You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by WebServices Development <We...@csx.com> on 2014/09/15 17:15:51 UTC
Need help with ANT javac classpath
I have an old application which is using JAXB version 1.0. When I pull in the projects in Eclipse, it compiles fine because it references the jaxb jars from my web-inf/lib.
When I am defining an ANT javac task for it, I get compilation errors because the jaxb classes from rt.jar take preference. I have not included the jars from JAVA_HOME in my javac task's classpath.
How can I set-up my javac task such that my project will still compile with ANT as it does in Eclipse?
P.S - I tried adding includejavaruntime="false" and includeantruntime="false" attributes - both together as well as individually - to the javac task - but I still get the error. The error is - createBinder() in ObjectFactory cannot override createBinder() in JAXBContext
Because it seems that when compiling in Eclipse, it uses the JAXBContext from the jaxb-api.jar that is part of the project whereas when running ANT javac, it uses the JAXBContext from rt.jar – which gets added to the classpath when running ANT – not part of my classpath parameter to javac.
What do I need to do to get this fixed?
This email transmission and any accompanying attachments may contain CSX privileged and confidential information intended only for the use of the intended addressee. Any dissemination, distribution, copying or action taken in reliance on the contents of this email by anyone other than the intended recipient is strictly prohibited. If you have received this email in error please immediately delete it and notify sender at the above CSX email address. Sender and CSX accept no liability for any damage caused directly or indirectly by receipt of this email.
RE: Need help with ANT javac classpath
Posted by Martin Gainty <mg...@hotmail.com>.
> From: WebServices_Development@csx.com
> To: user@ant.apache.org
> Subject: RE: Need help with ANT javac classpath
> Date: Tue, 16 Sep 2014 14:19:47 +0000
>
> �I think I may not have articulated my problem correctly
MG>for 6 weeks this summer I was answering all questions in spanish.. I thought the mis-interpretation was mine!
>
> I am using WAS 8.5 JDK 1.7 set-up as general build set-up for my ANT, but for this particular application, it uses separate JAXB1.0 jars on JAXB 1.0 generated classes.
MG>i would not drop application specific jars into endorsed
MG>since this is specific to one application dropping jaxb jars to endorsed would impact all implementations that use the JVM
MG>potentially causing mis-behaviour side-effect by other applications implementing their own JAXB implementation
The web-inf/lib contains jaxb-api.jar, jaxb-impl.jar, jaxb-xjc.jar and jaxb-libs.jar and some other jars used by the application.
MG>WEB-INF/lib is where a servlet container will look for all java jars
MG>WEB-INF/classes is where servlet container will look for java classes
MG>decidedly safest (and the most specific) implementation would be to use java -Djava.endorsed.dirs=
MG>http://documentation.progress.com/output/Iona/orbix/6.1/migrate/migrate_from_51/rebuilding_corba_java11.html
MG>Martin-
----------------------------------------------------------------------------------
At just over 49 miles long Panama Railway is probably the shortest railway in the world
As there was no roads from 1885-1914 Panama Railway carried materials and men to vital locations for the new Panama Canal
http://en.wikipedia.org/wiki/Panama_Canal_Railway
> -----Original Message-----
> From: Martin Gainty [mailto:mgainty@hotmail.com]
> Sent: Monday, September 15, 2014 5:39 PM
> To: Ant Users List
> Subject: RE: Need help with ANT javac classpath
>
>
>
> > From: WebServices_Development@csx.com
> > To: user@ant.apache.org
> > Subject: RE: Need help with ANT javac classpath
> > Date: Mon, 15 Sep 2014 16:06:55 +0000
> >
> > Thanks.
> >
> > This is a common build script that we have, so I didn't add fork for the javac task - as it would affect other builds as well, that use the latest java version and follow the default build.
> >
> > If it is not possible at all to incorporate something in the common build, I will take a look at separating this one out, but want to avoid it, if I can.
> >
> > I had looked at the endorsed directory, but I got the impression that it is to be used when you want to use a later version, not earlier. Is that not true? Also, if I can use it for earlier version, can I use the JAXB jars from the WEB-INF/lib directory for the path for - Djava.endorsed.dirs=/relative-path-to/WEB-INF/lib? Would other jars in that location cause any issues for endorsed directory?
> >
> MG>as stated earlier which JAXB jar is loaded depends on which
> MG>classloader is in use obviously when your container loads servlets
> MG>./WEB-INF/lib should take precendence in CLASSPATH Dominiques link to Glassfish has the best solution:
> MG>https://jaxb.java.net/guide/Migrating_JAXB_2_0_applications_to_JavaSE_6.html#Using_JAXB_2_1_or_JAXB_2_2_with_JavaSE_6
> MG>to resolve correct version of JAXB either:
>
> Place the 2.1/2.2 jaxb-api.jar into $JRE_HOME/lib/endorsed.
> This essentially makes your JRE to "JRE 6 + JAXB 2.x". This won't affect any other applications
> that use this JRE, and it's easy. On the other hand, in various scenarios you may not be able to alter the JRE.
>
> Use the system property java.endorsed.dirs when you launch your application, and have it point to the directory that contains
> the 2.1/2.2 jaxb-api.jar. This allows you use use JAXB 2.1/2.2 without modifying the JRE. Make sure not to include any other JAXB RI jar files
> (such as jsr173-api.jar or jaxb-impl.jar.)
>
> Implement a custom ClassLoader and block delegation to javax.xml.bind package, so that code running inside this class loader will load the JAXB API
> from elsewhere. This is a very advanced approach.
>
> MG>-Djava.endorsed.dirs= has the least side-effects which says for this
> MG>execution only java.endorsed.dirs will take precedence HTH
>
> -----Original Message-----
> > From: Dominique Devienne [mailto:ddevienne@gmail.com]
> > Sent: Monday, September 15, 2014 11:30 AM
> > To: Ant Users List
> > Subject: Re: Need help with ANT javac classpath
> >
> > On Mon, Sep 15, 2014 at 5:15 PM, WebServices Development < WebServices_Development@csx.com> wrote:
> >
> > > P.S - I tried adding includejavaruntime="false" and
> > > includeantruntime="false" attributes - both together as well as
> > > individually - to the javac task - but I still get the error. The
> > > error is - createBinder() in ObjectFactory cannot override
> > > createBinder() in JAXBContext
> > >
> >
> > Did you fork="true" too, for <javac>? That way you can have better control of the environment the JDK javac (implemented in Java) runs with, separate the from environment Ant itself runs in.
> >
> > Also look into
> > http://docs.oracle.com/javase/6/docs/technotes/guides/standards/
> >
> > A quick Google also turned up
> > http://stackoverflow.com/questions/16215409/is-it-possible-to-replace-
> > the-version-of-the-jaxb-implementation-in-java-jre-1-6
> >
> > --DD
> >
>
>
>
> This email transmission and any accompanying attachments may contain CSX privileged and confidential information intended only for the use of the intended addressee. Any dissemination, distribution, copying or action taken in reliance on the contents of this email by anyone other than the intended recipient is strictly prohibited. If you have received this email in error please immediately delete it and notify sender at the above CSX email address. Sender and CSX accept no liability for any damage caused directly or indirectly by receipt of this email.
> �Т���������������������������������������������������������������������ХF�V�7V'67&�&R�R���âW6W"�V�7V'67&�&T�B�6�R��&pФf�"FF�F����6����G2�R���âW6W"ֆV��B�6�R��&p
RE: Need help with ANT javac classpath
Posted by WebServices Development <We...@csx.com>.
I think I may not have articulated my problem correctly.
I am using WAS 8.5 JDK 1.7 set-up as general build set-up for my ANT, but for this particular application, it uses separate JAXB1.0 jars on JAXB 1.0 generated classes. It includes 4 jaxb jars in the web-inf/lib - so I basically need to go back to 1.0 version in my javac step for the application.
So, if I use the endorsed jvm property for a backward version, will it work and do I have copy just the jaxb-api.jar to that directory? The web-inf/lib contains jaxb-api.jar, jaxb-impl.jar, jaxb-xjc.jar and jaxb-libs.jar and some other jars used by the application.
-----Original Message-----
From: Martin Gainty [mailto:mgainty@hotmail.com]
Sent: Monday, September 15, 2014 5:39 PM
To: Ant Users List
Subject: RE: Need help with ANT javac classpath
> From: WebServices_Development@csx.com
> To: user@ant.apache.org
> Subject: RE: Need help with ANT javac classpath
> Date: Mon, 15 Sep 2014 16:06:55 +0000
>
> Thanks.
>
> This is a common build script that we have, so I didn't add fork for the javac task - as it would affect other builds as well, that use the latest java version and follow the default build.
>
> If it is not possible at all to incorporate something in the common build, I will take a look at separating this one out, but want to avoid it, if I can.
>
> I had looked at the endorsed directory, but I got the impression that it is to be used when you want to use a later version, not earlier. Is that not true? Also, if I can use it for earlier version, can I use the JAXB jars from the WEB-INF/lib directory for the path for - Djava.endorsed.dirs=/relative-path-to/WEB-INF/lib? Would other jars in that location cause any issues for endorsed directory?
>
MG>as stated earlier which JAXB jar is loaded depends on which
MG>classloader is in use obviously when your container loads servlets
MG>./WEB-INF/lib should take precendence in CLASSPATH Dominiques link to Glassfish has the best solution:
MG>https://jaxb.java.net/guide/Migrating_JAXB_2_0_applications_to_JavaSE_6.html#Using_JAXB_2_1_or_JAXB_2_2_with_JavaSE_6
MG>to resolve correct version of JAXB either:
Place the 2.1/2.2 jaxb-api.jar into $JRE_HOME/lib/endorsed.
This essentially makes your JRE to "JRE 6 + JAXB 2.x". This won't affect any other applications
that use this JRE, and it's easy. On the other hand, in various scenarios you may not be able to alter the JRE.
Use the system property java.endorsed.dirs when you launch your application, and have it point to the directory that contains
the 2.1/2.2 jaxb-api.jar. This allows you use use JAXB 2.1/2.2 without modifying the JRE. Make sure not to include any other JAXB RI jar files
(such as jsr173-api.jar or jaxb-impl.jar.)
Implement a custom ClassLoader and block delegation to javax.xml.bind package, so that code running inside this class loader will load the JAXB API
from elsewhere. This is a very advanced approach.
MG>-Djava.endorsed.dirs= has the least side-effects which says for this
MG>execution only java.endorsed.dirs will take precedence HTH
-----Original Message-----
> From: Dominique Devienne [mailto:ddevienne@gmail.com]
> Sent: Monday, September 15, 2014 11:30 AM
> To: Ant Users List
> Subject: Re: Need help with ANT javac classpath
>
> On Mon, Sep 15, 2014 at 5:15 PM, WebServices Development < WebServices_Development@csx.com> wrote:
>
> > P.S - I tried adding includejavaruntime="false" and
> > includeantruntime="false" attributes - both together as well as
> > individually - to the javac task - but I still get the error. The
> > error is - createBinder() in ObjectFactory cannot override
> > createBinder() in JAXBContext
> >
>
> Did you fork="true" too, for <javac>? That way you can have better control of the environment the JDK javac (implemented in Java) runs with, separate the from environment Ant itself runs in.
>
> Also look into
> http://docs.oracle.com/javase/6/docs/technotes/guides/standards/
>
> A quick Google also turned up
> http://stackoverflow.com/questions/16215409/is-it-possible-to-replace-
> the-version-of-the-jaxb-implementation-in-java-jre-1-6
>
> --DD
>
This email transmission and any accompanying attachments may contain CSX privileged and confidential information intended only for the use of the intended addressee. Any dissemination, distribution, copying or action taken in reliance on the contents of this email by anyone other than the intended recipient is strictly prohibited. If you have received this email in error please immediately delete it and notify sender at the above CSX email address. Sender and CSX accept no liability for any damage caused directly or indirectly by receipt of this email.
RE: Need help with ANT javac classpath
Posted by Martin Gainty <mg...@hotmail.com>.
> From: WebServices_Development@csx.com
> To: user@ant.apache.org
> Subject: RE: Need help with ANT javac classpath
> Date: Mon, 15 Sep 2014 16:06:55 +0000
>
> Thanks.
>
> This is a common build script that we have, so I didn't add fork for the javac task - as it would affect other builds as well, that use the latest java version and follow the default build.
>
> If it is not possible at all to incorporate something in the common build, I will take a look at separating this one out, but want to avoid it, if I can.
>
> I had looked at the endorsed directory, but I got the impression that it is to be used when you want to use a later version, not earlier. Is that not true? Also, if I can use it for earlier version, can I use the JAXB jars from the WEB-INF/lib directory for the path for - Djava.endorsed.dirs=/relative-path-to/WEB-INF/lib? Would other jars in that location cause any issues for endorsed directory?
>
MG>as stated earlier which JAXB jar is loaded depends on which classloader is in use
MG>obviously when your container loads servlets ./WEB-INF/lib should take precendence in CLASSPATH
MG>Dominiques link to Glassfish has the best solution:
MG>https://jaxb.java.net/guide
/Migrating_JAXB_2_0_applications_to_JavaSE_6.html#Using_JAXB_2_1_or_JAXB_2_2_with_JavaSE_6
MG>to resolve correct version of JAXB either:
Place the 2.1/2.2 jaxb-api.jar into $JRE_HOME/lib/endorsed.
This essentially makes your JRE to "JRE 6 + JAXB 2.x". This won't
affect any other applications
that use this JRE, and it's
easy. On the other hand, in various scenarios you may not be able to
alter the JRE.
Use the system property java.endorsed.dirs when you launch your application, and have it point to the directory that contains
the 2.1/2.2 jaxb-api.jar. This allows you use use JAXB 2.1/2.2 without modifying the JRE. Make sure not to include any other JAXB RI jar files
(such as jsr173-api.jar or jaxb-impl.jar.)
Implement a custom ClassLoader and block delegation to javax.xml.bind package, so that code running inside this class loader will load the JAXB API
from elsewhere. This is a very advanced approach.
MG>-Djava.endorsed.dirs= has the least side-effects which says for this execution only java.endorsed.dirs will take precedence
MG>HTH
-----Original Message-----
> From: Dominique Devienne [mailto:ddevienne@gmail.com]
> Sent: Monday, September 15, 2014 11:30 AM
> To: Ant Users List
> Subject: Re: Need help with ANT javac classpath
>
> On Mon, Sep 15, 2014 at 5:15 PM, WebServices Development < WebServices_Development@csx.com> wrote:
>
> > P.S - I tried adding includejavaruntime="false" and
> > includeantruntime="false" attributes - both together as well as
> > individually - to the javac task - but I still get the error. The
> > error is - createBinder() in ObjectFactory cannot override
> > createBinder() in JAXBContext
> >
>
> Did you fork="true" too, for <javac>? That way you can have better control of the environment the JDK javac (implemented in Java) runs with, separate the from environment Ant itself runs in.
>
> Also look into
> http://docs.oracle.com/javase/6/docs/technotes/guides/standards/
>
> A quick Google also turned up
> http://stackoverflow.com/questions/16215409/is-it-possible-to-replace-the-version-of-the-jaxb-implementation-in-java-jre-1-6
>
> --DD
>
>
> This email transmission and any accompanying attachments may contain CSX privileged and confidential information intended only for the use of the intended addressee. Any dissemination, distribution, copying or action taken in reliance on the contents of this email by anyone other than the intended recipient is strictly prohibited. If you have received this email in error please immediately delete it and notify sender at the above CSX email address. Sender and CSX accept no liability for any damage caused directly or indirectly by receipt of this email.
> B�KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKCB��[��X��ܚX�KK[XZ[�\�\�][��X��ܚX�P[� �\X�K�ܙ�B��܈Y][ۘ[��[X[��K[XZ[�\�\�Z[[� �\X�K�ܙ�B
RE: Need help with ANT javac classpath
Posted by WebServices Development <We...@csx.com>.
Thanks.
This is a common build script that we have, so I didn't add fork for the javac task - as it would affect other builds as well, that use the latest java version and follow the default build.
If it is not possible at all to incorporate something in the common build, I will take a look at separating this one out, but want to avoid it, if I can.
I had looked at the endorsed directory, but I got the impression that it is to be used when you want to use a later version, not earlier. Is that not true? Also, if I can use it for earlier version, can I use the JAXB jars from the WEB-INF/lib directory for the path for - Djava.endorsed.dirs=/relative-path-to/WEB-INF/lib? Would other jars in that location cause any issues for endorsed directory?
-----Original Message-----
From: Dominique Devienne [mailto:ddevienne@gmail.com]
Sent: Monday, September 15, 2014 11:30 AM
To: Ant Users List
Subject: Re: Need help with ANT javac classpath
On Mon, Sep 15, 2014 at 5:15 PM, WebServices Development < WebServices_Development@csx.com> wrote:
> P.S - I tried adding includejavaruntime="false" and
> includeantruntime="false" attributes - both together as well as
> individually - to the javac task - but I still get the error. The
> error is - createBinder() in ObjectFactory cannot override
> createBinder() in JAXBContext
>
Did you fork="true" too, for <javac>? That way you can have better control of the environment the JDK javac (implemented in Java) runs with, separate the from environment Ant itself runs in.
Also look into
http://docs.oracle.com/javase/6/docs/technotes/guides/standards/
A quick Google also turned up
http://stackoverflow.com/questions/16215409/is-it-possible-to-replace-the-version-of-the-jaxb-implementation-in-java-jre-1-6
--DD
This email transmission and any accompanying attachments may contain CSX privileged and confidential information intended only for the use of the intended addressee. Any dissemination, distribution, copying or action taken in reliance on the contents of this email by anyone other than the intended recipient is strictly prohibited. If you have received this email in error please immediately delete it and notify sender at the above CSX email address. Sender and CSX accept no liability for any damage caused directly or indirectly by receipt of this email.
Re: Need help with ANT javac classpath
Posted by Dominique Devienne <dd...@gmail.com>.
On Mon, Sep 15, 2014 at 5:15 PM, WebServices Development <
WebServices_Development@csx.com> wrote:
> P.S - I tried adding includejavaruntime="false" and
> includeantruntime="false" attributes - both together as well as
> individually - to the javac task - but I still get the error. The error
> is - createBinder() in ObjectFactory cannot override createBinder() in
> JAXBContext
>
Did you fork="true" too, for <javac>? That way you can have better control
of the environment the JDK javac (implemented in Java) runs with, separate
the from environment Ant itself runs in.
Also look into
http://docs.oracle.com/javase/6/docs/technotes/guides/standards/
A quick Google also turned up
http://stackoverflow.com/questions/16215409/is-it-possible-to-replace-the-version-of-the-jaxb-implementation-in-java-jre-1-6
--DD