Forum Stats

  • 3,757,875 Users
  • 2,251,286 Discussions
  • 7,869,957 Comments

Discussions

Ant build failed due to Parsing source file failed

user11071643
user11071643 Member Posts: 2
edited Apr 14, 2017 7:29PM in Java 8 Questions

I just started working on a PROD TAG for a change request and was able to build through ANT. After I added few java files, I am not able to build the project.

However I am still able to build the original PROD Tag.

1. There is no compile issue in Eclipse.

2. Able to execute my test classes

3. Imp point - It is complaining about the Static Imports. In my case, we have many java files where the APP Specific Constants are maintained and those are being used through out the project by importing those classes and referring to the constants in other Java classes

4. Project is using Java 8() and already in PRODUCTION

5. ANT VERSION 1.9.4

Not sure what it is.

Here is the stack trace -

BUILD FAILED

java.lang.RuntimeException:

Parsing source file [C:\app\14_0_50_Tag\InformationMessageDescriptor.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.application.utils.AnnotationDetector.hasAnnotatedSources(AnnotationDetector.java:179)

        at weblogic.ejb.spi.EJBJarUtils.hasEJBSources(EJBJarUtils.java:35)

        at weblogic.ant.taskdefs.build.module.EJBModuleFactory.claim(EJBModuleFactory.java:48)

        at weblogic.ant.taskdefs.build.module.ModuleFactory.createModules(ModuleFactory.java:76)

        at weblogic.ant.taskdefs.build.Application.build(Application.java:59)

        at weblogic.ant.taskdefs.build.WLCompileTask.privateExecute(WLCompileTask.java:194)

        at weblogic.ant.taskdefs.build.WLCompileTask.execute(WLCompileTask.java:160)

        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)

        at sun.reflect.GeneratedMethodAccessor3.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:357)

        at org.apache.tools.ant.Target.performTasks(Target.java:385)

        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)

        at org.apache.tools.ant.Project.executeTarget(Project.java:1306)

        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)

        at org.apache.tools.ant.Project.executeTargets(Project.java:1189)

        at org.apache.tools.ant.Main.runBuild(Main.java:758)

        at org.apache.tools.ant.Main.startAnt(Main.java:217)

        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)

        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)

Answers

  • user11071643
    user11071643 Member Posts: 2
    edited Apr 13, 2017 1:21PM

    I got the answer.

    I included an static import as in my class

    import static org.apache.commons.lang.StringUtils.trimToEmpty;

    and was using like this b.setName(trimToEmpty(rs.getString("name")));

    It took 2 days to figure this out.

    Ideally the import should be broker.setBarcode(trimToEmpty(rs.getString("name")));

    and should be used like this

    b.setName(StringUtils.trimToEmpty(rs.getString("name")));

  • Unknown
    edited Apr 14, 2017 7:29PM

    Then please mark the thread ANSWERED.