开发者

JBoss - does app have to be compiled under same jdk as JBOSS is running under?

开发者 https://www.devze.com 2022-12-22 15:24 出处:网络
I\'m a little confused about JBOSS and running it under different JDKs.For example, let\'s say I\'m running JBOSS 5.1, and before starting it I set my JAVA_HOME to point to JDK5.Let\'s also assume tha

I'm a little confused about JBOSS and running it under different JDKs. For example, let's say I'm running JBOSS 5.1, and before starting it I set my JAVA_HOME to point to JDK5. Let's also assume that my Java EE application is compiled under JDK6. If I deploy the Java EE app (compiled under JDK6) to JBOSS, when I try to look up my EJBs I get errors like:

javax.naming.NameNotFoundException: tc_test_project not bound

But if I recompile my code under JDK5 and redeploy it, it works fine and is able to lookup the EJBs ok.

开发者_运维技巧

Likewise, I can set JAVA_HOME to JDK6 and start JBOSS, and my code (compiled under JDK6) will run ok under that scenario (it's able to find the EBJs, etc.).

So it seems that your Java EE app needs to be compiled under the same JAVA_HOME that the JBOSS server is going to be running under, or am I misunderstanding something? Just wanted to get confirmation, thanks.


The application must be compiled with the same or lower version of the JDK used to launch JBOSS. This is because the application will use the same JVM.


No, you should be able to compile with JDK6 as long as you pass -target 1.5 as an option so it outputs java 1.5 class files. Add -source 1.5 if you want to be flagged for using newer language features.

So it can be compiled with a newer JDK as long as you target the version of the VM that the application will be running under (and are only using features that exist in the target VM).

EDIT: I never claimed it was a good idea or right, only that it is possible.

0

精彩评论

暂无评论...
验证码 换一张
取 消