This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Websphere and the fly likes Deploying EJB in Websphere via Ant Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "Deploying EJB in Websphere via Ant" Watch "Deploying EJB in Websphere via Ant" New topic
Author

Deploying EJB in Websphere via Ant

Greg Brouelette
Ranch Hand

Joined: Jan 23, 2002
Posts: 144
Hi folks:
Excuse me if I'm asking an old question. I did a search on the terms "WebSphere, Ant, Ejb, Deploy" and didn't see anything that seemed relevent.
Having said that, Let's move onto the question
I'm running WebSphere 3.5.2 Upgrading is not an option yet as we have to wait until our IT department is convinced that upgrading won't break our applications that are already in production.
I can already deploy and use EJB's in WebSphere using JetAce to build my serialized jars. But I'm developing a new application which will have 20+ beans. I'd really like to have a target in Ant that serializes and deploys the bean automatically. I can figure out how to add in an RMIC tag to build the stub and skel files, but I'd love to know if there is a command line method of doing what JetAce does graphically.
If I can figure this part out then I can simply run Ant and have my new code compile, jar, serialize, and deploy. Then I just bounce WebSphere and I'm all set.
Thank you in advance for you help and advice
[ February 12, 2002: Message edited by: Greg Brouelette ]

For a good Prime, call:<br />29819592777931214269172453467810429868925511217482600306406141434158089
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
JetAce has a command-line driven mode. You create a template XML file in JetAce and then start it using the -f option. The following posting at ejbinfo describes the process.
Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Greg Brouelette
Ranch Hand

Joined: Jan 23, 2002
Posts: 144
Kyle, Thank you for the link. That almost gets me there. There is one line in that article that says this:
Make an jetace XML file describing your ejbs. This is documented in the infocenter
I'm not clear on what is meant by "The Infocenter". Do you know what this is? If I had the DTD for this XML file then I think I'd be all set.
Thanks again for the fast response.
Greg Brouelette
Ranch Hand

Joined: Jan 23, 2002
Posts: 144
Aha! I think I may have it.
I used JetAce to write the XML of an already serialized bean and I can see that this is the xml the article was referring to.
That article was the push in the right direction I needed. Thanks again.
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Really -- you don't know what the "InfoCenter" is? Eeek... how have you done anything with WebSphere without it!
The "InfoCenter" is the documentation set for WebSphere. It comes both as a download, or you can read it online at http://www-3.ibm.com/software/webservers/appserv/infocenter35.html
Kyle
Greg Brouelette
Ranch Hand

Joined: Jan 23, 2002
Posts: 144
Here's what I have so far: Inside my target that builds the EJB jar file I have this element:
<exec executable="c:/WebSphere/AppServer/bin/antjetace.bat" >
<arg line="-f C:/Dev_Projects/OFX/deploymentdescriptors/XMLToBeanParser/XMLToBeanParser.xml"/>
</exec>
This will run the jetace batch file. You'll notice that the jetace.bat file is renamed antjetace.bat This is because I had to add the full path in this line within that file

call c:/WebSphere/AppServer/bin/setupCmdLine.bat

The XMLToBeanParser.xml is essentially the same XML that you get if, from within the jetace gui, you select File/Write XML. I have only modified it such that it gets the jar file from my jar directory and then put the new jar (with the comment files and ser file) into the DeployableBeans directory. So far this seems to work.
BTW, even though it's in the deployment descriptor directory, we should not confuse this with the actual deployment descriptor.
This newly serialized bean will deploy correctly if I deploy it via the WebSphere admin console.
Now, what I'd REALLY like to do is to avoid redeploying every time my code changes. I'd like to deploy once and then just replace the EJB bean and bounce my appserver.
Here's what's blocking me:
When WebSphere deploys a bean it creates a new set of *.java files such that if I have a foo.java in my bean WebSphere will create an EJSfoo.java I need to replicate that.
Next, I need to compile those. If I can create the EJSxxx.java then this is no problem. However, both of these steps seem to occur in a program called EJBDeploy. I can't find that program anywhere in my WebSphere directory structure.
There is also a task/program called EJBJar that breaks my jar file out and seems to hand them to the EJBDeploy program.
So the next question is: Is there a command line equivalent to the EJBJar and EJBDeploy task within WebSphere?
[ February 14, 2002: Message edited by: Greg Brouelette ]
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Now, what I'd REALLY like to do is to avoid redeploying every time my code changes. I'd like to deploy once and then just replace the EJB bean and bounce my appserver.

If I'm reading you right what you want is what is called "hot deployment". That's a feature of WebSphere 4.0. It's not possible in 3.5.
However, you do know you can script deployment of EJB Jar files using XMLConfig, right?
Kyle
[ February 13, 2002: Message edited by: Kyle Brown ]
Greg Brouelette
Ranch Hand

Joined: Jan 23, 2002
Posts: 144
>However, you do know you can script deployment of EJB Jar files using XMLConfig, right?
Yep, I know I can use XMLConfig. But I'm talking about the creation of the EJSxxxx.java, compiling them to the EJSxxxx.class files, and then the RMIC of the EJSxxxx.class files. It sounds like what I need to do isn't possible in WebSphere 3.5
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
I don't understand -- you don't HAVE to do the RMIC part -- both XMLConfig and (I believe) JetAce will do that for you. All you have to do is to compile your original Java files...
Kyle
Greg Brouelette
Ranch Hand

Joined: Jan 23, 2002
Posts: 144
I don't understand -- you don't HAVE to do the RMIC part -- both XMLConfig and (I believe) JetAce will do that for you. All you have to do is to compile your original Java files...

Really? Because when I go into the WebSphere admin console and add an EJB from the "DeployableEJBs" directory and then click the "Deploy" button WebSphere will:
1. create a working directory in the "DeployedEJB" directory
2. For every class fooxxx.class in the EJB it will create a EJSfooxxx.java file
3. It will compile those EJSfooxxx.java files into class files and adds them to the corosponding jar file in the "DeployedEJBs" directory.
4. It runs the RMIC compiler on those classes (and puts them somewhere I havn't found yet)
5. Builds an appropriate tree node in the GUI for the adminconsole.
I was under them impression that to "deploy" the EJBs in WebSphere I would have to either mimic these steps or deploy the bean via the admin console.
If I'm not explaining this correctly let me know and I'll try to clear it up.
BYW, Thank you for you comments and suggestions so far. They've really helped me get this far.
Greg Brouelette
Ranch Hand

Joined: Jan 23, 2002
Posts: 144
OK, It looks like what I need to do is to call some methods from within teh ejs.jar and deploytool.jar files that are in the WebSphere lib directory. That should mimic the steps I outlined above.
However, and here's a new frustrating twist, I cannot even open up my admin console now because I'm immediately getting this error
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String ind
ex out of range: 0
at java.lang.Throwable.<init>(Throwable.java:96)
at java.lang.Exception.<init>(Exception.java:44)
at java.lang.RuntimeException.<init>(RuntimeException.java:49)
at java.lang.IndexOutOfBoundsException.<init>(IndexOutOfBoundsException.
java:46)
at java.lang.StringIndexOutOfBoundsException.<init>(StringIndexOutOfBoun
dsException.java:59)
at java.lang.String.charAt(String.java(Compiled Code))
at com.ibm.ejs.sm.client.ui.HelpCoord.readHelpfile(HelpCoord.java:122)
at com.ibm.ejs.sm.client.ui.HelpCoord.<init>(HelpCoord.java:54)
at com.ibm.ejs.sm.client.ui.EJSConsole.<init>(EJSConsole.java:388)
at com.ibm.ejs.sm.client.ui.EJSConsole.main(EJSConsole.java:1353)
I may have to use XMLConfig to remove my web application and then rebuild it.
It's always something isn't it?
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Greg, you are making this too hard! You can use XMLConfig to do all the deploying, including the deployment code generation.
See Here for an example.
Kyle
[ February 14, 2002: Message edited by: Kyle Brown ]
Greg Brouelette
Ranch Hand

Joined: Jan 23, 2002
Posts: 144
Thanks Kyle, I'll work on using xmlconfig. It sounds like I need to reasses what actually needs to happen during deployment.
BTW, the StringIndexOutOfBoundsException happened after I installed Infocenter (how bizzare) the solution to get WebSphere started was to rename C:\WebSphere\Appserver\web to C:\WebSphere\Appserver\web_old
That kept WebSphere from trying to access whatever file was causing the exception.
Greg Brouelette
Ranch Hand

Joined: Jan 23, 2002
Posts: 144
First of all, Kyle, you've been a great help. Thank you very much.
OK, here's more information on the solution:
Kyle's right, I only have to use xmlconfig to deploy my beans. Here's the XML I'm using:
<?xml version="1.0"?>
<!DOCTYPE websphere-sa-config SYSTEM "$XMLConfigDTDLocation$$dsep$xmlconfig.dtd" >
<websphere-sa-config>
<node name="WK7897N27" action="locate">
<application-server name="OFX" action="locate">
<container name="OFXContainer" action="locate">
<ejb name="SignonEJB" action="stop"></ejb>
<ejb name="SignonEJB" action="delete"></ejb>
<ejb name="SignonEJBHome" action="create">
<jar-file>C:/WebSphere/AppServer/deployableEJBs/SignonEJB.jar</jar-file>
<home-name>com/uboc/ofx/ejb/signon/SignonEJBHome</home-name>
<user-id></user-id>
<password></password>
<create-db-table>true</create-db-table>
<find-for-update>false</find-for-update>
<minimum-pool-size>2</minimum-pool-size>
<maximum-pool-size>100</maximum-pool-size>
<primary-key-check>false</primary-key-check>
<db-exclusive-access>false</db-exclusive-access>
</ejb>
<ejb name="SignonEJB" action="start"></ejb>
</container>
</application-server>
</node>
</websphere-sa-config>

The command line is simply
xmlconfig -import [path the file described above] -adminNodeName [your node name]
Now, when I do this it seems to start working BUT I'm now getting this message:
[02.02.20 11:04:13:031 PST] 561768f1 EJBConfig X Empty Deployment Descriptor, Home Nam
e com/uboc/ofx/ejb/signon/SignonEJBHome was probably specified incorrectly, create or upda
te will fail.
[02.02.20 11:04:13:062 PST] 561768f1 EJBConfig X Failed to create EJB : SignonEJBHomeR
However, my jar file in the DeployableEJBs directory not only has a ejb-jar.xml deployment descriptor in the meta-inf directory (which is the new way of doing it) but it also has the SignOnEJB.ser serialized file that was created by JetAce.
What I'm thinking is that when I deploy via WebSphere I have to select the .ser file within the ejb, not the jar file it'self. Would my XML have to select the ser file as well?
Thanks againfor all your help and assistence.
Greg Brouelette
Ranch Hand

Joined: Jan 23, 2002
Posts: 144
I should add that I can successfully deploy the jar file via the WebSphere gui, the error is only happening via the XMLconfig tool. So I don't think that the jar file itself is the problem.
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Greg, this makes zero sense. The XMLConfig tool in 3.5 has no business generating ejb-jar.xml files. It can't be generating that file. Do you possibly have both WebSphere 3.5 and 4.0 installed on this machine?
Kyle
Greg Brouelette
Ranch Hand

Joined: Jan 23, 2002
Posts: 144
Greg, this makes zero sense. The XMLConfig tool in 3.5 has no business generating ejb-jar.xml files. It can't be generating that file. Do you possibly have both WebSphere 3.5 and 4.0 installed on this machine?

Kyle, I think I may have not explained it correctly. When I build the original jar file with all the appropriate class files I (that is, my ant target) adds the ejb-jar.xml into the meta-inf directory (just so it will be compatible in the future).
Then the ant target calls jetace.bat via the exec tag and creates the .ser file and the comments.env and comments.dep files and adds them back into the jar file and places that jar file into the WebSphere/AppServer/deployableEJBs
So I'm adding the ejb-jar.xml file myself.
Now, I did notice this: the EJBName in the stop and delete elements didn't match the ejbName in the create element. I fixed that and got the same error.
The only odd thing I could come up with is that when I deploy via the WebSphere GUI I have to select the .ser file within the ejb, not the jar file itself. Would my XML file that I use to deploy via xmlconfig.bat have to select the .ser file as well? That's the closest thing to a "missing deployment descriptor" that I can think of 3.5 using.
Greg Brouelette
Ranch Hand

Joined: Jan 23, 2002
Posts: 144
I Got It!
The home-name tag in the XML file I use to deploy use to be this:

It needed to be this

That did it!
 
Don't get me started about those stupid light bulbs.
 
subject: Deploying EJB in Websphere via Ant
 
Similar Threads
DeploymentException encountered when trying to deploy an Enterprise Bean in WebSphere
Deploying With Ant Using Websphere3.5
need some information about Ant
deploy ejb in websphere3.5
EJB InitialContext Factory