NoClassDefFoundError

H

H.L

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.
 
A

Andrew Thompson

H.L wrote:
...

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>
 
H

H.L

Andrew said:
H.L wrote:
..

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>

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

Message posted via http://www.javakb.com

I exchanged it for yours, but I still get the same error.
 
H

H.L

Andrew said:
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 simply have not done that thing. Thank you for
helping me.
 
A

Andrew Thompson

Andrew said:
...

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.
 
A

Andrew Thompson

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

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

Lionel van den Berg

H.L said:
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.

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.
 
A

Andrew Thompson

H.L said:
...
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
--
Andrew Thompson
http://www.physci.org/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200712/1
 
D

David Golden

Andrew said:
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.
 
A

Andrew Thompson

Lionel said:
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.

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

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200712/1
 
R

Roedy Green

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.
 
A

Andrew Thompson

Roedy Green wrote:
...
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.
 
A

Andrew Thompson

Andrew said:
...
What I am often doing when I come in late to the conversation is

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.
 
A

Andrew Thompson

Andrew Thompson wrote:
...
..'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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,120
Latest member
ShelaWalli
Top