NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
ats37
Joined: 24 Oct 2008 Posts: 3
|
Posted: Sat Nov 15, 2008 9:56 am Post subject: jars in ear file |
|
|
Hi,
For a long time now I've customised Netbeans' build scripts; patching
the test classpath to include the J2EE classes, integrating EMMA code
coverage into the test runs, overriding the javadoc definition so it
works when building with a 1.3 JDK, etc. But last week I finally
realised why there's all that stuff in the Web project's build
referring to ear properties/targets - when building a J2EE Application
project, that build script sets those same properties and then calls
the usual Web project's script (which, since Ant properties are fixed
once set, then uses the EAR script's values instead of it's own). Now
it makes sense :-)
Unfortunately, I only realised this was what it was doing because it
of a problem it was causing me with the application I was working on
:-(
My web application includes a library that uses a similar mechanism to
the JDK's Services API to locate a configuration file on the
classpath, in META-INF/services. The library includes such a file,
set for a default implementation. I have my own version in the web
project's java sources, which is copied to
WEB-INF/classes/META-INF/services during the build, specifying my own
implementation class. Running the web project, this works fine. But
when I added it to an Application project and ran that, it wasn't
calling my class.
Eventually I figured out this was because the ear file included
another copy of all the web app's jars, in addition to the ones in
WEB-INF/lib in the war file, and Websphere's default classloader
search order means the configuration from this jar is being picked up
instead of the one from WEB-INF/classes that I was expecting...
Now, I could change this behaviour in Websphere's settings, so the web
module finds its own copy first, but that's a pain as I'd have to
change it each time I redeploy. Besides, my other web module doesn't
use most of the jars this one does, so there's really no benefit to
having a shared copy in the ear file anyway. So what's the best way
to set up the project(s) so that the jar don't get copied into the ear
but still allow the web project to run on its own? I don't see any
property for "copy module's libraries" in the application's project
properties, but clearing the "Package" checkbox in the web module's
libraries settings stops it being copied to WEB-INF/lib and leads to
ClassNotFound errors when run outside of the application.
The only workarounds I've found so far are to either place the jars in
web/WEB-INF/lib in the first place, or to add duplicate entries on the
Packaging settings for all the jars with /WEB-INF/lib as the "Path in
WAR" (with Package unticked on the Libraries tab in either case). Are
there any other (better?) ways people can think of? Overriding the
copy target in build.xml, maybe?
Andy.
--
http://pseudoq.sourceforge.net/ Open source java Sudoku application |
|
| Back to top |
|
 |
Andy Stevens Posted via mailing list.
|
Posted: Tue Nov 25, 2008 12:24 am Post subject: jars in ear file |
|
|
Reposted, as anything I send From the previous address doesn't appear
to make it through spam filters :-(
Hi,
For a long time now I've customised Netbeans' build scripts; patching
the test classpath to include the J2EE classes, integrating EMMA code
coverage into the test runs, overriding the javadoc definition so it
works when building with a 1.3 JDK, etc. But last week I finally
realised why there's all that stuff in the Web project's build
referring to ear properties/targets - when building a J2EE Application
project, that build script sets those same properties and then calls
the usual Web project's script (which, since Ant properties are fixed
once set, then uses the EAR script's values instead of it's own). Now
it makes sense :-)
Unfortunately, I only realised this was what it was doing because it
of a problem it was causing me with the application I was working on
:-(
My web application includes a library that uses a similar mechanism to
the JDK's Services API to locate a configuration file on the
classpath, in META-INF/services. The library includes such a file,
set for a default implementation. I have my own version in the web
project's java sources, which is copied to
WEB-INF/classes/META-INF/services during the build, specifying my own
implementation class. Running the web project, this works fine. But
when I added it to an Application project and ran that, it wasn't
calling my class.
Eventually I figured out this was because the ear file included
another copy of all the web app's jars, in addition to the ones in
WEB-INF/lib in the war file, and Websphere's default classloader
search order means the configuration from this jar is being picked up
instead of the one from WEB-INF/classes that I was expecting...
Now, I could change this behaviour in Websphere's settings, so the web
module finds its own copy first, but that's a pain as I'd have to
change it each time I redeploy. Besides, my other web module doesn't
use most of the jars this one does, so there's really no benefit to
having a shared copy in the ear file anyway. So what's the best way
to set up the project(s) so that the jar don't get copied into the ear
but still allow the web project to run on its own? I don't see any
property for "copy module's libraries" in the application's project
properties, but clearing the "Package" checkbox in the web module's
libraries settings stops it being copied to WEB-INF/lib and leads to
ClassNotFound errors when run outside of the application.
The only workarounds I've found so far are to either place the jars in
web/WEB-INF/lib in the first place, or to add duplicate entries on the
Packaging settings for all the jars with /WEB-INF/lib as the "Path in
WAR" (with Package unticked on the Libraries tab in either case). Are
there any other (better?) ways people can think of? Overriding the
copy target in build.xml, maybe?
Andy.
--
http://pseudoq.sourceforge.net/ Open source java Sudoku application |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|