Hi,
 
See the following link. It might help.
http://www-128.ibm.com/developerworks/java/library/j-onejar/

 
On 1/13/06, Malcolm Sparks <[EMAIL PROTECTED]> wrote:
Raymond,

I fear that this isn't really a dom4j issue itself but a Java one. But saying
this wouldn't help you much, so I'll try to point you in the right direction.

When you say that the dom4j jar is 'missing' from sitemapMigrator.jar, bear in
mind that even if the jar file itself were somehow nested inside
sitemapMigrator.jar, the class loader would ignore it. You would have to include
all the classes of dom4j.jar individually, Java doesn't support nesting of jars
within jars. Ant has a zipfileset with src attribute facility which may help you
include just the dom4j classes, for example:

<zip destfile="sitemapMigrator.jar">
  <fileset dir="sitemapMigrator/classes"/>
  <zipfileset src=""></zip>

Personally, I wouldn't do this because you are merging two sets of classes
together. Sometime in the future you might want to know the version of dom4j you
were using when you did this step, or you might want to use another version of
dom4j, and it would be somewhat more cumbersome to figure things out.

Back to your problem- Alternatively, it might be that dom4j.jar appears in the
JRE installed on the Windows machine, or in the Eclipse classpath, but not in
the JRE on the UNIX machine, and that might explain what you are seeing.

However, I wouldn't recommend relying on the presence of dom4j on your
deployment machine but instead I would suggest you ship dom4j.jar separately,
and include it in the classpath when you run your utility.

For example:

java -classpath lib/sitemapMigrator.jar:lib/dom4j.jar <class name>

If you really want to use the -jar method of launching your utility (and I don't
really see much advantage to doing so on UNIX but anyhow), you should ship both
jars separately and include a Class-Path entry in the MANIFEST.MF file inside
sitemapMigrator.jar that links to dom4j.jar :-

From memory it would look a bit like this:

Manifest-Version: 1.0
Class-Path: dom4j.jar

Hope this helps.

Malcolm


Raymond Sebuwufu wrote:
> Hi,
> I created a jar file using Eclipse running on windows, transferred it to
> a UNIX server and when I try to run it using the following command, I
> get the error after the line below:
>
> /usr/java/jdk5/bin/java -jar sitemapMigrator.jar
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/dom4j/DocumentException
>
> I checked the ANT build script and I know the error is suggesting that
> the jar for dom4j is missing from sitemapMigrator.jar but looking at the
> script I can see that it should be included in the build.
>
> Does anyone know how to resolve this issue or have any idea what could
> be going wrong?
>
> Many thanks for your help in advance
>
> Raymond
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> _______________________________________________
> dom4j-user mailing list
> dom4j-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/dom4j-user






--
Regards,
Saurav

Reply via email to