 |
 |
java dying a creeping death - NoClassDefFound error
|
 |
|
 |
|
jim68000
|
|
Hi
I've been trying to use Mac OS X to do some XSLT transforms - it saves me the tyranny of my local NT sysadmin. I had some success at first, with the classes exefcuting fine, but now java fails whenever i try to load saxon.jar (or xt/xp.jar).
in both cases I get a NoClassDefFound for main in whatever class I'm calling.
The problem began when i switched from using the xt/xp combo to saxon - as both contain sax from the w3c is it possible that java has cached the classes somewhere and is confused as to which i mean and i need to delete that cache?
More weirdly, the problem seems to be getting worse. Tomcat is now affected by the same problem, wheras before it had seemed immune.
I've tried setting both a CLASSPATH env with setenv CLASSPATH /path/to/jar and calling java as java -cp /path/to/jar and both get the same result.
The strange thing is that java -jar jedit.jar (say) works fine - i get jedit and everything's dandy. It's just where i trying to call a method from a class.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: Edmond, OK USA
Status:
Offline
|
|
The Java VM will never cache classes anywhere - I have even written code that will reload classes through the system classpath and it works fine. More than likely the package you installed put stuff in the 'Magic' classpath locations which is being scanned before your other jars/classes, which would explain why all of your java code is acting up now. Specifying a classpath on the java invocation doesn't replace the classpath, it merely augments it. To illustrate:
java -classpath /non_such_directory java.lang.Object
produces:
Exception in thread "main" java.lang.NoSuchMethodError: main
which indicates that the VM loaded java/lang/Object.class, but that the method was non-existent (which it should be).
I tested this under JDK 1.3, so I am not sure about 1.2.2.
At any rate, I would check the classpath.
------------------
|
|
|
| |
|
|
|
 |
|
 |
|
jim68000
|
|
Originally posted by absmiths:
The Java VM will never cache classes anywhere - I have even written code that will reload classes through the system classpath and it works fine. More than likely the package you installed put stuff in the 'Magic' classpath locations which is being scanned before your other jars/classes, which would explain why all of your java code is acting up now.
Hmmm. Doubtful: the transform worked fine under xp/xt, then failed under saxon: then just hitting up arrow until i found the xp/xt line again failed too, even though i hadn't changed a thing...
What is the default classpath on OS X?
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jul 2000
Location: Jersey City, NJ 07304
Status:
Offline
|
|
I'm very interested in growing this discussion if possible. I've been using CodeWarrior on MacOS for about a year, doing Java only.
Last week I spent half a day trying to get one of my programs, which uses 6 jar files, and about 30 java source files to compile on MacOSX. There is no GUI app I could find so I was creating text files and just putting huge javac commands in them, naming all the source files and jars.
It was a lot of typing but then I just made it executable and could run it easily.
Unfortunately, I also could not get past the classDefNotFound errors, even though necessary classes were in the jar files. And I had put them into the CLASSPATH global variable.
Are there problems I'm not aware of? And also, are there any GUI java IDE's you could recommend for OSX?
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Jan 2001
Location: Seattle
Status:
Offline
|
|
For compiling code, use Project>Add Framework and choose a .jar file. However, how to get these added to the classpath the clickable app uses is still beyond me.
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Feb 2001
Location: zurich, switzerland
Status:
Offline
|
|
rollerdexter: codewarrior pro 6 for osx is out if you want it.
As for the classpath (although I haven't got my copy of osx yet) I know from my linux java headaches that each shell has it's own environment. (I don't know? can one open more than one shell window in osx?) and so it's best to set the path in the one of the inittab scripts so that you get this throughout your system. I mean the path. maybe java can simply not find the jars. Also if it is screwing up tomcat, I would go with the idea that you overwrote or deleted something when you installed saxon. was it in jar form or from a tgz. maybe , because xp/saxon whatever both deal with xml they have a method or member that has the same name as the other class and therefore cause some sort of ambiguity situation. mmmm..... what about just typing -cp ./ for the classpath. sorry if all these musings are useless. just thought i'd throw in my two cents.
------------------
#ex-dotcom#
|
|
weird wabbit
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: Edmond, OK USA
Status:
Offline
|
|
The only way to be absolutely sure is to:
1 - track down ALL neccessary jars,
2 - start a terminal and completely erase the CLASSPATH (I never use this anyway, it is asking for trouble.)
3 - manually invoke the command you want with -cp on the command-line and name each jar explicitly.
If this does not work, I would check in the JRE lib directory, etc. If both versions of the library provide the same classes (sax in this case) then your runtime environment is probably loading a mismatched set of classes from each version.
My motto is..."If after installing software, something is broken, then the installer broke it." Better find out what you did that broke the setup, then fix it.
I reiterate what I said before - the Java runtime environment will NOT cache classes (Between different invocations of the VM). E.G., when you recompile your source code, do the new versions load or the old? A caching environment as you suggest would make Java development impossible.
[This message has been edited by absmiths (edited 02-19-2001).]
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|