LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-09-2006, 03:12 PM   #1
robbbert
Member
 
Registered: Oct 2005
Location: Hannover, Germany
Distribution: Let there be Ubuntu... :o)
Posts: 573

Rep: Reputation: 32
java.lang.NoClassDefFoundError


Hi, I'm trying to get JBoss Hibernate running, on Eclipse 3.1, on Ubuntu 6.06.
This is a detailed (and lengthy) problem description - it's very important to me to solve this.
Thank you indeed for your time and efforts. I need to resolve this, at any rate. Thanks again.

This is the Java code I'm trying to execute:
Code:
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class Test
{
	public static void main(String[] args)
	{
		SessionFactory sessionFactory = new Configuration().configure("hibernate.cfg.xml").buildSessionFactory();
	}
}
When running that code, I'm getting the error:
Quote:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:116)
at hibernate.generatedcode.postgres.world.Test.main(Test.java:11)
So where could (which??) Java (there are several versions installed, but only one should be active - see below) search for that JAR? -

1. By default, Java on Ubuntu is started via "/usr/bin/java", which is a link that points to "/usr/lib/j2sdk1.5-sun/bin/java", in my case, and that's allright.
"/usr/lib/j2sdk1.5-sun/lib" does contain the JAR file in question, "commons-logging-1.1.jar".

2. Anyways, - to make sure to match a working Java Virtual Machine, I'm now starting Eclipse using a custom command: "/usr/lib/j2sdk1.5-sun/bin/java -Xms40m -Xmx256m -jar /media/hde1/home/robert/eclipse-3.1.2-wtp/startup.jar -os linux -ws gtk -arch x86 -launcher /media/hde1/home/robert/eclipse-3.1.2-wtp/eclipse -name Eclipse -showsplash 600 -exitdata 460011 -vm /usr/lib/j2sdk1.5-sun/bin/java -vmargs -Xms40m -Xmx256m -jar /media/hde1/home/robert/eclipse-3.1.2-wtp/startup.jar".

Again, "/usr/lib/j2sdk1.5-sun/lib" does contain the JAR file in question, "commons-logging-1.1.jar".

3. In the project's "Java Build Path", I've added (a) "/usr/lib/j2sdk1.5-sun/lib/hibernate3.jar" (otherwise, the project wouldn't compile), and (b) "/usr/lib/j2sdk1.5-sun/lib/commons-logging-1.1.jar" (containing the class that could not be found).
I've also made sure both libraries are checked to be exported.

4. In the project's "Java Build Path", I've also added a reference to the variable "JRE_LIB", which points to "/usr/lib/j2sdk1.5-sun/jre/lib/rt.jar". That package that cannot be found, "commons-logging-1.1.jar", does exist in "/usr/lib/j2sdk1.5-sun/jre/lib/ext".

5. On my Ubuntu system, there's also some dubious folder named "/usr/share/java". There, mostly links exist, but additionally, some actual JAR files. I've added the JAR file in question, "commons-logging-1.1.jar", to it.

6. Java (in case some application would still ask "the system" for where to find Java) should be configured allright:
Quote:
robert@ubuntu:/$ sudo update-alternatives --config java
Password:

There are 6 alternatives which provide `java'.

Selection Alternative
-----------------------------------------------
1 /etc/alternatives/kaffe-system/bin/java
* 2 /usr/lib/j2sdk1.5-sun/bin/java
3 /usr/bin/gij-wrapper-4.1
4 /usr/lib/jvm/java-gcj/jre/bin/java
+ 5 /usr/lib/j2se/1.4/bin/java
6 /usr/lib/j2sdk1.5-sun/jre/bin/java
7. I don't understand what the + sign means in the above quote, anyways, I'd also placed the offending JAR into "/usr/lib/j2se/1.4/lib/ext".

8. At some point of time, I'd also set the CLASSPATH property accordingly, pointing to "/usr/lib/j2sdk1.5-sun/jre/lib/ext", where "commons-logging-1.1.jar" resides. - No luck.

9. I've searched the web for similar issues, but anything doesn't seem to help for me.
Also, I haven't had such problems when using Eclipse on Windows (using other libraries), extensively.

------------------------
Still no luck!
I've spent a d*mned complete day on just trying to resolve that simple issue! And it's not going to stop! F*ck!!
------------------------

- Would anyone please be so nice to get me out of here? You see, I've tried alot, and I really need some assistance to get me productive again.

Sincerely
robbbert
 
Old 07-10-2006, 02:05 PM   #2
robbbert
Member
 
Registered: Oct 2005
Location: Hannover, Germany
Distribution: Let there be Ubuntu... :o)
Posts: 573

Original Poster
Rep: Reputation: 32
Another case:

I've added the Apache Axis default web app to Tomcat. - When I point the browser to that URL, the following error gets thrown:
Quote:
root cause

Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK
org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.ja va:105)
However, $JAVA_HOME is set perfectly right:
Quote:
robert@ubuntu:~$ echo $JAVA_HOME
/usr/lib/j2sdk1.5-sun
 
Old 07-10-2006, 03:16 PM   #3
alred
Member
 
Registered: Mar 2005
Location: singapore
Distribution: puppy and Ubuntu and ... erh ... redhat(sort of) :( ... + the venerable bsd and solaris ^_^
Posts: 658
Blog Entries: 8

Rep: Reputation: 31
your posting are quite long and left alone stuffs like apache and tomcat but no harm checking your javac , jar and javah and such executables in your usual */bin directories ...


//i'm not sure whether this can help you ...

.
 
Old 07-10-2006, 04:02 PM   #4
robbbert
Member
 
Registered: Oct 2005
Location: Hannover, Germany
Distribution: Let there be Ubuntu... :o)
Posts: 573

Original Poster
Rep: Reputation: 32
Quote:
but no harm checking your javac , jar and javah and such executables in your usual */bin directories
You mean I should check whether those files exist? - Of course they do! - Even $CLASSPATH and $JAVA_HOME are set correctly (and contain the offending JAR files) whenever I get those issues and check the paths!

Last edited by robbbert; 07-10-2006 at 04:03 PM.
 
Old 07-10-2006, 04:16 PM   #5
alred
Member
 
Registered: Mar 2005
Location: singapore
Distribution: puppy and Ubuntu and ... erh ... redhat(sort of) :( ... + the venerable bsd and solaris ^_^
Posts: 658
Blog Entries: 8

Rep: Reputation: 31
no files are as offending as how you mentioned i guess ...

can try something like /usr/bin/jar -V and for the rest of */bin/javac and such too ... probably they belong to gnu softwares ...

but if you have already got these right in the first place then the problems might lie somewhere else which i wouldnt know ...


//sorry , cant help you much ...


.
 
Old 07-14-2006, 03:39 PM   #6
robbbert
Member
 
Registered: Oct 2005
Location: Hannover, Germany
Distribution: Let there be Ubuntu... :o)
Posts: 573

Original Poster
Rep: Reputation: 32
Quote:
can try something like /usr/bin/jar -V and for the rest of */bin/javac and such too ... probably they belong to gnu softwares ...
That's right: These are symbolic links, (in my case) pointing to various Java virtual machines. I've cleaned that up to use the Sun 1.5 JDK (keyword: "configure-alternatives"), and now, at least Axis within Tomcat is working.

BTW, I really dislike how Ubuntu (my favorite Linux distribution) handles Java. When you install Sun Java (by Ubuntus repositories...), there shouldn't remain symbolic links to Kaffe Java, IBM Java, "some" Java, etc.

When you state, "java", "javah", "javac", "jar", etc., any of these programs should point to the same Java version.

Thanks
 
Old 07-16-2006, 06:47 AM   #7
robbbert
Member
 
Registered: Oct 2005
Location: Hannover, Germany
Distribution: Let there be Ubuntu... :o)
Posts: 573

Original Poster
Rep: Reputation: 32
Compiling JSPs with Tomcat works now. For almost two days I'd tried anything until finally I switched from that Tomcat version that came bundled with NetBeans to an original one.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java: java.lang.NoClassDefFoundError: javaapplication8/Factorial chief_officer Programming 9 05-31-2006 03:28 PM
java exception: java.lang.NoClassDefFoundError kath Programming 12 05-11-2006 04:37 AM
java.lang.NoclassDefFoundError rlnd Programming 5 02-18-2006 04:54 AM
Exception in thread "main" java.lang.NoClassDefFoundError: Lobais Linux - Software 19 06-23-2004 08:42 AM
Exception in thread "main" java.lang.NoClassDefFoundError: melinda_sayang Programming 2 04-27-2004 11:49 AM


All times are GMT -5. The time now is 04:21 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration