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 / December 2007

Tip: Looking for answers? Try searching our database.

NoClassDefFoundError

Thread view: 
H.L - 01 Dec 2007 15:53 GMT
I have developed a program with Netbeans for Linux. It accesses a MySQL
database. This is done via the com.mysql.jdbc Driver jar file. It works
fine when I run the program on its own, but when I try to do it through
Java web start, I get a NoClassdefFoundError. Do you know why this can
be? The application can be accessed at
http://cafka.econ.au.dk/LMDG_Doc/launchm.jnlp. We run the Tomcat server
on
Linux.

Regards.
Andrew Thompson - 01 Dec 2007 16:21 GMT
...
>http://cafka.econ.au.dk/LMDG_Doc/launchm.jnlp.

That JNLP is invalid - the resources element should appear
before the application-desc).  Here is a valid (and slighly
optimized) version of it.

<?xml version="1.0" encoding="utf-8"?>
<jnlp
 spec="1.0+"
  codebase="http://cafka.econ.au.dk/LMDG_Doc/">
 <information>
   <title>Cafkadoc Java Application</title>
   <vendor>CLS</vendor>
   <description>
   Cafka documentation application
   </description>
   <description kind="short">
     Application for documentation about the
     DLS projects
   </description>
   <offline-allowed/>
 </information>
 <security>
     <all-permissions/>
 </security>
<resources>
   <j2se version="1.5+"/>
   <jar href="Mailman.jar"/>
 </resources>
<application-desc />
</jnlp>

Signature

Andrew Thompson
http://www.physci.org/

H.L - 01 Dec 2007 16:34 GMT
> ..
> >http://cafka.econ.au.dk/LMDG_Doc/launchm.jnlp.
[quoted text clipped - 34 lines]
>
> Message posted via http://www.javakb.com

I exchanged it for yours, but I still get the same error.
Andrew Thompson - 01 Dec 2007 16:40 GMT
>> ..
>> >http://cafka.econ.au.dk/LMDG_Doc/launchm.jnlp.
...
> I exchanged it for yours, but I still get the same error.

Did you try flushing the cache (or testing the app. against
a new cache - by changing the cache location)?

Signature

Andrew Thompson
http://www.physci.org/

H.L - 01 Dec 2007 17:15 GMT
> >> ..
> >> >http://cafka.econ.au.dk/LMDG_Doc/launchm.jnlp.
[quoted text clipped - 5 lines]
>
> --

How would I do that? I simply have not done that thing. Thank you for
helping me.
Andrew Thompson - 01 Dec 2007 18:29 GMT
>> >> ..
>> >> >http://cafka.econ.au.dk/LMDG_Doc/launchm.jnlp.

>> Did you try flushing the cache (or testing the app. against
>> a new cache - by changing the cache location)?

> How would I do that? ...

I describe it on the end of this thread.
<http://forum.java.sun.com/thread.jspa?threadID=5209499>

Signature

Andrew Thompson
http://www.physci.org/

Andrew Thompson - 01 Dec 2007 18:38 GMT
>...
>>http://cafka.econ.au.dk/LMDG_Doc/launchm.jnlp.
>> com.mysql.jdbc .. NoClassdefFoundError
>
>That JNLP is invalid - the resources element should ..

..also include..

> <resources>
>    <j2se version="1.5+"/>
>    <jar href="Mailman.jar"/>
>  </resources>
> <application-desc />
></jnlp>

..a reference to the Jar that contains the com.mysql.jdbc.*
classes, and (checks) Mailman.jar (the only archive
referenced in that resources element) surely does *not*
contain them!

That would be another problem, and probably the
underlying cause of the NDFE.

Signature

Andrew Thompson
http://www.physci.org/

Andrew Thompson - 01 Dec 2007 18:40 GMT
>>...
>>>http://cafka.econ.au.dk/LMDG_Doc/launchm.jnlp.
>>> com.mysql.jdbc .. NoClassdefFoundError
...
>That would be another problem, and probably the
>underlying cause of the NDFE.

ummm.. By 'NDFE', I meant the 'NoClassdefFoundError'.

Signature

Andrew Thompson
http://www.physci.org/

H.L - 01 Dec 2007 20:55 GMT
> >>...
> >>>http://cafka.econ.au.dk/LMDG_Doc/launchm.jnlp.
[quoted text clipped - 10 lines]
>
> Message posted via http://www.javakb.com

Thanks once more. If you go there, you will see that I have done almost
exactly as you indicate in another discussion at
http://forum.java.sun.com/thread.jspa?threadID=5240706&tstart=0. I can't
follow your tip on cache flush. I use Tomcat on Linux. You stated the
Windows case.
Andrew Thompson - 02 Dec 2007 05:23 GMT
>> >>...
>> >>>http://cafka.econ.au.dk/LMDG_Doc/launchm.jnlp.
...
> Thanks once more. If you go there, ..

Sorry - where exactly?  (Are you referring the the URL to the
JNLP file, the other thread at the Sun forums.. somewhere else?

>..you will see that I have done almost
>exactly as you indicate in another discussion at
>http://forum.java.sun.com/thread.jspa?threadID=5240706&tstart=0. I can't
>follow your tip on cache flush. I use Tomcat on Linux. You stated the
>Windows case.

Ummm.. OK.  Are you saying that there is *no* *Java* *Control* *Panel*
on this *Linux* box?  Despite that this page* has screenshots of the
JCP on Win., I think it implies the JCP is available (in some form)
for all Java installations.

*
<http://java.sun.com/j2se/1.5.0/docs/guide/deployment/deployment-guide/jcp.html

Signature

Andrew Thompson
http://www.physci.org/

David Golden - 02 Dec 2007 06:15 GMT
> Ummm.. OK.  Are you saying that there is *no* *Java* *Control* *Panel*
> on this *Linux* box?  Despite that this page* has screenshots of the
> JCP on Win., I think it implies the JCP is available (in some form)
> for all Java installations.

There typically is a java control panel included in the linux sun jre:
"jcontrol", in the jre's /bin directory.  (Also called "ControlPanel",
but that was a poor name choice on a unix/linux box.  Not sure,
but I think some/older jres may only have had the "ControlPanel" name.
Either way, it's the same tool, just "jcontrol" is a better name)

If you want to use the linux java control panel on a GUI-less server,
path of least pain is probably to just "ssh -X" (i.e. forward the X11
connection) into the server from a linux (or other X11) desktop with a
GUI.
Lionel van den Berg - 01 Dec 2007 22:37 GMT
> I have developed a program with Netbeans for Linux. It accesses a MySQL
> database. This is done via the com.mysql.jdbc Driver jar file. It works
[quoted text clipped - 4 lines]
> on
> Linux.

I saw the JNLP posted by Andrew Thompson. The answer is simple, you need
to add the mysql driver jar file to the jnlp under the resources section
and also have the jar file on the server.

For example, I keep my jars in the relative directory lib/ and include
the following line in my jnlp (you might have a different driver name so
substitute yours):

<jar href="lib/mysql-connector-java-5.0.3-bin.jar" download="lazy"/>

Cheers

Lionel.
Roedy Green - 02 Dec 2007 04:23 GMT
>NoClassdefFoundError

see
http://mindprod.com/jgloss/runerrormessages.html#NOCLASSDEFFOUNDERROR

This is the hardest exception to track down. It has many many possible
causes.  I wish Sun could figure out some way to break it down into
subexceptions.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Lionel van den Berg - 02 Dec 2007 06:44 GMT
>> NoClassdefFoundError
>
[quoted text clipped - 4 lines]
> causes.  I wish Sun could figure out some way to break it down into
> subexceptions.

But a rather obvious starting point in this case is to include the
driver file which contains the classes that the OP is actually trying to
load dynamically!
Andrew Thompson - 02 Dec 2007 08:27 GMT
>>> NoClassdefFoundError
...
>> causes.  I wish Sun could figure out some way to break it down into
>> subexceptions.
>
>But a rather obvious starting point in this case is to include the
>driver file which contains the classes that the OP is actually trying to
>load dynamically!

Sure.  But two people have now identified that aspect (not that
Roedy would necessarily have noticed) and Roedy tends to take
the 'high overview' and replies with 'a wealth of information to cover
the possibilities' that is encapsulated in the page at the end
of the link provided.  

Added to that, it is a hint to the OP that most compile/run-time
errors can be explored/investigated at the mindpord site.  So
the *next* time the OP sees a NoClassdefFoundError, or an
AccessControlException, or an.. (etc) they know a good
place to start, in investigating it.

Signature

Andrew Thompson
http://www.physci.org/

Roedy Green - 02 Dec 2007 13:44 GMT
>Added to that, it is a hint to the OP that most compile/run-time
>errors can be explored/investigated at the mindpord site.  So
>the *next* time the OP sees a NoClassdefFoundError, or an
>AccessControlException, or an.. (etc) they know a good
>place to start, in investigating it.

As Andrew usually puts it "this is not a help desk".

In my view you generally should NOT hand the solution on a plate.  You
should give general information useful to solve that class of
problems.  In the process of applying those hints, the questioner
becomes a better programmer.

There is a matter of balance.  If you give too general a hint, the
student becomes discouraged and gets the idea he/she is hopeless.  If
you give too specific a hint, they don't learn anything.  Just right,
and the student gets a great rush of accomplishment, (which reinforces
learning), and learns the most about that class of problem.

If the questioner is an accomplished Java programmer, simply handing
over the answer is appropriate.  They have probably already tried the
usual mechanisms and for some reason went off on some wrong tangent in
understanding.

The other way I look at this is, the questioner is NOT the primary
intended audience. It is all the other students.  The other students
are not interested in the minutiae of the problem.  They want to learn
something they can apply to THEIR problems.  So you should try to give
advice that is generally applicable.

What I am often doing when I come in late to the conversation is
pointing out the student could have handled this on his own simply by
looking up a few keywords in the Java glossary.  Then there is no
delay waiting for an answer that may never come, or may come with a
large dose of invective.

Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Andrew Thompson - 02 Dec 2007 14:03 GMT
>>Added to that, it is a hint to the OP that most compile/run-time
>>errors can be explored/investigated at the mindpord site.  So
>>the *next* time the OP sees a NoClassdefFoundError, or an
>>AccessControlException, or an.. (etc) they know a good
>>place to start, in investigating it.
...
>There is a matter of balance.  ...

Thank you for that quote.  It is ..nice to hear you express
something that sounds surprising* (to me).

* Your goodwill and good intention is not a question (worthy
of the slightest thought).

Signature

Andrew Thompson
http://www.physci.org/

Andrew Thompson - 02 Dec 2007 14:36 GMT
...
>The other way I look at this is, the questioner is NOT the primary
>intended audience. It is all the other students.  The other students
>are not interested in the minutiae of the problem.  They want to learn
>something they can apply to THEIR problems.  So you should try to give
>advice that is generally applicable.

F'cken Yay.  (sorry - did not mean to interrupt this sound
exposition, but I was ..'possessed by a great spirit' (shrugs
vaguely - that'll do)).

>What I am often doing when I come in late to the conversation is
>pointing out the student could have handled this on his own simply by
>looking up a few keywords in the Java glossary.  Then there is no
>delay waiting for an answer that may never come, or may come with a
>large dose of invective.

Well stated.

Signature

Andrew Thompson
http://www.physci.org/

Andrew Thompson - 02 Dec 2007 14:56 GMT
>...
>What I am often doing when I come in late to the conversation is
[quoted text clipped - 4 lines]
>
>Well stated.

In fact, to take that (a little) further, my 'homepage' at
the moment is a simple page on my local file-system
that has 'handy links' as well as a 'search form' pointed
at Google, that can specify
- search string
- file type, &
- domain search

For the file type and domain search, I have drop down lists.

The domain search includes 8 Java related domains - *one
of those 8* is mindprod.  The mindprod site rates highly in
my 'search for knowledge' in relation to the Java programming
language.

Signature

Andrew Thompson
http://www.physci.org/

Andrew Thompson - 02 Dec 2007 15:04 GMT
...
>..'search form' pointed at Google,

Speaking of which. Drop this in some HTML.  Very
handy (if I say so myself).

<form method='get' action='http://www.google.com/search'>
Text:
<input type='text' size='20' name='as_q'>

Filetype:
<select name='as_filetype' size='1'>
<option value='' selected>All
<option value='java'>Java
<option value='jnlp'>JNLP
<option value='hs'>HelpSet
<option value='au'>Sound - AU
<option value='wav'>Sound - Wav
<option value='aiff'>Sound - AIFF
<option value='jpg'>Image - JPEG
<option value='gif'>Image - GIF
<option value='png'>Image - PNG
</select>

Site:
<select name='as_sitesearch' size='1'>
<option value='' selected>All
<option value='java.sun.com'>Sun
<option value='forum.java.sun.com'>Sun - Forums
<option value='bugs.sun.com'>Sun - Bug DB
<option value='ant.apache'>Apache - Ant
<option value='mindprod.com'>Mindprod
<option value='physci.org'>PhySci
<option value='java.net'>Java.net
<option value='dev.java.net'>Java.net - Dev
</select>

<input type='submit'>
</form>

HTH

Signature

Andrew Thompson
http://www.physci.org/

H.L - 02 Dec 2007 19:18 GMT
> But a rather obvious starting point in this case is to include the
> driver file which contains the classes that the OP is actually trying to
> load dynamically!

Thanks a lot for giving straight advice. Your solution worked, but
there was one more thing that I had to do for the error not to come. The
jar of the SQL database driver had to be signed as well. I thought that
it was enough to include it. It was downloaded from an official source.
The documentation on this is not very clear, neither from Apache or
Netbeans or the stuff on JNLP files from Sun. That's why I needed some
help from here.

Regards,

Håkan Lane
Lionel van den Berg - 03 Dec 2007 08:31 GMT
> The documentation on this is not very clear, neither from Apache or
> Netbeans or the stuff on JNLP files from Sun. That's why I needed some
> help from here.

I have to beg the differ on that one. The documentation for JWS does
clearly state that you must sign your jars. You need to work closely
with the Java control panel to get all the debugging output to see what
is going on.

But glad you got there.

Lionel.
Andrew Thompson - 03 Dec 2007 08:50 GMT
...
> ...The
>jar of the SQL database driver had to be signed as well.

Does it?  I had been meaing to ask why your project specified
<all-permissions/>.  That is not necessary for an app. that simply
wants to 'phone home' to a DB coming off the same server.

If you need the app. to contact a different server, then it would
require either trust or the user to OK the cross-domain access.

What else does the project do that might require trust?
Have you tried it without asking for all-permissions?

Signature

Andrew Thompson
http://www.physci.org/

Roedy Green - 03 Dec 2007 17:28 GMT
>The
>jar of the SQL database driver had to be signed as well.

If you are asking how to sign jars, see
http://mindprod.com/jgloss/jarsignerexe.html
http://mindprod.com/jgloss/jar.html
http://mindprod.com/jgloss/certificate.html
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Roedy Green - 05 Dec 2007 06:49 GMT
On Sun, 02 Dec 2007 20:27:09 +0100, "H.L" <H.L@softhome.net> wrote,
quoted or indirectly quoted someone who said :

>The
>jar of the SQL database driver had to be signed as well.

If you are asking how to sign jars, see
http://mindprod.com/jgloss/jarsignerexe.html
http://mindprod.com/jgloss/jar.html
http://mindprod.com/jgloss/certificate.html
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



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



©2008 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.