Run Enterprise Application Client outside Netbeans

2020-05-03 05:26发布

I have followed the tutorial on this webpage: https://netbeans.org/kb/docs/javaee/entappclient.html

I want to run the enterprise application client outside of Netbeans. Note that an Enterprise application client is different to a web client i.e. it is an application client.

I have tried executing the following commands:

set classpath=C:\GenieDevelopment\NetBeansProjects\RemoteInterface\EJBRemote\dist\EJBRmote.jar cd C:\Program Files\glassfish-4.0\glassfish\bin Appclient -client C:\NetBeansProjects\RemoteInterface\ClientTest\dist\ClientTest.jar

The error I get is:

Oct 04, 2016 7:59:32 PM org.glassfish.apf.impl.DefaultErrorHandler error
SEVERE: Class [ Ltest/TestEJBRemote; ] not found. Error while loading [ class cl
ienttest.Main ]
Exception in thread "main" java.lang.NoClassDefFoundError: test/TestEJBRemote
        at clienttest.Main.main(Main.java:24)
Caused by: java.lang.ClassNotFoundException: test.TestEJBRemote
        at java.net.URLClassLoader.findClass(Unknown Source)
        at org.glassfish.appclient.client.acc.ACCClassLoader.findClass(ACCClassL
oader.java:237)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 1 more

What is the problem? The remote interface is in the classpath.

2条回答
劫难
2楼-- · 2020-05-03 05:38

The classpath doesn't consider JAR files inside directories that you list. It'll use JAR files explicitly given in the classpath, and .class files in the directories you list; but not JAR files in the directories. If you want to get it to include JAR files in a directory, you'll need to use wildcards:

java -cp "EntAppClient.jar;C:\jardirectory\*" ...

That will include all files within that directory, and if those files are JARs, it'll pick them all up.

If you want to be able to build applications and then deploy and run them outside of your IDE, I strongly recommend using Maven to control your dependencies and allow you to build a fat JAR containing all the dependencies in one place. You'll save yourself a lot of headaches later on.

查看更多
Summer. ? 凉城
3楼-- · 2020-05-03 05:51

You need to run J2EE apps inside a webserver such as tomcat or glassfish or even Google AppEngine. Usually you generate .WAR file that you upload to the web server. In the case of tomcat you open http://localhost:8080/manager/html and then upload the .war file and then http://localhost:8080/myapp will show you your webapp.

查看更多
登录 后发表回答