I'm teaching myself EJB with Roman's Mastering EJB and I've hit a snag just trying to do the 'hello world' EJB. All my files are ok, exactly the same as what I downloaded from the author's website. The problem comes with the JNDI naming that apparently should be taken care of by a weblogic-ejb-jar.xml, or somehow through the descriptor files. I'm using ant to compile the ejb jar but it ignores the weblogic-ejb-jar.xml, which is in the same directory right next to the plain ejb-jar.xml This is my ejb-jar.xml:
This is my weblogic-ejb-jar.xml:
and this is the ant task:
I think I'm missing something fundamental here, but I can't work out whether it's ant, weblogic, Mastering EJB or me that's at fault. Massively grateful for any tips Adam
Hi Adam, What is the error message raised ? What is the code used to perform the lookup ? Note: Depending on the causes of your problem, it could be better to post the question to the weblogic forum. [ December 12, 2002: Message edited by: Bill Bailey ]
Basically ant wasn't putting the weblogic-ejb-jar.xml descriptor in the jar. I played with it and have managed to get it to do that. However I'm not sure it's going to be OK. It generated all sorts of weblogic stuff as well. Where should the JNDI info normally go? Currently I've got it in the weblogic-ejb-jar.xml I could do this the weblogic way, but the weblogic console will deploy generic jars as well, so there's no point in restricting myself. So if I delete this weblogic-ejb-jar.xml, where would I put the JNDI info? Thanks Adam
You need the weblogic-ejb-jar.xml file if you want WebLogic to deploy your ejb. It is optional to run ejbc on the ejb jar before deploying. WebLogic will automatically run ejbc if you do not. All that extra stuff is being generated by ejbc in your ant task, it is perfectly normal. In no way is the weblogic-ejb-jar.xml optional.
Oh. Then my ant task is messing up. For some reason it won't include the weblogic-ejb-jar.xml, unless I use the weblogic ant-task within the ejb-jar ant-task. If I do that I get allsorts of weblogic stuff generated too. I don't want to use the weblogic ant-task - I just want a generic jar, containing all the descriptor files I decide to use. I mean, I will probably end up with a websphere and a jboss descriptor file as well. Any ideas?
Your ant task is working how it is supposed to work. It is meant to be ignorant of vendor implementation details, hence it does not include the additional vendor files. You have a few choices: 1) Use the vendor extensions to create the jars. In this case you would create separate ejb jars for each application server you are building for. 2) Use the support tag to tell ant what additional files to include. This may be a maintenance nightmare if you have alot of ejbs, since you would need to specify the files for each ejb separately. 3) Modify ant to work how you would like it to work, afterall it is open-source. This is really only valuable if you can get it submitted back to the project. Personally, I would recommend number 1 or 3.
Ok. I can live with no. 1 At the moment, I've got it to make a jar with everything in it. Say though I had 4 descriptor files, one standard and the others for specific appservers: hello-ejb-jar.xml hello-weblogic-ejb-jar.xml hello-jboss-ejb-jar.xml hello-websphere-ejb-jar.xml If they all get put in the same jar, with no appserver specific generated stuff, would it still work? Or would the websphere-ejb-jar.xml disturb weblogic & vice versa?
Post by:autobot
Opportunity is missed by most people because it is dressed in overalls and looks like work - Edison. Tiny ad:
a bit of art, as a gift, that will fit in a stocking