Проект NetBeans развернут в TomEE с перерывами FileNotFoundException - PullRequest
0 голосов
/ 17 апреля 2020

Здесь происходит нечто очень странное. Я использую Netbeans 11.3, apache -tomee-webprofile-8.0.1, JDK 10 для сборки этого приложения JEE, иногда оно работает в другое время сразу после сборки, когда оно начинает выдавать исключения. В pom нет никаких изменений. xml, но он начинает плохо себя вести, когда я настраиваю такие вещи, как OpenJPA. На данный момент я даже не уверен, где искать, поскольку поведение не является stati c или предсказуемым.

Исключение журнала сервера TomEE:

17-Apr-2020 00:09:34.632 INFO [http-nio-8080-exec-5] org.apache.catalina.core.ApplicationContext.log No state saving method defined, assuming default server state saving
17-Apr-2020 00:17:01.065 SEVERE [Catalina-utility-1] org.apache.catalina.core.StandardContext.listenerStop Exception sending context destroyed event to listener instance of class [org.apache.myfaces.webapp.StartupServletContextListener]
    java.lang.IllegalStateException: java.io.IOException: java.lang.reflect.InvocationTargetException
        at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.getArchiveEntry(AbstractSingleArchiveResourceSet.java:101)
        at org.apache.catalina.webresources.AbstractArchiveResourceSet.getResource(AbstractArchiveResourceSet.java:256)
        at org.apache.catalina.webresources.StandardRoot.getResourceInternal(StandardRoot.java:282)
        at org.apache.catalina.webresources.Cache.getResource(Cache.java:62)
        at org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:217)
        at org.apache.catalina.webresources.StandardRoot.getClassLoaderResource(StandardRoot.java:226)
        at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2303)
        at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:865)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1334)
        at org.apache.tomee.catalina.TomEEWebappClassLoader.loadClass(TomEEWebappClassLoader.java:208)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188)
        at org.primefaces.webapp.PreDestroyApplicationEventListener.processEvent(PreDestroyApplicationEventListener.java:41)
        at javax.faces.event.SystemEvent.processListener(SystemEvent.java:49)
        at org.apache.myfaces.application._ApplicationUtils._traverseListenerList(_ApplicationUtils.java:121)
        at org.apache.myfaces.application.ApplicationImpl$SystemListenerEntry.publish(ApplicationImpl.java:2737)
        at org.apache.myfaces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:634)
        at javax.faces.application.ApplicationWrapper.publishEvent(ApplicationWrapper.java:346)
        at org.apache.myfaces.webapp.AbstractFacesInitializer._dispatchApplicationEvent(AbstractFacesInitializer.java:366)
        at org.apache.myfaces.webapp.AbstractFacesInitializer.destroyFaces(AbstractFacesInitializer.java:410)
        at org.apache.myfaces.webapp.StartupServletContextListener.contextDestroyed(StartupServletContextListener.java:130)
        at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4730)
        at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5396)
        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257)
        at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:805)
        at org.apache.catalina.startup.HostConfig.undeploy(HostConfig.java:1425)
        at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1352)
        at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1611)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:305)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
        at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1151)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1353)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1357)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1335)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:514)
        at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.base/java.lang.Thread.run(Thread.java:844)
    Caused by: java.io.IOException: java.lang.reflect.InvocationTargetException
        at org.apache.tomcat.util.compat.Jre9Compat.jarFileNewInstance(Jre9Compat.java:236)
        at org.apache.tomcat.util.compat.JreCompat.jarFileNewInstance(JreCompat.java:162)
        at org.apache.catalina.webresources.AbstractArchiveResourceSet.openJarFile(AbstractArchiveResourceSet.java:307)
        at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.getArchiveEntry(AbstractSingleArchiveResourceSet.java:97)
        ... 39 more
    Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.GeneratedConstructorAccessor10.newInstance(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
        at org.apache.tomcat.util.compat.Jre9Compat.jarFileNewInstance(Jre9Compat.java:233)
        ... 42 more
    Caused by: java.nio.file.NoSuchFileException: /.../WEB-INF/lib/cdi-api-2.0.jar
        at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
        at java.base/sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
        at java.base/sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:145)
        at java.base/java.nio.file.Files.readAttributes(Files.java:1755)
        at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1220)
        at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:727)
        at java.base/java.util.zip.ZipFile$CleanableResource.get(ZipFile.java:845)
        at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:245)
        at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:175)
        at java.base/java.util.jar.JarFile.<init>(JarFile.java:341)
        ... 46 more
17-Apr-2020 00:17:13.380 SEVERE [Catalina-utility-1] org.apache.catalina.core.ApplicationContext.log Servlet.init() for servlet [Faces Servlet] threw exception
    java.lang.IllegalStateException: No Factories configured for this Application. This happens if the faces-initialization does not work at all - make sure that you properly include all configuration settings necessary for a basic faces application and that all the necessary libs are included. Also check the logging output of your web application and your container for any exceptions!
If you did that and find nothing, the mistake might be due to the fact that you use some special web-containers which do not support registering context-listeners via TLD files and a context listener is not setup in your web.xml.
A typical config looks like this;
<listener>
  <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>

pom. xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>

   <groupId>com.shoptext</groupId>
   <artifactId>MyApp</artifactId>
   <version>20200416</version>
   <packaging>war</packaging>

   <name>MyApp</name>

   <properties>
      <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   </properties>

   <repositories>
      <repository>  
         <id>prime-repo</id>  
         <name>PrimeFaces Maven Repository</name>  
         <url>http://repository.primefaces.org</url>  
         <layout>default</layout>  
      </repository>  
   </repositories>    

   <dependencies>
      <dependency>
         <groupId>org.primefaces</groupId>
         <artifactId>primefaces</artifactId>
         <version>8.0</version>
      </dependency>
      <dependency>
         <groupId>org.primefaces.themes</groupId>
         <artifactId>bluesky</artifactId>
         <version>1.0.8</version>
      </dependency>
      <dependency>
         <groupId>javax.enterprise</groupId>
         <artifactId>cdi-api</artifactId>
         <version>2.0.SP1</version>
      </dependency>
      <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <version>4.12</version>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.apache.openjpa</groupId>
         <artifactId>apache-openjpa</artifactId>
         <version>3.1.1</version>
         <type>zip</type>
         <classifier>binary-nodocs</classifier>
         <scope>provided</scope>         
      </dependency>
      <dependency>
         <groupId>javax</groupId>
         <artifactId>javaee-web-api</artifactId>
         <version>8.0.1</version>
         <scope>provided</scope>
      </dependency>
      <!-- Logging -->
      <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.13.1</version>
      </dependency>
      <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.13.1</version>
      </dependency> 
   </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>10</source>
                    <target>10</target>
                    <compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${endorsed.dir}</outputDirectory>
                            <silent>true</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>javax</groupId>
                                    <artifactId>javaee-endorsed-api</artifactId>
                                    <version>7.0</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

Я изменил фактическое имя приложения в этом вопросе на «AppName», чтобы было легче читать. Если не считать того, что все остальное работает как положено. Я использую Netbeans 11.3 для создания и работы над этим проектом, и теперь мне приходится воссоздавать его три раза. Я почти уверен, что это не имеет ничего общего с IDE, но на данный момент у меня нет идей. Вы сталкивались с этим раньше?

...