- This topic has 13 replies, 3 voices, and was last updated 20 years ago by Scott Anderson.
-
AuthorPosts
-
nat101MemberHi;
I am trying to produce ejb’s the ‘XDoclet’ way and have followed the Trader tutorial and have some general and specific questions/problems.1) When will it be ok to choose j2ee 1.4 for a XDoclet project? (Quickfix?)
2) In the buy and sell methods’ javadoc, there is a @parameter for ‘customer’, however the method itself only has one string parameter for the stock symbol. Is this correct? My concern is that an incorrect annotation can cause XDoclet to generate wrong code somewhere.
(Welcome to the new era, we now have to DEBUG annotations.)3) (Ok. Enough fluff.) Since I use Jonas 4.1.4, I had to add a Jonas XDoclet subtask, but I have no idea what to enter as values for any properties. Isn’t there a simpler way? Imho, ME should know which properties to check off, along with default values. Anyhow, I added a session bean segment manually (with the help of ME’s ctrl-space!) like this:
<jonas-ejb-jar> <!-- Session Beans --> <jonas-session> <ejb-name>Trader</ejb-name> <jndi-name>ejb/training/TraderHome</jndi-name> </jonas-session> <!-- Entity Beans --> <!-- Message Driven Beans --> </jonas-ejb-jar>
Btw, The name of my pkg is training.trader.ejb.
But when I deploy to Jonas, and tell Jonas to deploy it, Jonas refuses with the folowing:2004-12-29 21:18:16,140 : EjbDeploymentDescManager.getDeploymentDescriptor : No entry 'META-INF/jonas-ejb-jar.xml' was found in the file '/E:/java/AppServer/JOnAS414/work/ejbjars/jonas/firstejb_2004.12.29-21.17.50.jar'. 2004-12-29 21:18:16,265 : SessionDesc.checkTxAttribute : trans-attribute missing for method public abstract int training.trader.interfaces.Trader.buy(java.lang.String,int) throws java.rmi.RemoteException in session bean Trader (set to the default value Supports) 2004-12-29 21:18:16,281 : SessionDesc.checkTxAttribute : trans-attribute missing for method public abstract int training.trader.interfaces.Trader.sell(java.lang.String,int) throws java.rmi.RemoteException in session bean Trader (set to the default value Supports) 2004-12-29 21:18:16,328 : JFactory.checkJonasVersion : failed to find class training.trader.interfaces.JOnASTrader1519799399Homejava.lang.ClassNotFoundException: training.trader.interfaces.JOnASTrader1519799399Home
4) Also if I want to develop ejb’s without XDoclet, do I still have ME create an ‘ejb project’? And what type of automation (regarding ejbs) does ME supply sans XDoclet?
Thank you much.
-nat
GregMember1) When will it be ok to choose j2ee 1.4 for a XDoclet project? (Quickfix?)
XDoclet support for j2ee1.4 really depends on the underlying modules. I don’t know of hand which modules are 1.4 compliant and which haven’t been updated. I believe the ejb module is 1.4 compliant, so you would just have to check on the jonas module and see if it will generate 1.4 compatible deployment descriptors for jonas correctly then you can use 1.4 for your j2ee version. I just checked the jonas subtask documentation here and it appears that the jonas module doesn’t have support for 4.x versions. And j2ee 1.4 was first introduced in jonas 4.
2) In the buy and sell methods’ javadoc, there is a @parameter for ‘customer’, however the method itself only has one string parameter for the stock symbol. Is this correct?
Nevermind that parameter. That is just old javadoc that didn’t get updated when we modified the traderx application for this documentation.
3) (Ok. Enough fluff.) Since I use Jonas 4.1.4, I had to add a Jonas XDoclet subtask, but I have no idea what to enter as values for any properties. Isn’t there a simpler way?
Not currently, you have to still setup xdoclet configuraiton along with a couple of xdoclet tags in your EJB source to get xdoclet to generate all of your jonas mappings.
1) Use the EJB tutorial as normal except you must set the ejbSpec version to 2.1 on the <ejbdoclet> if you want to use J2EE1.4.
2) Where the tutorial talks about jboss,you need to add a jonas subtask instead
3) Set the jonas version attribute to 3.0 and set the destDir to “src/META-INF”. This tells xdoclet to generate the jonas-ejb-jar.xml file in the src/META-INF directory.
4) Go to your EJB source and add the following xdoclet tags to the top of your EJB file (just below the @ejb tags is fine.* @jonas.bean * ejb-name = "<same as @ejb.bean name="" attribute>" * jndi-name = "<same as @ejb.bean jndi-name="" attribute>"
Now when you run XDoclet you will see all of your interfaces get generated and also you will see a jonas-ejb-jar.xml deployment descriptor along side your ejb-jar.xml file.
4) Also if I want to develop ejb’s without XDoclet, do I still have ME create an ‘ejb project’? And what type of automation (regarding ejbs) does ME supply sans XDoclet?
Lots 🙂 like packaging your EJB into a jar and deploying it to an appserver with auto-syncing and full hot-swap debugging support. But as far as keeping all of your interface files and deployment descriptors that will be up to you without xdoclet (a very tedious task indeed).
nat101MemberOk. I tried, but no go. Here are the details.
Set the jonas version attribute to 3.0 and set the destDir to “src/META-INF”. This tells xdoclet to generate the jonas-ejb-jar.xml file in the src/META-INF directory.
This ‘took’. No more error regarding this.
4) Go to your EJB source and add the following xdoclet tags to the top of your EJB file (just below the @ejb tags is fine.
Code:
* @jonas.bean
* ejb-name = “<same as @ejb.bean name=”” attribute>”
* jndi-name = “<same as @ejb.bean jndi-name=”” attribute>”Now when you run XDoclet you will see all of your interfaces get generated and also you will see a jonas-ejb-jar.xml deployment descriptor along side your ejb-jar.xml file.
a) The interfaces were being genned before this step, anyhow, along with the jonas-ejb xml, but it was red-flagged until I manually enterd the <jonas-session> attribute as decribed above in the first message.
Note: I didn’t notice any change before/after adding the @jonas.bean.Now for the errors. The Jonas console, upon deploy request responds:
* Deploy error : autoload/firstejb.jar : java.lang.Exception: Cannot create Container: javax.ejb.EJBException: Trader Cannot load training.trader.interfaces.JOnASTrader227742157Home; nested exception is: java.lang.ClassNotFoundException: training.trader.interfaces.JOnASTrader227742157Home
The Jonas error log reports:
2004-12-30 11:13:32,812 : SessionDesc.checkTxAttribute : trans-attribute missing for method public abstract int training.trader.interfaces.Trader.buy(java.lang.String,int) throws java.rmi.RemoteException in session bean Trader (set to the default value Supports) 2004-12-30 11:13:32,812 : SessionDesc.checkTxAttribute : trans-attribute missing for method public abstract int training.trader.interfaces.Trader.sell(java.lang.String,int) throws java.rmi.RemoteException in session bean Trader (set to the default value Supports) 2004-12-30 11:13:32,843 : JFactory.checkJonasVersion : failed to find class training.trader.interfaces.JOnASTrader227742157Homejava.lang.ClassNotFoundException: training.trader.interfaces.JOnASTrader227742157Home
Here is the top of my TraderBean class:
/** * XDoclet-based session bean. The class must be declared * public according to the EJB specification. * * To generate the EJB related files to this EJB: * - Add Standard EJB module to XDoclet project properties * - Customize XDoclet configuration for your appserver * - Run XDoclet * * Below are the xdoclet-related tags needed for this EJB. * * @ejb.bean name="Trader" * display-name="Name for Trader" * description="Description for Trader" * jndi-name="ejb/training/TraderHome" * type="Stateless" * view-type="remote" * * @jonas.bean * ejb-name = "Trader" * jndi-name ="ejb/training/TraderHome" */ public class TraderBean implements SessionBean {
Here is the jonas-ejb-jar.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE jonas-ejb-jar PUBLIC "-//ObjectWeb//DTD JOnAS 3.0//EN" "http://www.objectweb.org/jonas/dtds/jonas-ejb-jar_3_0.dtd"> <jonas-ejb-jar> <!-- Session Beans --> <jonas-session> <ejb-name>Trader</ejb-name> <jndi-name>ejb/training/TraderHome</jndi-name> </jonas-session> <!-- Entity Beans --> <!-- Message Driven Beans --> </jonas-ejb-jar>
I am certain, that there is no problem, am just missing some simple piece somewhere.
Thank you much;
-nat
Scott AndersonParticipantNat,
The problem you’re experiencing with Jonas is that unlike all other application servers we support, it will not automatically generate stub/skeleton code for your EJB’s when you deploy your application. That’s why you’re getting this:
* Deploy error : autoload/firstejb.jar
: java.lang.Exception: Cannot create Container: javax.ejb.EJBException: Trader Cannot load training.trader.interfaces.JOnASTrader227742157Home; nested exception is: java.lang.ClassNotFoundException: training.trader.interfaces.JOnASTrader227742157HomeThe only workaround is to use the Jonas-provided tools to manually generate those files outside of Eclipse and then import the Java files into your Eclipse project. Once in the project they’ll be packaged correctly into your deployment, but you’ll need to remember to regenerate them if your interfaces change.
nat101Member@support-scott wrote:
Nat,
The problem you’re experiencing with Jonas is that unlike all other application servers we support, it will not automatically generate stub/skeleton code for your EJB’s when you deploy your application. That’s why you’re getting this:
Humph! I feel lucky! Any hope for ME doing this soon?
The only workaround is to use the Jonas-provided tools to manually generate those files outside of Eclipse and then import the Java files into your Eclipse project.
To which folder do I import it to?
Once in the project they’ll be packaged correctly into your deployment, but you’ll need to remember to regenerate them if your interfaces change.
There must be a simply way via ANT to do this automatically.
Problem is I am not too well versed with Ant. Maybe I’ll get one of the Jonas folks to write it.Thank you much, and HNY;
-nat
Scott AndersonParticipantHumph! I feel lucky! Any hope for ME doing this soon?
Nothing on the product plans. We’re hoping the Jonas guys will join all the rest of the servers and fix this soon. Their users (like you) applying pressure on them is really what they need to address it.
To which folder do I import it to?
To the one the package declaration tells you to, of course. 🙂 From what you provided, the stubs need to be imported into a source folder under training.trader.interfaces
There must be a simply way via ANT to do this automatically.
Problem is I am not too well versed with Ant. Maybe I’ll get one of the Jonas folks to write it.I’m sure there is. In fact, Ant already has support in the EJB task. The doc is here:
http://jonas.objectweb.org/current/doc/ant-ejbjar.html
nat101MemberThank you much.
Since Jonas is the official Red Hat app server, (the redhat docs also helped me), I didn’t expect it to be difficult to deploy.Ah. I just thought of a new feature request for ME. A wizard to build ant scripts. Simply ask what I want to accomplish, source/destination directories, voila!
ta
-nat
Scott AndersonParticipantNat,
Ah. I just thought of a new feature request for ME. A wizard to build ant scripts.
Don’t know if this helps, but there’s another plugin called eclipse2ant that *might* help you a bit (or not). I’ve never used it so I can’t speak to its quality or anything else, but it’s available here: http://www.eclipse-plugins.info/eclipse/plugin_details.jsp?id=797
nat101MemberThanks.
-nat
nat101MemberCan you please open this again; I have GOOD news.
It i smuch simpler than:The only workaround is to use the Jonas-provided tools to manually generate those files outside of Eclipse and then import the Java files into your Eclipse project. Once in the project they’ll be packaged correctly into your deployment, but you’ll need to remember to regenerate them if your interfaces change.
Currently, all you have to do is run their utility genIC against the deployed ejb jar. Thats it. NO import and redeploy required. So, I drop into the ‘autodploy’ dir, (or from Eclipse RUN) and ONE command, “genic anyejb.jar” will automatically add the required stubs to the jar. Really much simpler that it looked like.
And now…. the problem. Huh? Yep. This solved the problem you addressed, namely the ‘class not found’, which is fixed and Jonas DOES deploy the file. BUT it still complains about ‘trans-attribute’ missing.
(evidently, the remaining 2 errors were not related.)
This looks like an application level error, and to quote it again:2004-12-30 15:54:53,203 : SessionDesc.checkTxAttribute : trans-attribute missing for method public abstract int training.trader.interfaces.Trader.buy(java.lang.String,int) throws java.rmi.RemoteException in session bean Trader (set to the default value Supports)
2004-12-30 15:54:53,203 : SessionDesc.checkTxAttribute : trans-attribute missing for method public abstract int training.trader.interfaces.Trader.sell(java.lang.String,int) throws java.rmi.RemoteException in session bean Trader (set to the default value Supports)Thanks again.
-nat
Scott AndersonParticipantNat,
The problem on the trans-attribute looks like a warning that one wasn’t found in either the ejb-jar.xml file or in the jonas-specific descriptor. As a result, Jonas is setting it to the default, which is “Supports”. To correct it, you’ll need to add the @ejb.transaction tags and regenerate the descriptors, as documented here: http://xdoclet.sourceforge.net/xdoclet/tags/ejb-tags.html#@ejb_transaction__0__1_
nat101MemberYes! After googling a bit:) I added:
@ejb.transaction type = "Never"
in the javadoc section of the buy and sell methods in the TraderBean.
Success!
Thank you!
-nat
ps. Um…yes you can close out the thread!
nat101MemberFair warning:) since thread not yet closed out…
We shall cover the j2ee client and ME… next year….
HNY!
-nat
Scott AndersonParticipantNat,
Sounds good. See you in the new year. 🙂
-
AuthorPosts