Missing something...

I've been learning/working in Java for about a month now. I've got an application finished and it works fine on my desktop (Windows 2000 using NetBeans IDE). But I'm having problems getting it to work on the server (Solaris). I'm sure it's something simple that I'm overlooking but I just can't find it!

The app consists of 5 class files, all in a package named 'ewlr'. I've placed them on the server in the /local/apps/java/PMJ/ewlr path. The app uses the log4j-1.2.jar file (logging stuff), classes12.zip (Oracle stuff), and two other jar files (web services stuff) from a third-party. I've placed all of those plus two properties files into the /local/apps/java/PMJ path. The app gets run by a shell script:

--

#!/bin/csh

#

# RUN_PATH needs to be set to cwd.

#

set RUN_PATH=/local/apps/java/PMJ

set JAVA_HOME=/usr/jdk/instances/jdk1.5.0

setenv CLASSPATH $RUN_PATH/log4j-1.2.jar:$RUN_PATH/classes12.zip:$RUN_PATH/WebService.jar:$RUN_PATH/webservice

client.jar:$RUN_PATH/ewlr:$RUN_PATH

cd $RUN_PATH

$JAVA_HOME/bin/java ewlr.Main $RUN_PATH/

--

When I run the app, I get 'Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger'. The error happens on this line:

private static Logger logger = Logger.getLogger(Main.class.getName());

So why can't it find the Logger class? I've explicitly included the jar file that contains that class in the classpath via the shell script. What am I overlooking/missing? Like I said, it works fine on my desktop (though I don't run it via a script).

Thanx in advance to any tips/hints you can provide! And sorry this ended up being so long...

Dave

Message was edited by:

DaveKub

Message was edited by:

DaveKub

[1827 byte] By [DaveKuba] at [2007-10-3 2:51:45]
# 1
I'm not too familiar with csh at all, but instead of using CLASPATH env, why not simply pass the classpath to java using the -cp argument, i.e.$JAVA_HOME/bin/java -cp $CP ewlr.Main $RUN_PATH/barring that suggestion, no idea
IanSchneidera at 2007-7-14 20:40:39 > top of Java-index,Java Essentials,Java Programming...
# 2

You could try adding -cp $CLASSPATH between java and ewlr.Main. You shouldn't have to, since you're setting the env var. But if java is a shell script, or if it gets run in a subshell that doesn't propagate your environment, then that could be the problem.

If that doesn't help, then either $RUN_PATH/log4j-1.2.jar doesn't exist, or else it doesn't contain the file in question.

jverda at 2007-7-14 20:40:39 > top of Java-index,Java Essentials,Java Programming...
# 3

Adding the -cp gave me the same error message. But then I noticed that the file size of the log4j-1.2.jar file was *one byte* smaller than it is on my system. So I transferred it to the server again and verified that the file size matched this time. Ta-da! The error message went away... Doh!!

I checked the other jar, class, and zip file(s) and some of them were also a different size. Not sure how that happened but after transferring them again everything works. Maybe when I initially ftp'd them to the server I didn't set it to binary mode? Who knows, but it works now!

Thanx for the replies!

Dave

DaveKuba at 2007-7-14 20:40:39 > top of Java-index,Java Essentials,Java Programming...
# 4

> I checked the other jar, class, and zip file(s) and

> some of them were also a different size. Not sure

> how that happened but after transferring them again

> everything works. Maybe when I initially ftp'd them

> to the server I didn't set it to binary mode?

Sounds very likely. :-)

jverda at 2007-7-14 20:40:39 > top of Java-index,Java Essentials,Java Programming...