Modify

Opened 10 years ago

Closed 10 years ago

Last modified 6 years ago

#10040 closed defect (fixed)

Broken compilation for newer JDKs

Reported by: akks Owned by: team
Priority: normal Milestone: 14.06
Component: Core Version: latest
Keywords: Cc: Don-vip

Description (last modified by akks)

Adding JAXB-generated classes in r7133 leads to the problem with JDK8:

svn co https://josm.openstreetmap.de/svn/trunk
cd trunk
ant dist 

gives the following exception:

BUILD FAILED
F:\Java\trunk\build.xml:207: java.lang.AssertionError: org.xml.sax.SAXParseException; systemId: jar:file:/F:/Java/trunk/tools/jaxb/jaxb-xjc.jar!/com/sun/tools/xjc/reader/xmlschema/bindinfo/binding.xsd; lineNumber: 52; columnNumber: 88; schema_reference: Failed to read schema document 'xjc.xsd', because 'file' access is not allowed due to restriction set by the accessExternalSchema property. 

The problem is known for newer JDKs (security reasons), but I could not solve it by adding <arg value="-disableXmlSecurity" />.

Attachments (0)

Change History (27)

comment:1 by akks, 10 years ago

Description: modified (diff)

comment:2 by Don-vip, 10 years ago

There was a similar bug in jdk8 itself: 8020999.

comment:3 by Don-vip, 10 years ago

What's your version of Java and Ant ? I have setup a new continuous integration project for Java 8, and it works fine with:

~# /usr/lib/jvm/java-8-oracle/bin/java -version
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

~# ant -version
Apache Ant(TM) version 1.9.2 compiled on July 14 2013

comment:4 by akks, 10 years ago

F:\Java\trunk>java -version
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

F:\Java\trunk>ant -version
Apache Ant(TM) version 1.9.3 compiled on December 23 2013

(tested with Ant 1.9.4 too), Windows 8.1 64 bit.
The problem can be solved by running

set ANT_OPTS=-Djavax.xml.accessExternalSchema=file

before compilation (or patching ant.bat). This option can not be easily included into build.xml (only if we remove all jaxb jars and just exec xjc from command line). Not sure, maybe the ticket should be closed.

The bug is said to be fixed in Java 8. Indeed,
xjc data_nodist/wms-cache.xsd works from command line without errors.
Maybe some of our jaxb-jars are not patched? (tried 2.2.7 from Maven - the same errors)

Latest beta jaxb-xjc from http://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-xjc works without any errors, but then the encoding=UTF-8 should be removed as unsupported.

comment:5 by Don-vip, 10 years ago

Milestone: 14.0514.06

Reproduced also on my Windows setup. But if you have found a temporary solution, it can wait a further release. We'll see plenty of new things in the next weeks, like a new version of Eclipse with a new version of Ant, proper JDK8 support, JDK8 updates 11 and 20, etc. Remember we just moved to Java 7, not 8 yet :)

comment:6 by akks, 10 years ago

I agree. When the JAXB release will be published (not beta), we can use the new JARs and get rid of this problem. For now, let us use ANT_OPTS=-Djavax.xml.accessExternalSchema=file in environment.

comment:7 by Don-vip, 10 years ago

I still don't get it however, why I don't observe the problem on Linux :D

comment:8 by stoecker, 10 years ago

Hmm, on my system JAXB fails with:

Caught an exception while logging the end of the build.  Exception was:
java.lang.NoClassDefFoundError: org/apache/tools/ant/util/DateUtils
        at org.apache.tools.ant.DefaultLogger.formatTime(DefaultLogger.java:330)
        at org.apache.tools.ant.DefaultLogger.buildFinished(DefaultLogger.java:177)
        at org.apache.tools.ant.Project.fireBuildFinished(Project.java:2087)
        at org.apache.tools.ant.Main.runBuild(Main.java:872)
        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)
Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.util.DateUtils
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        ... 7 more
There has been an error prior to that:
/home/stoecker/sources/josm/core/build.xml:215: Problem: failed to create task or type javac
Cause: the class org.apache.tools.ant.taskdefs.Javac was not found.
Action: Check that the component has been correctly declared
        and that the implementing JAR is in one of:
        -/usr/share/ant/lib
        -/home/stoecker/.ant/lib
        -a directory added on the command line with the -lib argument

Do not panic, this is a common problem.
It may just be a typographical error in the build file or the task/type declaration.
The commonest cause is a missing JAR.

This is not a bug; it is a configuration problem

        at org.apache.tools.ant.UnknownElement.getNotFoundException(UnknownElement.java:499)
        at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:431)
        at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:163)
        at org.apache.tools.ant.Task.perform(Task.java:347)
        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)

I say that change should be reversed until it works stable on all systems.

in reply to:  8 comment:9 by Don-vip, 10 years ago

Replying to stoecker:

> /home/stoecker/sources/josm/core/build.xml:215: Problem: failed to create task or type javac
Cause: the class org.apache.tools.ant.taskdefs.Javac was not found.
Action: Check that the component has been correctly declared
        and that the implementing JAR is in one of:
        -/usr/share/ant/lib
        -/home/stoecker/.ant/lib
        -a directory added on the command line with the -lib argument

Do not panic, this is a common problem.
It may just be a typographical error in the build file or the task/type declaration.
The commonest cause is a missing JAR.

This is not a bug; it is a configuration problem

It doesn't look like related to the JAXB change but a serious configuration problem on your side. Javac is a core Ant task.

I say that change should be reversed until it works stable on all systems.

I'm ok to fix problems, but we won't make this stuff stable by reverting it.

comment:10 by stoecker, 10 years ago

I don't understand why it causes an error of javac. But the error is caused by jaxb target. It does not happen when I remove "jaxb" dep or when I downgrade to previous version of build.xml.

Here the result of only "ant jaxb". It seems somehow the classpath for normal imports gets lost.

stoecker@mumm:~/josm/core> ant jaxb
Buildfile: /home/stoecker/sources/josm/core/build.xml

init:

jaxb:
      [xjc] files are up to date
Caught an exception while logging the end of the build.  Exception was:
java.lang.NoClassDefFoundError: org/apache/tools/ant/util/DateUtils
        at org.apache.tools.ant.DefaultLogger.formatTime(DefaultLogger.java:330)
        at org.apache.tools.ant.DefaultLogger.buildFinished(DefaultLogger.java:177)
        at org.apache.tools.ant.Project.fireBuildFinished(Project.java:2087)
        at org.apache.tools.ant.Main.runBuild(Main.java:872)
        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)
Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.util.DateUtils
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        ... 7 more

comment:11 by Don-vip, 10 years ago

Strange, I don't have this problem on my Ubuntu machines. Can you please attach the output of ant -v jaxb and check the contents of the folders given in error message:

-/usr/share/ant/lib
-/home/stoecker/.ant/lib

comment:12 by stoecker, 10 years ago

Apache Ant(TM) version 1.9.2 compiled on October 2 2013
Trying the default build file: build.xml
Buildfile: /home/stoecker/sources/josm/core/build.xml
Detected Java version: 1.7 in: /usr/lib64/jvm/java-1.7.0-openjdk-1.7.0/jre
Detected OS: Linux
parsing buildfile /home/stoecker/sources/josm/core/build.xml with URI = file:/home/stoecker/sources/josm/core/build.xml
Project base dir set to: /home/stoecker/sources/josm/core
parsing buildfile jar:file:/usr/share/java/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/usr/share/java/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file
Property "clevel" has not been set
 [macrodef] creating macro  init-test-preferences
 [macrodef] creating macro  call-groovyc
 [macrodef] creating macro  call-junit
Build sequence for target(s) `jaxb' is [init, jaxb]
Complete build sequence is [init, jaxb, test-init, init-svn-revision-xml, init-git-revision-xml, create-revision, mac, javadoc, javacc, compile, check-schemas, dist, findbugs, distmac, create-revision-eclipse, test-clean, run, clean, test-compile, test, test-html, dist-optimized, check-plugins, ]

init:
 [uptodate] MapCSSParser.jj omitted as /home/stoecker/sources/josm/core/src/org/openstreetmap/josm/gui/mappaint/mapcss/parsergen/MapCSSParser.java is up to date.
 [uptodate] File "/home/stoecker/sources/josm/core/src/org/openstreetmap/josm/gui/mappaint/mapcss/parsergen/MapCSSParser.java" is up-to-date.
    [mkdir] Skipping /home/stoecker/sources/josm/core/build because it already exists.
    [mkdir] Skipping /home/stoecker/sources/josm/core/dist because it already exists.

jaxb:
      [xjc] build id of XJC is 2.2.7
      [xjc] Checking timestamp of /home/stoecker/sources/josm/core/data_nodist/wms-cache.xsd
      [xjc] Checking timestamp of /home/stoecker/sources/josm/core/src/org/openstreetmap/josm/data/imagery/WmsCache.java
      [xjc] Checking timestamp of /home/stoecker/sources/josm/core/src/org/openstreetmap/josm/data/imagery/types/EntryType.java
      [xjc] Checking timestamp of /home/stoecker/sources/josm/core/src/org/openstreetmap/josm/data/imagery/types/ObjectFactory.java
      [xjc] Checking timestamp of /home/stoecker/sources/josm/core/src/org/openstreetmap/josm/data/imagery/types/ProjectionType.java
      [xjc] Checking timestamp of /home/stoecker/sources/josm/core/src/org/openstreetmap/josm/data/imagery/types/WmsCacheType.java
      [xjc] Checking timestamp of /home/stoecker/sources/josm/core/src/org/openstreetmap/josm/data/imagery/types/package-info.java
      [xjc] the last modified time of the inputs is  1401640706000
      [xjc] the last modified time of the outputs is 1401640756000
      [xjc] files are up to date
Caught an exception while logging the end of the build.  Exception was:
java.lang.NoClassDefFoundError: org/apache/tools/ant/util/DateUtils
	at org.apache.tools.ant.DefaultLogger.formatTime(DefaultLogger.java:330)
	at org.apache.tools.ant.DefaultLogger.buildFinished(DefaultLogger.java:177)
	at org.apache.tools.ant.Project.fireBuildFinished(Project.java:2087)
	at org.apache.tools.ant.Main.runBuild(Main.java:872)
	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)
Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.util.DateUtils
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	... 7 more
stoecker@mumm:~/josm/core> ls /usr/share/ant/lib -la
insgesamt 8
drwxr-xr-x 2 root root 4096  1. Jan 23:18 .
drwxr-xr-x 5 root root 4096 31. Dez 21:45 ..
lrwxrwxrwx 1 root root   28 31. Dez 21:45 ant-bootstrap.jar -> ../../java/ant-bootstrap.jar
lrwxrwxrwx 1 root root   18 31. Dez 21:45 ant.jar -> ../../java/ant.jar
lrwxrwxrwx 1 root root   29  1. Jan 23:18 ant-junit4.jar -> ../../java/ant/ant-junit4.jar
lrwxrwxrwx 1 root root   28  1. Jan 23:18 ant-junit.jar -> ../../java/ant/ant-junit.jar
lrwxrwxrwx 1 root root   27 31. Dez 21:45 ant-launcher.jar -> ../../java/ant-launcher.jar

/home/stoecker/.ant/lib does not exist. "ant.jar" contains the missing class".

stoecker@mumm:~/josm/core> unzip -l /usr/share/ant/lib/ant.jar |grep -e "org.apache.tools.ant.taskdefs.Javac" -e "org/apache/tools/ant/util/DateUtils"
      801  2013-10-02 12:58   org/apache/tools/ant/taskdefs/Javac$ImplementationSpecificArgument.class
    20697  2013-10-02 12:58   org/apache/tools/ant/taskdefs/Javac.class
     4995  2013-10-02 12:58   org/apache/tools/ant/util/DateUtils.class

As said. It seems the jaxb target kills the following call somehow.

comment:13 by stoecker, 10 years ago

If I remove the xjc part in jaxb target it works also. So the call of <xjc> causes the issue, not that classpath defs above.

comment:14 by Don-vip, 10 years ago

Any change of behaviour if you add loaderref="xjc.loader" attribute to <taskdef name="xjc" ... > definition?

in reply to:  14 comment:15 by stoecker, 10 years ago

Replying to Don-vip:

Any change of behaviour if you add loaderref="xjc.loader" attribute to <taskdef name="xjc" ... > definition?

No change.

comment:16 by stoecker, 10 years ago

Wanna access to an openSUSE 13.1 system?

comment:17 by Don-vip, 10 years ago

Yes, please, as I cannot reproduce it on Ubuntu :)

comment:18 by akks, 10 years ago

Less important but also 'problematic' task is ant test. On Windows it runs correctly (with some failing tests) but on testing FreeBSD 10 (Ant 1.9.4 via tar.gz and OpenJDK 1.8.0_05) there are running errors:

...
dist:
     [echo] Revision 7207
   [delete] Deleting: /usr/home/ak/josm/dist/josm-custom.jar
      [jar] Building jar: /usr/home/ak/josm/dist/josm-custom.jar
test-compile:
BUILD FAILED
/usr/home/ak/josm/build.xml:322: The following error occurred while executing this line:
/usr/home/ak/josm/build.xml:309: /usr/home/ak/josm/lib does not exist.
Last edited 10 years ago by akks (previous) (diff)

in reply to:  18 comment:19 by Don-vip, 10 years ago

Replying to akks:

(Ant 1.9.4 via tar.gz and OpenJDK 1.8.0_05) there are running errors:

Maybe a Groovy update can help :)

comment:20 by Don-vip, 10 years ago

In 7208/josm:

see #10040 - update Groovy to 2.3.2 (official version for running Groovy on JDK 8)

comment:21 by akks, 10 years ago

It did help but only together with mkdir lib. Then it started giving errors about default encoding :(
BSD is too strange, I guess. OpenSuse problem is more important.

comment:22 by Don-vip, 10 years ago

In 7209/josm:

see #10040 - call JDK xjc native executable instead of ant task to avoid problems with JDK8 and OpenSUSE systems

comment:23 by Don-vip, 10 years ago

In 7212/josm:

see #10040 - update Eclipse config files

comment:24 by Don-vip, 10 years ago

Resolution: fixed
Status: newclosed

comment:25 by stoecker, 10 years ago

Thanks fine. Works like a charm.

comment:26 by akks, 10 years ago

In 7215/josm:

update Netbeans project, skip jaxb build target if not needed (see #10040)

comment:27 by ashishgp11@…, 6 years ago

Hi,

I am having the same issue mentioned below with JDK8(java_1.8_32) version as XSD's are not getting generated.

The Wsimport tool has completed Web service artifact generation.
Review the tool output for details, including errors and warnings.

parsing WSDL...



java.lang.reflect.InvocationTargetException

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:508)
at com.ibm.ws.bootstrap.WSLauncher.main(WSLauncher.java:280)

Caused by: java.lang.AssertionError: org.xml.sax.SAXParseException: Failed to read external schema document "jar:file:/C:/ibm/RAD95/WebSphere85/AppServer/plugins/com.ibm.jaxb.tools.jar!/com/ibm/jtc/jax/tools/xjc/reader/xmlschema/bindinfo/xjc.xsd", because "jar" access is not allowed.

at com.ibm.jtc.jax.tools.xjc.SchemaCache.newValidator(SchemaCache.java:82)
at com.ibm.jtc.jax.tools.xjc.reader.internalizer.SCDBasedBindingSet.apply(SCDBasedBindingSet.java:237)
at com.ibm.jtc.jax.tools.xjc.ModelLoader.createXSOM(ModelLoader.java:541)
at com.ibm.jtc.jax.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:269)
at com.ibm.jtc.jax.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:95)
at com.ibm.jtc.jax.tools.ws.processor.modeler.wsdl.JAXBModelBuilder.bind(JAXBModelBuilder.java:142)
at com.ibm.jtc.jax.tools.ws.processor.modeler.wsdl.WSDLModeler.buildJAXBModel(WSDLModeler.java:2306)
at com.ibm.jtc.jax.tools.ws.processor.modeler.wsdl.WSDLModeler.internalBuildModel(WSDLModeler.java:206)
at com.ibm.jtc.jax.tools.ws.processor.modeler.wsdl.WSDLModeler.buildModel(WSDLModeler.java:149)
at com.ibm.jtc.jax.tools.ws.wscompile.WsimportTool.buildWsdlModel(WsimportTool.java:446)
at com.ibm.jtc.jax.tools.ws.wscompile.WsimportTool.run(WsimportTool.java:207)
at com.ibm.jtc.jax.tools.ws.wscompile.WsimportTool.run(WsimportTool.java:185)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:508)
at com.ibm.jtc.jax.tools.ws.Invoker.invoke(Invoker.java:174)
at com.ibm.jtc.jax.tools.ws.WsImport.main(WsImport.java:57)
at com.ibm.ws.jaxws.tools.WsImport.main(WsImport.java:28)
... 5 more

Caused by: org.xml.sax.SAXParseException: Failed to read external schema document "jar:file:/C:/ibm/RAD95/WebSphere85/AppServer/plugins/com.ibm.jaxb.tools.jar!/com/ibm/jtc/jax/tools/xjc/reader/xmlschema/bindinfo/xjc.xsd", because "jar" access is not allowed.

at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager$2.reportError(Unknown Source)
at com.ibm.xml.jaxp.util.ExternalResourceHelper$ProtocolValidator.validate(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.resolveEntity(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaLoader.resolveDocument(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.resolveSchema(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.constructTrees(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)
at org.apache.xerces.jaxp.validation.XMLSchemaFactory.newSchema(Unknown Source)
at javax.xml.validation.SchemaFactory.newSchema(Unknown Source)
at javax.xml.validation.SchemaFactory.newSchema(Unknown Source)
at com.ibm.jtc.jax.tools.xjc.SchemaCache.newValidator(SchemaCache.java:79)
... 23 more.

I have tried to change the property file jaxp.properties by keeping javax.xml.accessExternalSchema = all , but the issue is not getting resolved.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.