For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub
- This topic has 5 replies, 2 voices, and was last updated 20 years, 2 months ago by
Glenn Puckett.
-
AuthorPosts
-
Glenn PuckettParticipantI have started my first J2EE project using myEclipse. I have been working through the EJB Quickstart and the Web Development with MyEclipse and JBoss tutorials. Instead of using the examples as stated in the tutorials I have been trying to apply it to my real world situation. As I am going I have been taking very small baby steps to minimize the complications.
I am using Eclipse SDK v3.1.2, myEclipse v4.1.1, jBoss v4.0.2 and mySQL v5.0.20
I first built a simple struts architecture utilizing the form, action, JSP wizard and then added a couple extra html and jsp modules with appropriate links and actions. Once I got this tested out and working I created a session bean. After getting the session bean working and talking to my servlet I then started on a CMP entity bean with the anticipation of accessing a table on the mySQL database. This is where I have run into a brick wall.
I have tried a little of everything over the past several days and can’t get the latest code to deploy in jBoss. According to the tutorials everything is as it should be. Also I have tried just about everything I can to make it work. Nothing seems to help.
Here is the xDoclet code from my entity bean:
* @ejb.bean name="Parcel" * display-name="ParcelBean" * description="Entity Bean for the Parcel Table" * jndi-name="Parcel" * type="CMP" * cmp-version="2.x" * view-type="local" * schema="metaTEST" * cmp-field="ID" * cmp-field="mapRtgNbr" * cmp-field="acctNum" * cmp-field="alphaClass" * cmp-field="propType" * cmp-field="lotSize" * primkey-field="ID" * primkey-class="java.lang.Integer" * @jboss.persistence * create-table="false" * remove-table="false" * table-name="parcel_tbl" * @ejb.finder * query="select object(p) from Parcel as p where p.mapRtgNbr == ?1" * signature="com.metaTEST.ejb.ParcelLocal getParcel(java.lang.String mapRtgNbr)" * description="Get an entry from the Parcel Table"And the following code is also in the entity bean:
/** * @ejb.interface-method view-type="both" * * @return */ public abstract Object getData(); /** * @ejb.interface-method view-type="both" * * @param name */ public abstract void setData(Object pData); /** * @ejb.interface-method view-type="both" * @ejb.permission column-name = "ID" unchecked="" * @ejb.pk-field * @return */ public abstract Integer getID(); /** * @ejb.interface-method view-type="both" * @param id */ public abstract void setID(Integer id); /** * @ejb.interface-method view-type="both" * @ejb.permission column-name = "maprtgnbr" unchecked="" * @return */ public abstract String getMapRtgNbr(); /** * @ejb.interface-method view-type="both" * @param mapRtgNbr */ public abstract void setMapRtgNbr(String mapRtgNbr); /** * @ejb.interface-method view-type="both" * @ejb.permission column-name = "acctnum" unchecked="" * @return */ public abstract String getAcctNum(); /** * @ejb.interface-method view-type="both" * @param acctNum */ public abstract void setAcctNum(String acctNum); /** * @ejb.interface-method view-type="both" * @ejb.permission column-name = "alpha_class" unchecked="" * @return */ public abstract String getAlphaClass(); /** * @ejb.interface-method view-type="both" * @param alphaClass */ public abstract void setAlphaClass(String alphaClass); /** * @ejb.interface-method view-type="both" * @ejb.permission column-name = "prop_type" unchecked="" * @return */ public abstract String getPropType(); /** * @ejb.interface-method view-type="both" * @param propType */ public abstract void setPropType(String propType); /** * @ejb.interface-method view-type="both" * @ejb.permission column-name = "tot_lot_size" unchecked="" * @return */ public abstract float getLotSize(); /** * @ejb.interface-method view-type="both" * @param lotSize */ public abstract void setLotSize(float lotSize);I have used several variations of this code. You will notice the presence of the cmp-field entries. There was no difference in the xml files with those in or out. I also had to add in the unchecked=”” to prevent xml validation errors. The generated ejb-jar.xml file contains:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd"> <ejb-jar > <description><![CDATA[No Description.]]></description> <display-name>Generated by XDoclet</display-name> <enterprise-beans> <!-- Session Beans --> <session > <description><![CDATA[Session bean for access to TEST data]]></description> <display-name>CammaAccess session bean</display-name> <ejb-name>TESTAccess</ejb-name> <home>com.metaTEST.interfaces.TESTAccessHome</home> <remote>com.metaTEST.interfaces.TESTAccess</remote> <local-home>com.metaTEST.interfaces.TESTAccessLocalHome</local-home> <local>com.metaTEST.interfaces.TESTAccessLocal</local> <ejb-class>com.metaTEST.ejb.TESTAccessSession</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> </session> <!-- To add session beans that you have deployment descriptor info for, add a file to your XDoclet merge directory called session-beans.xml that contains the <session></session> markup for those beans. --> <!-- Entity Beans --> <entity > <description><![CDATA[Entity Bean for the Parcel Table]]></description> <display-name>Parcel Table Entity Bean</display-name> <ejb-name>Parcel</ejb-name> <local-home>com.metaTEST.interfaces.ParcelLocalHome</local-home> <local>com.metaTEST.interfaces.ParcelLocal</local> <ejb-class>com.metaTEST.ejb.ParcelCMP</ejb-class> <persistence-type>Container</persistence-type> <prim-key-class>java.lang.Integer</prim-key-class> <reentrant>False</reentrant> <cmp-version>2.x</cmp-version> <abstract-schema-name>metaTEST</abstract-schema-name> <primkey-field>ID</primkey-field> <query> <description><![CDATA[Get an entry from the Parcel Table]]></description> <query-method> <method-name>getParcel</method-name> <method-params> <method-param>java.lang.String</method-param> </method-params> </query-method> <ejb-ql><![CDATA[select object(p) from Parcel as p where p.mapRtgNbr == ?1]]></ejb-ql> </query> <!-- Write a file named ejb-finders-ParcelBean.xml if you want to define extra finders. --> </entity> <!-- To add entity beans that you have deployment descriptor info for, add a file to your XDoclet merge directory called entity-beans.xml that contains the <entity></entity> markup for those beans. --> <!-- Message Driven Beans --> <!-- To add message driven beans that you have deployment descriptor info for, add a file to your XDoclet merge directory called message-driven-beans.xml that contains the <message-driven></message-driven> markup for those beans. --> </enterprise-beans> <!-- Relationships --> <!-- Assembly Descriptor --> <!-- To specify your own assembly descriptor info here, add a file to your XDoclet merge directory called assembly-descriptor.xml that contains the <assembly-descriptor></assembly-descriptor> markup. --> <assembly-descriptor > <!-- To specify additional security-role elements, add a file in the merge directory called ejb-security-roles.xml that contains them. --> <!-- method permissions --> <!-- To specify additional method-permission elements, add a file in the merge directory called ejb-method-permissions.ent that contains them. --> <method-permission > <description><![CDATA[description not supported yet by ejbdoclet]]></description> <unchecked/> <method > <description><![CDATA[]]></description> <ejb-name>Parcel</ejb-name> <method-intf>Local</method-intf> <method-name>getID</method-name> <method-params> </method-params> </method> </method-permission> <method-permission > <description><![CDATA[description not supported yet by ejbdoclet]]></description> <unchecked/> <method > <description><![CDATA[]]></description> <ejb-name>Parcel</ejb-name> <method-intf>Remote</method-intf> <method-name>getID</method-name> <method-params> </method-params> </method> </method-permission> <method-permission > <description><![CDATA[description not supported yet by ejbdoclet]]></description> <unchecked/> <method > <description><![CDATA[]]></description> <ejb-name>Parcel</ejb-name> <method-intf>Local</method-intf> <method-name>getMapRtgNbr</method-name> <method-params> </method-params> </method> </method-permission> <method-permission > <description><![CDATA[description not supported yet by ejbdoclet]]></description> <unchecked/> <method > <description><![CDATA[]]></description> <ejb-name>Parcel</ejb-name> <method-intf>Remote</method-intf> <method-name>getMapRtgNbr</method-name> <method-params> </method-params> </method> </method-permission> <method-permission > <description><![CDATA[description not supported yet by ejbdoclet]]></description> <unchecked/> <method > <description><![CDATA[]]></description> <ejb-name>Parcel</ejb-name> <method-intf>Local</method-intf> <method-name>getAcctNum</method-name> <method-params> </method-params> </method> </method-permission> <method-permission > <description><![CDATA[description not supported yet by ejbdoclet]]></description> <unchecked/> <method > <description><![CDATA[]]></description> <ejb-name>Parcel</ejb-name> <method-intf>Remote</method-intf> <method-name>getAcctNum</method-name> <method-params> </method-params> </method> </method-permission> <method-permission > <description><![CDATA[description not supported yet by ejbdoclet]]></description> <unchecked/> <method > <description><![CDATA[]]></description> <ejb-name>Parcel</ejb-name> <method-intf>Local</method-intf> <method-name>getAlphaClass</method-name> <method-params> </method-params> </method> </method-permission> <method-permission > <description><![CDATA[description not supported yet by ejbdoclet]]></description> <unchecked/> <method > <description><![CDATA[]]></description> <ejb-name>Parcel</ejb-name> <method-intf>Remote</method-intf> <method-name>getAlphaClass</method-name> <method-params> </method-params> </method> </method-permission> <method-permission > <description><![CDATA[description not supported yet by ejbdoclet]]></description> <unchecked/> <method > <description><![CDATA[]]></description> <ejb-name>Parcel</ejb-name> <method-intf>Local</method-intf> <method-name>getPropType</method-name> <method-params> </method-params> </method> </method-permission> <method-permission > <description><![CDATA[description not supported yet by ejbdoclet]]></description> <unchecked/> <method > <description><![CDATA[]]></description> <ejb-name>Parcel</ejb-name> <method-intf>Remote</method-intf> <method-name>getPropType</method-name> <method-params> </method-params> </method> </method-permission> <method-permission > <description><![CDATA[description not supported yet by ejbdoclet]]></description> <unchecked/> <method > <description><![CDATA[]]></description> <ejb-name>Parcel</ejb-name> <method-intf>Local</method-intf> <method-name>getLotSize</method-name> <method-params> </method-params> </method> </method-permission> <method-permission > <description><![CDATA[description not supported yet by ejbdoclet]]></description> <unchecked/> <method > <description><![CDATA[]]></description> <ejb-name>Parcel</ejb-name> <method-intf>Remote</method-intf> <method-name>getLotSize</method-name> <method-params> </method-params> </method> </method-permission> <!-- transactions --> <!-- To specify additional container-transaction elements, add a file in the merge directory called ejb-container-transactions.ent that contains them. --> <!-- finder transactions --> <!-- message destinations --> <!-- To specify additional message-destination elements, add a file in the merge directory called ejb-message-destinations.ent that contains them. --> <!-- exclude list --> <!-- To specify an exclude-list element, add a file in the merge directory called ejb-exclude-list.xml that contains it. --> </assembly-descriptor> </ejb-jar>When I deploy to jBoss I get the message “Error in ejb-jar.xml for Entity Bean Parcel: primkey-field ID is not a cmp-field . . .” I have researched this for days now and have come across what looks like potential fixes to the xml. However, in order to achive a valid fix it appears to me I have to get the XDoclet parameters configured properly. What am I missing? What do I need to do?
I assume I could switch to a BMP entity bean and code all the SQL access myself. That is my next step if I can’t get a working answer. I would much rather utilize CMP at this point, but I am running out of time for this phase of the development.
Thanks,
Glenn Puckett
MetaMAP, Inc.
Lexington, KyJune 15, 2006 at 12:02 am #253498
Riyad KallaMemberAs I am going I have been taking very small baby steps to minimize the complications.
I am using Eclipse SDK v3.1.2, myEclipse v4.1.1, jBoss v4.0.2 and mySQL v5.0.20
Good approach and good setup, everything looks ok.
Ok XDoclet isn’t my forte, but let’s see if we can figure something out. I was checking out the @ejb doclet information on the XDoclet site (helpful ref: http://xdoclet.sf.net) and came across this:
http://xdoclet.sourceforge.net/xdoclet/tags/ejb-tags.html#@ejb_pk-field__0__1_It looks like if you want to use the pk-field tag, which you do on your ID field, you also have to add and use the entitypk subtask which is defined here: http://xdoclet.sourceforge.net/xdoclet/ant/xdoclet/modules/ejb/entity/EntityPkSubTask.html
I’m not sure if we flag that class with some CMP-specific flag or if it’s smart enough to know that the type is container managed in which case the PK will be a cmp-field.
June 15, 2006 at 6:33 am #253505
Glenn PuckettParticipant@support-rkalla wrote:
As I am going I have been taking very small baby steps to minimize the complications.
I am using Eclipse SDK v3.1.2, myEclipse v4.1.1, jBoss v4.0.2 and mySQL v5.0.20
Good approach and good setup, everything looks ok.
Ok XDoclet isn’t my forte, but let’s see if we can figure something out. I was checking out the @ejb doclet information on the XDoclet site (helpful ref: http://xdoclet.sf.net) and came across this:
http://xdoclet.sourceforge.net/xdoclet/tags/ejb-tags.html#@ejb_pk-field__0__1_It looks like if you want to use the pk-field tag, which you do on your ID field, you also have to add and use the entitypk subtask which is defined here: http://xdoclet.sourceforge.net/xdoclet/ant/xdoclet/modules/ejb/entity/EntityPkSubTask.html
I’m not sure if we flag that class with some CMP-specific flag or if it’s smart enough to know that the type is container managed in which case the PK will be a cmp-field.
Thanks for your response.
I do have the entitypk subtask active for this project. At least when I go to Properties, MyEclipse-XDoclet I have Standard-EJB active and in the subtask list entitypk is there and checked. However, none of the options are selected. Looking at the referenced documentation none of those options are required for that subtask to function. However, I AM NOT getting a generated primary key class for this entity bean.
I am using the @ebj.pk-field specification. It is on the getID method. Is that the proper place?
/** * @ejb.interface-method view-type="both" * @ejb.permission column-name = "ID" unchecked="" * @ejb.pk-field * @return */ public abstract Integer getID(); /** * @ejb.interface-method view-type="both" * @param id */ public abstract void setID(Integer id);From all the reading I have done I feel like I am very close on this. It appears I have possibly two issues. They are:
-
1. The primary key class is not being generated
2. The cmp fields are not being added to the ejb-jar.xml file even though I am using the cmp-field of the @ejb.bean task.Is there more that I just don’t know about? How can I make these two activities happen?[/list]
June 16, 2006 at 3:18 pm #253560
Glenn PuckettParticipantI had to discover this one by accident. The pk-field has to be the first getter and setter in the class after the constructor or the XDoclet WILL NOT generate properly. In the 3 part tutorial titled “Web Development with MyEclipse and JBoss” part 2 describes building 2 entity EJBs. It provides the details of the Inventory ejb and then just gives the list of the Item ejb. I was using the Item ejb as the template. It is NOT right. The Inventory ejb has the itemId field in the proper place. The Item ejb has the getData and setData methods as the first getter/setter in the class. As soon as I moved the getPartId() and setPartId() before the getData/setData methods everything generated just fine.
I cannot find this described anywhere. However, there is just far too much information to search through to encounter that. I’m sure the pro’s at myEclipse do this automatically. Newbee’s such as myself have no idea this is necessary.
June 16, 2006 at 6:49 pm #253569
Riyad KallaMemberGlenn,
I’m sorry you had to pull out so much hair to figure this entire process out. To be honest in our work, especially when dealing with enterprise customers, we have seen *so many* development houses move to either a Spring-based solution, Spring-Hibernate, (few iBatis) and even EJB3 solutions just to get away from thsi nightmare of XDoclet artifact generation.In my limited experience with Hibernate annotations and EJB3, you go from the brink of suicide, to piling through persiistence code fairly painlessly, it’s pretty nice.
I don’t know where you are in the project or how feasbile those options are, I just wanted to pass that on as reading this thread and not knowing what to suggest was a painful experience.
June 19, 2006 at 4:58 am #253617
Glenn PuckettParticipant@support-rkalla wrote:
Glenn,
I’m sorry you had to pull out so much hair to figure this entire process out. To be honest in our work, especially when dealing with enterprise customers, we have seen *so many* development houses move to either a Spring-based solution, Spring-Hibernate, (few iBatis) and even EJB3 solutions just to get away from thsi nightmare of XDoclet artifact generation.In my limited experience with Hibernate annotations and EJB3, you go from the brink of suicide, to piling through persiistence code fairly painlessly, it’s pretty nice.
I don’t know where you are in the project or how feasbile those options are, I just wanted to pass that on as reading this thread and not knowing what to suggest was a painful experience.
Thanks for the feedback. Actually this is a brand new project. And I do anticipate moving to Hibernate as quickly as possible. But I have so much to learn going I am trying to go a manageable bit at a time. The first release of this project is a small inquiry only interface to current data. My plans are to implement using Struts and CMP EJBs for the first release. Then move to something like Spring-Hibernate and EJB3 for the main development later this summer.
Actually I think the XDoclet concept is great. However, I am finding that there really is not an easy resource for learning how to apply it directly in our environment. It’s one thing to dig into the spec and learn about XDoclet and another to figure out how to apply it to developing in the myEclipse environment. If someone really knowledgable with the two had the time to put together an “How-To” it would be great for us novices. I have to forge forward with this development and don’t have the time for researching all the concepts.
myEclipse is great. It’s the first IDE I have used that works from start to end when going through the tutorials. Every other J2EE product I have tried I couldn’t get through the tutorials error free. We are a small shop and don’t have the resources for a month of classes to learn how to use these products.
Thanks again,
Glenn Puckett
-
AuthorPosts
