How can I run JDK 19 with Structured Concurrency? (ERROR: java.lang.NoClassDefFoundError: jdk/incubator/concurrent/StructuredTaskScope) - maven

Note: this post somehow related with this question; however, the error is different. So I am posting as another question.
I want to try the new Project Loom feature defined in: JEP 428: Structured Concurrency (Incubator)
I created a library project that uses class StructuredTaskScope, which can compile right.
Then I created a test project to demonstrate the use of library project, which can compile right too.
In pom.xml, both projects use:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<release>19</release>
<compilerArgs>
<arg>--enable-preview</arg>
<arg>--add-modules=jdk.incubator.concurrent</arg>
</compilerArgs>
</configuration>
</plugin>
However, When i try to run the test project, it returns error below:
C:\me\codes\com.tugalsan\tst\com.tugalsan.tst.thread>java -jar target/com.tugalsan.tst.thread-1.0-SNAPSHOT-jar-with-dependencies.jar --enable-preview --add-modules jdk.incubator.concurrent
Exception in thread "main" java.lang.NoClassDefFoundError: jdk/incubator/concurrent/StructuredTaskScope
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1013)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at com.tugalsan.api.thread.server.TS_ThreadFetchAll.<init>(TS_ThreadFetchAll.java:44)
at com.tugalsan.api.thread.server.TS_ThreadFetchAll.of(TS_ThreadFetchAll.java:85)
at com.tugalsan.tst.thread.Main.main(Main.java:13)
Caused by: java.lang.ClassNotFoundException: jdk.incubator.concurrent.StructuredTaskScope
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 12 more
I also tried adding '=' character, but no luck: java -jar target/com.tugalsan.tst.thread-1.0-SNAPSHOT-jar-with-dependencies.jar --enable-preview --add-modules=jdk.incubator.concurrent

As Joachim Sauer answered:
Everything after the -jar filename.jar will be passed as an argument.
Hence to run an app with jdk.incubator.concurrent, one should use below order:
java --enable-preview --add-modules jdk.incubator.concurrent -jar JARFILENAME.jar argument0 argument1 argument2...

Related

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/util/Tool

I get below error when i package (jar) and run my defaulthadoopjob.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/util/Tool
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.util.Tool
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 12 more
Could not find the main class: DefaultHadoopJobDriver. Program will exit.
Commands used to build Jar.
# jar -cvf dhj.jar
# hadoop -jar dhj.jar DefaultHadoopJobDriver
The above command gave me error "Failed to load Main-Class manifest attribute from dhj.jar"
rebuilt jar with manifest using below command
jar -cvfe dhj.jar DefaultHadoopJobDriver .
hadoop -jar dhj.jar DefaultHadoopJobDriver -- This returned the original error message that I reported above.
My Hadoop job has single class "DefaultHoopJobDrive" that extends Configures and implements Tool, and run method as only code for Job creation and inputpath,outpurpath set.
Aslo I.m using new API.
I'm running hadoop 1.2.1 and the Job works fine from eclipse.
This might be something to do with the classpath. Please help.
For executing that jar you don't have to give hadoop -jar. The command is like so:
hadoop jar <jar> [mainClass] args...
If this jar again gets the java.lang.ClassNotFoundException exception then can you use the:
hadoop classpath
command to see whether hadoop-core-1.2.1.jar is present in your hadoop installations classpath?
FYI, and if it's not present in this list you have to add this jar to the hadoop lib directory.
Try building your hadoop java code with all hadoop jars available in hadoop's lib folder.
In this case you are missing the hadoop util class which is present in the hadoop-core-*.jar
Classpath can be specified while building the code within the jar or you can externalise it using the following command
hadoop -cp <path_containing_hadoop_jars> -jar <jar_name>
In case anyone is using Maven and lands here: Dependency issues can be resolved by asking Maven to include any jars it requires within the parent project's jar itself. That way, Hadoop doesn't have to look elsewhere for dependencies -- it can find them right there itself. Here's how to do this:
1. Go to pom.xml
Add a section to your <project> tag, called <build>
Add the following to your <build></build> section:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.7.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<excludes>
<exclude>org.slf4j:slf4j-api</exclude>
<exclude>junit:junit</exclude>
<exclude>jmock:jmock</exclude>
<exclude>xml-apis:xml-apis</exclude>
<exclude>org.testng:testng</exclude>
<exclude>org.mortbay.jetty:jetty</exclude>
<exclude>org.mortbay.jetty:jetty-util</exclude>
<exclude>org.mortbay.jetty:servlet-api-2.5</exclude>
<exclude>tomcat:jasper-runtime</exclude>
<exclude>tomcat:jasper-compiler</exclude>
<exclude>org.apache.hadoop:hadoop-core</exclude>
<exclude>org.apache.mahout:mahout-math</exclude>
<exclude>commons-logging:commons-logging</exclude>
<exclude>org.mortbay.jetty:jsp-api-2.1</exclude>
<exclude>org.mortbay.jetty:jsp-2.1</exclude>
<exclude>org.eclipse.jdt:core</exclude>
<exclude>ant:ant</exclude>
<exclude>org.apache.hadoop:avro</exclude>
<exclude>jline:jline</exclude>
<exclude>log4j:log4j</exclude>
<exclude>org.yaml:snakeyaml</exclude>
<exclude>javax.ws.rs:jsr311-api</exclude>
<exclude>org.slf4j:jcl-over-slf4j</exclude>
<exclude>javax.servlet:servlet-api</exclude>
</excludes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/jruby.home</exclude>
<exclude>META-INF/license</exclude>
<exclude>META-INF/maven</exclude>
<exclude>META-INF/services</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
Now build your project again, and run with the normal hadoop java my.jar ... command. It shouldn't cry about dependencies now. Hope this helps!

Karaf OSGi: JAX-RS with CXF: ClassNotFoundException: org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl

When installing a CXF web service bundle in Karaf OSGi (built with maven), the following error is logged:
2013-03-18 15:08:29,050 | ERROR | rint Extender: 2 | BlueprintContainerImpl | container.BlueprintContainerImpl 393 | 7 - org.apache.aries.blueprint.core - 1.1.0 | Unable to start blueprint container for bundle service-server
org.osgi.service.blueprint.container.ComponentDefinitionException: Error setting property: PropertyDescriptor <name: serviceBeans, getter: null, setter: [class org.apache.cxf.jaxrs.JAXRSServerFactoryBean.setServiceBeans(interface java.util.List)]
at org.apache.aries.blueprint.container.BeanRecipe.setProperty(BeanRecipe.java:941)[7:org.apache.aries.blueprint.core:1.1.0]
at org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:907)[7:org.apache.aries.blueprint.core:1.1.0]
at org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:888)[7:org.apache.aries.blueprint.core:1.1.0]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:820)[7:org.apache.aries.blueprint.core:1.1.0]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[7:org.apache.aries.blueprint.core:1.1.0]
at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[7:org.apache.aries.blueprint.core:1.1.0]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)[:1.6.0_41]
at java.util.concurrent.FutureTask.run(FutureTask.java:138)[:1.6.0_41]
at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[7:org.apache.aries.blueprint.core:1.1.0]
at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)[7:org.apache.aries.blueprint.core:1.1.0]
at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)[7:org.apache.aries.blueprint.core:1.1.0]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:668)[7:org.apache.aries.blueprint.core:1.1.0]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:370)[7:org.apache.aries.blueprint.core:1.1.0]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:261)[7:org.apache.aries.blueprint.core:1.1.0]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)[:1.6.0_41]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)[:1.6.0_41]
at java.util.concurrent.FutureTask.run(FutureTask.java:138)[:1.6.0_41]
at org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)[7:org.apache.aries.blueprint.core:1.1.0]
at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)[7:org.apache.aries.blueprint.core:1.1.0]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)[:1.6.0_41]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)[:1.6.0_41]
at java.util.concurrent.FutureTask.run(FutureTask.java:138)[:1.6.0_41]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)[:1.6.0_41]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)[:1.6.0_41]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)[:1.6.0_41]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)[:1.6.0_41]
at java.lang.Thread.run(Thread.java:662)[:1.6.0_41]
Caused by: java.lang.ExceptionInInitializerError
at org.apache.cxf.jaxrs.utils.JAXRSUtils.<clinit>(JAXRSUtils.java:107)
at org.apache.cxf.jaxrs.model.ClassResourceInfo.getConsumeMime(ClassResourceInfo.java:239)
at org.apache.cxf.jaxrs.model.OperationResourceInfo.checkMediaTypes(OperationResourceInfo.java:171)
at org.apache.cxf.jaxrs.model.OperationResourceInfo.<init>(OperationResourceInfo.java:74)
at org.apache.cxf.jaxrs.utils.ResourceUtils.createOperationInfo(ResourceUtils.java:354)
at org.apache.cxf.jaxrs.utils.ResourceUtils.evaluateResourceClass(ResourceUtils.java:221)
at org.apache.cxf.jaxrs.utils.ResourceUtils.createClassResourceInfo(ResourceUtils.java:207)
at org.apache.cxf.jaxrs.JAXRSServiceFactoryBean.setResourceClassesFromBeans(JAXRSServiceFactoryBean.java:218)
at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.setServiceBeans(JAXRSServerFactoryBean.java:295)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.6.0_41]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)[:1.6.0_41]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_41]
at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_41]
at org.apache.aries.blueprint.utils.ReflectionUtils$MethodPropertyDescriptor.internalSet(ReflectionUtils.java:628)
at org.apache.aries.blueprint.utils.ReflectionUtils$PropertyDescriptor.set(ReflectionUtils.java:378)
at org.apache.aries.blueprint.container.BeanRecipe.setProperty(BeanRecipe.java:939)
... 26 more
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl
at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:122)
at javax.ws.rs.ext.RuntimeDelegate.getInstance(RuntimeDelegate.java:91)
at javax.ws.rs.core.MediaType.<clinit>(MediaType.java:44)
... 42 more
Caused by: java.lang.ClassNotFoundException: org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)[:1.6.0_41]
at java.security.AccessController.doPrivileged(Native Method)[:1.6.0_41]
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)[:1.6.0_41]
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)[:1.6.0_41]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)[:1.6.0_41]
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)[:1.6.0_41]
at javax.ws.rs.ext.FactoryFinder.newInstance(FactoryFinder.java:37)
at javax.ws.rs.ext.FactoryFinder.find(FactoryFinder.java:133)
at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:105)
... 44 more
This changed from the previous Caused by: java.lang.ClassNotFoundException: com.sun.rs.ws.ext.RuntimeDelegateImpl when, based on the suggestion from several locations, I added the following line my ext/system.properties file:
javax.ws.rs.ext.RuntimeDelegate=org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl
I'm also explicitly importing this package in my pom with:
<build>
...
<plugins>
...
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.6</version>
<extensions>true</extensions>
<configuration>
<instructions>
...
<Import-Package>org.apache.cxf.jaxrs.impl,*</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
The only bundles exporting anything related (as far as I can tell) are:
Apache ServiceMix :: Specs :: JSR-311 API 1.1.1(org.apache.servicemix.specs.jsr311-api-1.1.1)
Exporting:
javax.ws.rs,version=1.1.1
javax.ws.rs.core,version=1.1.1
javax.ws.rs.ext,version=1.1.1
Apache CXF Bundle Jar(org.apache.cxf.bundle)
Exporting
~25 org.apache.cxf.jaxrs.____ or so packages (including impl)
Can anyone help? I haven't managed to find any fixes that resolve the issue.
Not really an answer, but my solution was to drop CXF entirely. Now using simple servlets (javax.servlet)

xmlbeans-maven-plugin not finding javac

I am trying to setup xmlbeans-maven-plugin 2.3.3 in my Eclipse and while everything seems to go OK, It fails with an java.io.IOException due to inability to find the file C:\Users\Daniel\Workspace\MyProject\javac.
This is strange because javac is on the system's %PATH% so why would it try to find it in %PROJECT_LOC%?
I found this problem description which sounds very similar to mine, but I placed the JDK path in front of all other paths and that didn't help.
Any idea how to tell the xmlbeans-maven-plugin where to look for javac?
UPDATE 1: I tried working around this problem by simply copying javac.exe to the project's directory and at least it now finds it but the problem moved forward to:
java.lang.NoClassDefFoundError: com/sun/tools/javac/Main
Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.Main
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main" Could not find the main class: com.sun.tools.javac.Main. Program will exit.
Any insight that could help come up with the correct solution to this (e.g. something in .m2/settings.xml?) would be appreciated.
UPDATE 2: I also tried this little solution I found in my searches:
<settings 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/settings-1.0.0.xsd">
<localRepository>c:\maven\repository</localRepository>
<configuration>
<compiler>C:\Program Files (x86)\Java\jdk1.6.0_37\bin\javac.exe</compiler>
</configuration>
</settings>
But that didn't help the plugin find javac. It still complains about "The system cannot find the file specified" for javac.exe.
Found the solution! In the project's pom.xml, simply add the following inside <configuration>:
<compiler>C:\Program Files (x86)\Java\jdk1.6.0_37\bin\javac.exe</compiler>
i.e.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xmlbeans-maven-plugin</artifactId>
<version>2.3.3</version>
<executions>
<execution>
<goals>
<goal>xmlbeans</goal>
</goals>
</execution>
</executions>
<inherited>true</inherited>
<configuration>
<schemaDirectory>${basedir}/src/main/xsd</schemaDirectory>
<compiler>C:\Program Files (x86)\Java\jdk1.6.0_37\bin\javac.exe</compiler>
</configuration>
</plugin>
Also, be sure to point the Window -> Preferences -> Java -> installed JREs to the JDK's, not JRE's: C:\Program Files (x86)\Java\jdk1.6.0_37. As described in this thread.

merging two war files with overlays

I have to merge two war files. I use eclipse indigo and maven 2. So I put one war as a dependency in the others pom.xml and added the overlay option as well:
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<overlays>
<overlay>
<groupId>org.mydomain</groupId>
<artifactId>myproject</artifactId>
</overlay>
</overlays>
...
I use this to add all dependencies as jar's to my lib folder:
...
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<outputDirectory>${project.build.directory}/webapp/WEB-INF/lib</outputDirectory>
</configuration>
</plugin>
...
So if I perform maven install a proper war file is build with everything in it. The problem is when I deploy this on the glassfish server (3.1) there are no classes deployed (I looked in the eclipseApps folder in my glassfish folder). The jar's are there, the folders are there but empty. So it does not work on the server.
Anyone an idea?
Update:
As proposed in the comments I put the war file in the autodeploy folder and got the following errors:
INFO: Initializing Mojarra 2.1.0 (FCS 2.1.0-b11) for context ''
INFO: Unsanitized stacktrace from failed start...
com.sun.faces.config.ConfigurationException: java.util.concurrent.ExecutionException: com.sun.faces.config.ConfigurationException: Unable to parse document 'bundle://237.0:1/com/sun/faces/jsf-ri-runtime.xml': null
at com.sun.faces.config.ConfigManager.getConfigDocuments(ConfigManager.java:675)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:322)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:225)
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:4690)
at com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:534)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5305)
at com.sun.enterprise.web.WebModule.start(WebModule.java:500)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:755)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1980)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1630)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:100)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:286)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:364)
at com.sun.enterprise.v3.admin.adapter.InstallerThread.load(InstallerThread.java:210)
at com.sun.enterprise.v3.admin.adapter.InstallerThread.run(InstallerThread.java:108)
Caused by: java.util.concurrent.ExecutionException: com.sun.faces.config.ConfigurationException: Unable to parse document 'bundle://237.0:1/com/sun/faces/jsf-ri-runtime.xml': null
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:252)
at java.util.concurrent.FutureTask.get(FutureTask.java:111)
at com.sun.faces.config.ConfigManager.getConfigDocuments(ConfigManager.java:673)
... 19 more
Caused by: com.sun.faces.config.ConfigurationException: Unable to parse document 'bundle://237.0:1/com/sun/faces/jsf-ri-runtime.xml': null
at com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:923)
at com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:868)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at com.sun.faces.config.ConfigManager.getConfigDocuments(ConfigManager.java:659)
... 19 more
Caused by: java.lang.NullPointerException
at java.util.Arrays$ArrayList.<init>(Arrays.java:2842)
at java.util.Arrays.asList(Arrays.java:2828)
at com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings.addRecognizedFeatures(ParserConfigurationSettings.java:115)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.<init>(DocumentBuilderImpl.java:182)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(DocumentBuilderFactoryImpl.java:76)
at com.sun.faces.config.ConfigManager$ParseTask.getBuilderForSchema(ConfigManager.java:1133)
at com.sun.faces.config.ConfigManager$ParseTask.getDocument(ConfigManager.java:1002)
at com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:914)
... 23 more
SEVERE: Critical error during deployment:
com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:379)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:225)
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:4690)
at com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:534)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5305)
at com.sun.enterprise.web.WebModule.start(WebModule.java:500)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:755)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1980)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1630)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:100)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:286)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:364)
at com.sun.enterprise.v3.admin.adapter.InstallerThread.load(InstallerThread.java:210)
at com.sun.enterprise.v3.admin.adapter.InstallerThread.run(InstallerThread.java:108)
Caused by: java.lang.NullPointerException
at java.util.Arrays$ArrayList.<init>(Arrays.java:2842)
at java.util.Arrays.asList(Arrays.java:2828)
at com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings.addRecognizedFeatures(ParserConfigurationSettings.java:115)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.<init>(DocumentBuilderImpl.java:182)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(DocumentBuilderFactoryImpl.java:76)
at com.sun.faces.config.ConfigManager$ParseTask.getBuilderForSchema(ConfigManager.java:1133)
at com.sun.faces.config.ConfigManager$ParseTask.getDocument(ConfigManager.java:1002)
at com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:914)
at com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:868)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at com.sun.faces.config.ConfigManager.getConfigDocuments(ConfigManager.java:659)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:322)
... 18 more
SEVERE: PWC1306: Startup of context failed due to previous errors
SEVERE: PWC1305: Exception during cleanup after start failed

maven jetty plugin log4j configuration

i have a java web app with maven.
i'm using jetty to run it during development (by using maven jetty plugin)
i've my log4j.properties file placed under src/main/resources and it is copied under WEB-INF/classes when deployed as expected.
in my log4j.properties file i defined a filter variable and when deployed it is also filtered with the real value.
in log4j.properties under src/main/resources;
log4j.appender.FILE.File = ${config-gui.log-file}
in log4j.properties under WEB-INF/classes (after deployed with filtering);
log4j.appender.FILE.File = /tmp/mylogfile.log
my problem is; i'm getting following error when i run mvn jetty:run
log4j:ERROR setFile(null,true) call failed.<br />
java.io.FileNotFoundException: (No such file or directory)
at java.io.FileOutputStream.openAppend(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:177)
at java.io.FileOutputStream.<init>(FileOutputStream.java:102)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:289)
at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:163)
at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:215)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:256)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:132)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:96)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:654)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:612)
at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:509)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:415)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:441)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:470)
at org.apache.log4j.LogManager.<clinit>(LogManager.java:122)
at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:73)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:88)
at com.pribas.bucherplayerconfiggui.util.LoggerUtil.getLogger(LoggerUtil.java:10)
at com.pribas.bucherplayerconfiggui.Initialization.<clinit>(Initialization.java:22)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.mortbay.jetty.webapp.WebXmlConfiguration.newListenerInstance(WebXmlConfiguration.java:649)
at org.mortbay.jetty.webapp.WebXmlConfiguration.initListener(WebXmlConfiguration.java:630)
at org.mortbay.jetty.webapp.WebXmlConfiguration.initWebXmlElement(WebXmlConfiguration.java:367)
at org.mortbay.jetty.plus.webapp.AbstractConfiguration.initWebXmlElement(AbstractConfiguration.java:190)
at org.mortbay.jetty.webapp.WebXmlConfiguration.initialize(WebXmlConfiguration.java:289)
at org.mortbay.jetty.plus.webapp.AbstractConfiguration.initialize(AbstractConfiguration.java:133)
at org.mortbay.jetty.webapp.WebXmlConfiguration.configure(WebXmlConfiguration.java:222)
at org.mortbay.jetty.plus.webapp.AbstractConfiguration.configure(AbstractConfiguration.java:113)
at org.mortbay.jetty.webapp.WebXmlConfiguration.configureWebApp(WebXmlConfiguration.java:180)
at org.mortbay.jetty.plus.webapp.AbstractConfiguration.configureWebApp(AbstractConfiguration.java:96)
at org.mortbay.jetty.plus.webapp.Configuration.configureWebApp(Configuration.java:124)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1217)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:510)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
at org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart(Jetty6PluginWebAppContext.java:110)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
at org.mortbay.jetty.plugin.AbstractJettyRunMojo$1.filesChanged(AbstractJettyRunMojo.java:409)
at org.mortbay.util.Scanner.reportBulkChanges(Scanner.java:493)
at org.mortbay.util.Scanner.reportDifferences(Scanner.java:359)
at org.mortbay.util.Scanner.scan(Scanner.java:286)
at org.mortbay.util.Scanner$1.run(Scanner.java:246)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
i think this error is because of it sees log4j.properties file which is under src/main/resources (which has appender's file param is not acceptable) instead of under WEB-INF/classes one.
i want maven jetty plugin to ignore log4j.properties file which is under src/main/resources and sees the one under WEB-INF/classes.
how can i do this?
or if this error is not related the idea i have, how can i solve this?
thx in advance.
I think, you can hardly guarantee which of log4j.properties will be used on in your jar or in WEB-INF/classes. It depends on concrete classloader implementation (in Tomcat or Jetty) which can either see WEB-INF/classes/log4j.properties or WEB-INF/libs/yourlib.jar:/log4j.properties. So you need to filter here or there :)
Using maven profiles you can configure the <excludes> for your resources and use this profile for to build web application for Tomcat deployment.
Maybe better solution will be renaming /src/main/resources/log4j.properties to /src/main/resources/log4j-jetty.properties and then configure Log4j via jetty plugin to use that resource:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<configuration>
...
<systemProperties>
<systemProperty>
<name>log4j.configuration</name>
<value>log4j-jetty.properties</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>

Resources