Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

The more I work with JWSC, the more issues I seem to find. This new one is related to JavaCompiler and has the same smell as the other JWSC problem I've found. I've not had time to investigate this one in detail, but did find a workaround still.

The problem seemed to be that when I started to package my apps with javapackager I switched to Java 8 as my default JDK. Since I was on vacation at that time, I had no need to build any work projects and this issue went unnoticed for a week or so. When I got back to work and tried to build our code, it failed, with the error below...
 JWSC error message
[jwsc] Parsing source files
[AntUtil.deleteDir] Deleting directory /var/folders/y2/__zvkpb547zg92kgv6rx5m540000gn/T/_j2czzr
BUILD FAILED
build.xml:245: The following error occurred while executing this line:
build_targets.xml:201: java.lang.RuntimeException:
Parsing source file [xxxx.java] failed!
CAUSE:
An error has occurred while invoking com.sun.tools.javac.main.JavaCompiler
to inspect your source files.
We use the JavaCompiler to obtain import declarations when there are
STATIC-IMPORT declarations in your source files.
This situation elicits what is believed to the JavaCompiler has been loaded
in a different class loader before this time calling. One common case in
which this happens is when using the 'ant' tool, which uses a special context
classloader to load classes from tools.jar.
Alternatively, you can work around it by simply including
$JAVA_HOME/lib/tools.jar in the java -classpath parameter.
If you are running ant, you will need to modify the standard
ant script to include tools.jar in the -classpath.
Or you can redefine the static-import with single-type-import
declarations in your souce files, that will avoid using the
JavacCompiler parser.
at com.bea.util.jam.internal.parser.JamParser.parse(JamParser.java:109)
at com.bea.util.jam.internal.javadoc.JavadocImportHandler.parseFile(JavadocImportHandler.java:103)
at com.bea.util.jam.internal.javadoc.JavadocImportHandler.genImportSpecs(JavadocImportHandler.java:143)
at com.bea.util.jam.internal.javadoc.JavadocClassBuilder.initImportSpecs(JavadocClassBuilder.java:247)
at com.bea.util.jam.internal.javadoc.JavadocClassBuilder.build(JavadocClassBuilder.java:142)
at com.bea.util.jam.provider.CompositeJamClassBuilder.build(CompositeJamClassBuilder.java:51)
at com.bea.util.jam.internal.JamClassLoaderImpl.loadClass(JamClassLoaderImpl.java:128)
at com.bea.util.jam.internal.JamServiceImpl.getAllClasses(JamServiceImpl.java:65)
at weblogic.wsee.util.JamUtil.parseSource(JamUtil.java:157)
at weblogic.wsee.tools.anttasks.JwsLoader.loadJClasses(JwsLoader.java:186)
at weblogic.wsee.tools.anttasks.JwsLoader.load(JwsLoader.java:75)
at weblogic.wsee.tools.anttasks.JwsModule.loadWebServices(JwsModule.java:627)
at weblogic.wsee.tools.anttasks.JwsModule.generate(JwsModule.java:428)
at weblogic.wsee.tools.anttasks.JwsModule.build(JwsModule.java:302)
at weblogic.wsee.tools.anttasks.JwscTask.execute(JwscTask.java:240)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:441)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.Main.runBuild(Main.java:851)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)




At first I thought that the issue was with some of my code and build system changes of the service I was working on, however the same issue came up for every service I tried to build, so I decided it couldn't be a code issue and must be an environment problem.

I was on the right track. Checking the Java version showed me this...
 java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)


So I switched back to JDK 7, tried to build our services and it all worked again.

Not exactly sure why JWSC is failing like this, I'd like to get back to this issue later when I have time, but it is not a priority now.

-i

A quick disclaimer...

Although I put in a great effort into researching all the topics I cover, mistakes can happen. Use of any information from my blog posts should be at own risk and I do not hold any liability towards any information misuse or damages caused by following any of my posts.

All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle). Use of any information contained in this blog post/article is subject to this disclaimer.
Hi! You can search my blog here ⤵
NOTE: (2022) This Blog is no longer maintained and I will not be answering any emails or comments.

I am now focusing on Atari Gamer.