Friday, June 25, 2010

Running j2EE application from JAR file

I have a J2EE application that uses JMS and Glassfish application server.

The Application is built on netbeans and runs fine, when executed from Netbeans.

I made a build of it, so that i can run it using the JAR file. In the Library, i added the Glassfish lib as well as the Glassfish\imq lib, so that it gets all the JARs that it needs. The build is fine and i get an executable jar in the dist folder.

However, when the application is executed using the JAR file, it starts but gives an exception: "Javax.Naming.NoInitialContextException Cannot instantiate  com.sun.appserv.naming "

I checked the project folder. 
The dist folder just has the JAR file. 
build/jar/META-INF folder has the lib folder.

Please help.

Ans : 
If you look at the quickstart guide for Glassfish

https://glassfish.dev.java.net/downloads/quickstart/index.html

It shows you how to start the glassfish server running:

https://glassfish.dev.java.net/downloads/quickstart/index.html#ProcedureTo_Start_the_GlassFish_server

------------------
Steps

   1.   Add the install-dir/bin/ directory to the PATH environment variable.
   2.   Start the server by entering this command: asadmin start-domain domain1.

      When the server has started, this message appears: Domain domain1 is ready to receive client requests. Additional services are being started in the background.
------------------

Then this should show you the steps to deploy your application:

https://glassfish.dev.java.net/downloads/quickstart/index.html#Packaging_and_Deploying_Applications

I've not used GlassFish yet, as I haven't had an EE project to do for a while, but hopefully this should give you all the steps you need to get things running without relying on NetBeans...

No comments:

Blog Archive