Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2007

Tip: Looking for answers? Try searching our database.

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Priority

Thread view: 
dushkin - 12 Jul 2007 11:06 GMT
Hello,

I built an eclipse project and used its Export tool to create a jar
file.
When I executed the jar, I got the above message.

The project folders structure is as follows:

/base/.settings
/base/config -->holds some xml file
/base/lib/ -->holds 3rd party jars including the log4j
/base/bin --> output folder. Also holds log4j.properties file.
/base/xxx  --> holds the main class source
/base/src/a1/a2/a3/... --> sources
/base/src/b1/b2/b3/... --> sources
/base/src/c1/c2/c3/... --> sources

I wasted already so much time on that!
Any help will be blessed!

Thanks!
Flo 'Irian' Schaetz - 12 Jul 2007 12:14 GMT
And thus spoke dushkin...

>  /base/lib/ -->holds 3rd party jars including the log4j

Did you include that in your manifest?

Flo
dushkin - 12 Jul 2007 12:18 GMT
> And thus spoke dushkin...
>
[quoted text clipped - 3 lines]
>
> Flo

This is the manifest file created automatically by the eclipse export
tool:

Manifest-Version: 1.0
Sealed: true
Main-Class: com.comverse.mep.CdrManagerNG.CdrManagerNG

Didn't think I need to change the auto created file...
And if so - do you think I need to add every jar to the manifest? And
how?
Thanks.
Flo 'Irian' Schaetz - 12 Jul 2007 13:08 GMT
And thus spoke dushkin...

> Didn't think I need to change the auto created file...
> And if so - do you think I need to add every jar to the manifest? And
> how?

I'm no expert, but when I use Ant to build my files and create a .jar
(and .zip it toegether with the libs), I always add the class-path to
the manifest-file, for example:

Class-Path: . ./libs/MyLib.jar

With Ant it's rather simple to do that...

<manifest file="manifest.txt">
    <attribute name="Built-By" value="${user.name}"/>
    <attribute name="Main-Class" value="translator.Translator"/>
    <attribute name="Class-Path" value=". ./libs/MyLib.jar"/>
</manifest>

Then I can use...

<jar destfile="${ant.project.name}.jar" basedir="${bin}"
manifest="manifest.txt"/>

...to create the jar with the correct manifest...

Flo
dushkin - 12 Jul 2007 14:05 GMT
> And thus spoke dushkin...
>
[quoted text clipped - 24 lines]
>
> Flo

Well, I added
Class-Path: ..\libs/lib\log4j-1.2.14.jar
to the manifest file but the result occur.

Any other ideas?
dushkin - 12 Jul 2007 14:07 GMT
> > And thus spoke dushkin...
>
[quoted text clipped - 32 lines]
>
> - Show quoted text -

Well, I added
Class-Path: ..\libs\lib\log4j-1.2.14.jar
to the manifest file but the same result occur.

Any other ideas?
Flo 'Irian' Schaetz - 12 Jul 2007 14:15 GMT
And thus spoke dushkin...

> Well, I added
> Class-Path: ..\libs\lib\log4j-1.2.14.jar
> to the manifest file but the same result occur.

above you write, that it's in /lib/, now you search for it in .
"../libs/lib/"...

MY directory is called "/libs/"... That isn't an integral part of the
line :-) You have to put your own directory there...

In your case, probably...

Class-Path: . /lib/log4j-1.2.14.jar

Or perhaps /base/lib/etc. I'm not sure about your real structure.

Flo
dushkin - 12 Jul 2007 14:33 GMT
> And thus spoke dushkin...
>
[quoted text clipped - 15 lines]
>
> Flo

Hi Flo,
That was a foolish mistake developed from being so tired of seeking
for an answer... :-(

Anyway, it still no good...

Again:
The directories structure inside the jar is as follows:

/com --> contains sub folders with the class files
/config --> contains an xml file
/lib --> contains all the third party jars (including the log4j)
/Meta-inf
.classpath
.project

The manifest is:
---------------------
Manifest-Version: 1.0
Sealed: true
Main-Class: com.comverse.mep.CdrManagerNG.CdrManagerNG
Class-Path: .\lib\log4j-1.2.14.jar
---------------------
I also tried ..\lib and \lib

The classpath is

 <?xml version="1.0" encoding="UTF-8" ?>
- <classpath>
 <classpathentry kind="src" path="src" />
 <classpathentry kind="lib" path="lib/log4j-1.2.14.jar" />
 <classpathentry kind="lib" path="lib/dom4j-1.6.1.jar" />
 <classpathentry kind="lib" path="lib/jaxen-1.1-beta-5.jar" />
 <classpathentry kind="lib" path="lib/sftp.jar" />
 <classpathentry kind="lib" path="lib/classes12.jar" />
 <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER" />
 <classpathentry kind="output" path="bin" />
 </classpath>
Lew - 12 Jul 2007 14:40 GMT
Flo 'Irian' Schaetz wrote:
>>> I'm no expert, but when I use Ant to build my files and create a .jar
>>> (and .zip it toegether with the libs), I always add the class-path to
[quoted text clipped - 10 lines]
>>> manifest="manifest.txt"/>
>>> ...to create the jar with the correct manifest...

> Well, I added
> Class-Path: ..\libs\lib\log4j-1.2.14.jar
> to the manifest file but the same result occur.
>
> Any other ideas?

Notice that Flo's example used forward slashes, not backslashes as yours did.
 Also, you are rooting the log4j JAR's location in the parent directory of
your JAR, not usually safe, unlike Flo's example which used the current directory.

Notice that the log4j JAR must be located in a directory on the network / file
system where your JAR is, because:
> The Class-Path header points to classes or JAR files on the local network, not JAR files within the JAR file or classes accessible over internet protocols.

From
<http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html>
which you should read.

Signature

Lew

Flo 'Irian' Schaetz - 12 Jul 2007 14:44 GMT
And thus spoke Lew...

> Notice that the log4j JAR must be located in a directory on the network / file
> system where your JAR is, because:

Oh, f... yes. I knew I had forgotten something. My libs are in the
directory /libs/, not in the .jar file internal directory /libs/. So my
structure looks like this..

/MyJar.jar
/libs/MyLib1.jar
/libs/MyLib2.jar
etc.

The Manifest inside the MyJar.jar points to /libs/ in the filesystem...
This is why I use Ant .zip the whole thing after making the .jar, so I
bundle the libs and the jar toegether... (Ok, to be honest, I even use
an .exe wrapper, but that's what my boss wants - he forces me to do so :-).

Flo
dushkin - 12 Jul 2007 14:58 GMT
> Flo 'Irian' Schaetz wrote:
> >>> I'm no expert, but when I use Ant to build my files and create a .jar
[quoted text clipped - 34 lines]
>
> - Show quoted text -

Oh!
So, shouldn't (or maybe can't) the jars be placed inside the jar???
because this is how the export tool did by itself!
I would have prefered to ship a jar with all its resources inside...
How this information affects your kind advices Lew and Flo?
Flo 'Irian' Schaetz - 12 Jul 2007 15:06 GMT
And thus spoke dushkin...

> So, shouldn't (or maybe can't) the jars be placed inside the jar???
> because this is how the export tool did by itself!
> I would have prefered to ship a jar with all its resources inside...
> How this information affects your kind advices Lew and Flo?

Read the other posting: It's correct. To include another .jar into your
.jar, you'll probably have to extract the classes from it...

Flo


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.