|
 |
|
 |
08-25-2006, 12:55 AM
|
#1 (permalink)
|
|
Code Monkey
Join Date: Apr 2005
Posts: 68
|
Compiled Java files working on one machine and not on another machine??
Hello,
I have two queries which are as follows:
1)
I had some java classes which i had to compile and move into the production machine.
Now i compiled those files in my development environment and moved the class files to Production.But they didnt worked there.
My Development environment consists of: Windows XP,Apache Tomcat Webserver 4.1,jdk1.3.1_01
My Production environment consists of: UNIX,Weblogic 6.1 ,jdk1.3.1_01(which comes included with weblogic by default)
Now what i would like to know is this:
Java is a platform-independent language having only the difference between JVM's for different machines which interprets the generated bytecodes.So the files compiled on any machine should work properly wherever a JVM is present no matter on which machine the JVM is there(Please correct me if i im wrong)??
But the files compiled on my development machine didn't worked on the production machine.But the same when i compiled on the Production machine it worked smoothly.So can you people please explain me why it behaved like this??
2)If any application server/webserver includes the Java Software Development kit
AND
if i have JDK installed on the same PC at some other location(excluding appserver/webserver version)
then when the applications is deployed and accessed which JDK version the Application will
use??
Thanks,
Jignesh
|
|
|
08-25-2006, 01:53 AM
|
#2 (permalink)
|
|
Java fanboy
Join Date: Aug 2003
Posts: 1,148
|
Answering 2 first, it depends. If you're running a web-application, the J2EE server you're using (weblogic in this case) may have a configuration file that defines which JDK get's used. Normally the computer simply chooses whichever is first in your PATH.
As for 1 - you'll need to elaborate on what "they didn't work there" entails.
|
|
|
08-26-2006, 03:21 AM
|
#3 (permalink)
|
|
Code Monkey
Join Date: Apr 2005
Posts: 68
|
Hi Belisarius,
Thanks for the reply.
The .java files which i compiled on the Windows machine resulting into .class files.These .class files didnt worked on teh UNIX machine.
But the same java files which when compiled on the UNIX machine and the resluting class files were used , the class files worked fine.
Firstly i supposed that this can be due to java versions on both of the machines but then i installed the same jdk version which was there in the weblogic server that is jdk1.3.1_01 which comes integrated with the weblogic6.1 server.But after compiling the .java files using the above mentioned jdk version also the class files didn't worked on the UNIX machine.
Can you please explain what are the possible causes for this kind of behaviour of class files as in the normal case the bytecodes obtained by compiling the .java files on any machine can be read by the jvm installed on any kind of machine(Correct me if i am wrong in this thing??).
Jignesh
|
|
|
08-26-2006, 05:17 AM
|
#4 (permalink)
|
|
Java fanboy
Join Date: Aug 2003
Posts: 1,148
|
Well, in my past experience the main problem has been with GUI's, as they have a tendency to break across platforms. I haven't had an instance where, say, "Hello World" would break.
You need to tell me how you know they're "broken". It may be that the class files aren't broken, but that it's a misconfiguration and WebLogic doesn't see what you think it's seeing. If, for instance, you move JAR files to the wrong directory, but running an Ant script to recompile puts them in the correct directory.
You'll need to explain what "didn't work" actually means.
|
|
|
08-27-2006, 04:32 AM
|
#5 (permalink)
|
|
Code Monkey
Join Date: Apr 2005
Posts: 68
|
Hi Belisarius,
I have a already exisiting application for which i had to create a new module.
Now the application was already compiled and working since 4 years.
The application is built on MVC architecture.
So from the controller one method is invoked which is there in a abstract class and my each class made for the new module extends this abstract class and implements its only single abstract method .
But this abstract class was already compiled and existing there.In my new module i was just using this abstract class as mentioned above by extending it.
When i made the new module and integrated the new module in the application the following things occured:
When i compiled my .java files on my Windows Machine and the resulting .class files i deployed in my application in my webserver on my Windows machine they worked fine.
But when the same class files were deployed on UNIX machine in the application on my weblogic server ,the exception was thrown:
java.lang.NoSuchMethodError occured.
I saw the stack trace and found out the method where the exception was occuring.This was the same method of that abstract class which was already compiled and i was implementing that by making my new classes to extend that abstract class.
And the exception was occuring when this method was invoked from the controller and the method version which was getting called is the one i implemented in my newly made classes by extending the above mentioned abstract class.
I checked each and every line of code but i found nothing wrong..
Also i looked in to the java docs .It was given like this:
usually this error is caught by the compiler ,but it can occur at runtime only if the class definition has incompatibly been changed.
But the same .java files when i compiled on the UNIX machine and the resulting .class files were deployed in my webapplication on weblogic ,they worked fine.
So this was the problem.So what do you say now??
Jignesh
|
|
|
08-27-2006, 04:41 AM
|
#6 (permalink)
|
|
Java fanboy
Join Date: Aug 2003
Posts: 1,148
|
My guess would be that there is an obsolete class file hidden somewhere in the package that you moved from Windows to Unix. There is the possibility that you found a bug in the implementation of Java, but I'd bet that for some reason an old class file is getting used and is only being replaced upon re-compile.
|
|
|
09-07-2006, 04:21 AM
|
#7 (permalink)
|
|
Code Monkey
Join Date: Apr 2005
Posts: 68
|
But Belisarius,I am compiling only the newly made files and as told before all the newly made files are extending the already existing abstract class and overriding its only method.I am just recompiling the newly made files but not that abstract class.So if i compile them on UNIX machine the work but if compile them on Windows,a runtime error occurs "java.lang.NoSuchMethodError" for the same method which the newly made classes are overriding form the abstract class which they extend.
So what are your comments now??
|
|
|
09-07-2006, 11:45 AM
|
#8 (permalink)
|
|
Java fanboy
Join Date: Aug 2003
Posts: 1,148
|
Well, my inclination is that there is still an old .class file somewhere that is screwing things up, but unless I can access your entire work environment, I'm not sure I'll be able to help you much more. You can take a look at the .class file before and after you compile to see if there's a filesize difference.
Also, you can try creating a throw-away java file that extends the abstract class in the same fashion, and see if it compiles and runs (compile only that class though, don't use a compile program like Ant).
Also, you can take a look at the output of javap -c and try to spot any differences.
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting 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
|
|
|
All times are GMT -8. The time now is 10:55 PM.
|
Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
|
 |
|