File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Websphere and the fly likes Deploying Jar inside WebSphere5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "Deploying Jar inside WebSphere5" Watch "Deploying Jar inside WebSphere5" New topic

Deploying Jar inside WebSphere5

Mishra Anshu
Ranch Hand

Joined: Sep 16, 2003
Posts: 224
Suppose I have an enterprise application (say , MyApp.ear), deployed on the WebSphere5. It uses, JMS, DataSource configuration, done at the Server where it has been deployed.

Now, I want to make an java application which uses some of the piece of functionalities of the MyApp.ear. So, I make a jar of such utilities/methods (say, MyUtil.jar) and use it in my Stand alone java application. It compiles fine. Now, MyUtil.jar has got code for, say, dealing with datasource (hence, database ). As, the datasource (and also JMS ques n all...)is configured on the Server, I feel I need to deploy my java application on the Server. so that my "MyUtil.jar" can use the configuration seetings done over there.

When I went to the admin console of the WebSphere server , it suggests that it will allow one to deploy the application as either, EAR, WAR or JAR file. When I tried to deploy the JAR of my application , with mainfest file containing the Main class, it produced an error, suggesting that it has to be an EAR file to deploy.

I made an EAR project and then wrapped my application in a Application Client project (I am using WSAD), and then tried to deploy my application over the WebSphere server. It did deploy, but the status of the application became "UNKNOWN".

Has anybody ever required to deploy stand alone application over the App Server, and what happens if at all a non-web project is deployed over the App Server?

Can you suggest a better way, so that the common code sitting inside the MyApp.ear could be used and also, we can run the Standalone java app inside a JVM instead of using App Server?

"Ignorance is bliss"
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3753

In J2EE, only EAR's can be deployed. WARs/JARs exist inside EARs so if anything lets you deploy them, then it might be automatically creating an EAR around them, but either way, there is always an EAR.

There's really no such thing as a stand alone app in J2EE. You either have to code services (EJB/Web/Messaging) using EARs + JARs/EJBs or you code Web applications using WARs inside of EARs.

If you need a true stand alone JVM, you don't use websphere, you just start it from command line.

I think what you're talking about is a utility library. Yes, you can create utility library jars and pass them inside multiple EARs. If you want them to share objects accross EARs you would have to add it to the server class loader (strongly not recommended). In the case you need helper methods, just drop the JAR into every EAR, else in the case of shared memory, create a service layer around the JAR and have the other applications go through there.

[OCA 8 Book] [Blog]
I agree. Here's the link:
subject: Deploying Jar inside WebSphere5
It's not a secret anymore!