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 EJB and other Java EE Technologies and the fly likes Urgent J2EE deploytool help 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 » Java » EJB and other Java EE Technologies
Bookmark "Urgent J2EE deploytool help " Watch "Urgent J2EE deploytool help " New topic
Author

Urgent J2EE deploytool help

Edy Yu
Ranch Hand

Joined: Nov 21, 2000
Posts: 264
I am new to EJB.
I created a very simple CMP entity bean and tried to build the EJB by the deploy tool.
Here is the code:
1. Remote interface
package demo.xy.commands;
import java.rmi.*;
import javax.ejb.*;
/**
* Remote interface defines the business functions
* of this entity bean.
*/
public interface CommandsRemote extends EJBObject {
//Primary key
public Integer getId() throws RemoteException;
public void setId(Integer Id) throws RemoteException;
public String getName() throws RemoteException;
public void setName(String name) throws RemoteException;
}
2. Home interface
package demo.xy.commands;
import java.rmi.*;
import javax.ejb.*;
public interface CommandsHome extends EJBHome {
public CommandsRemote create(Integer id) throws CreateException, RemoteException;
public CommandsRemote findByPrimaryKey(Integer pk) throws FinderException, RemoteException;
}
3. Bean class
package demo.xy.commands;
import javax.ejb.*;
public abstract class CommandsBean implements EntityBean {
public Integer ejbCreate(Integer id) {
this.setId(id);
return null;
}
public void ejbPostCreate(Integer id) {
}
public abstract Integer getId();
public abstract void setId(Integer id);
public abstract String getName();
public abstract void setName(String name);
public void setEntityContext(EntityContext ctx) {
}
public void unsetEntityContext() {
}
public void ejbActivate() {
}
public void ejbPassivate() {
}
public void ejbLoad() {
}
public void ejbStore() {
}
public void ejbRemove() {
}
}

The following is the result I got by verifying my JAR using the "verify" function in the deploytool.

-------------------------------
FAILED TEST - EJB tests
-------------------------------
***********************************************************
Test Name: tests.ejb.entity.cmp2.CmpFieldAccessorModifiers
Test Assertion: EJB 2.0 Spec 9.4.1, cmp field accessors methods must be abstract, public or protected
Detailed Messages:
Error : [ set ] accessor method for field [ decription ] is not abstract and public or protected
***********************************************************
***********************************************************
Test Name: tests.ejb.entity.cmp2.CmpFieldsAccessorExposition
Test Assertion: EJB 2.0 Spec 9.4.11 Set Accessor method for primary key fields should not be exposed in the remote interface
Detailed Messages:
Error : Primary key field set accessor method [ roleId ] is exposed through the remote interface [ RoleRemote ]
***********************************************************
***********************************************************
Test Name: tests.ejb.entity.cmp2.CmpFieldAccessor
Test Assertion: EJB 2.0 Spec 9.4.1, cmp field accessors must bear the name of the field, first letter uppercased and prefixed with get and set
Detailed Messages:
Unexpected error in verifier, check for problems related to: [ java.lang.IllegalArgumentException: argument number too large at ]
***********************************************************

Can anybody tell me what is worng in my code?
Thanks in advance.


<i><br />Sun Certified Programmer for Java 2 Platform (SCJP)<br />Sun Certified Developer for Java 2 Platform (SCJD)<br />Sun Certified Web Component Developer for Java2 Platform, Enterprise Edition (SCWCD)<br />Sun Certified Business Component Developer for Java2 Platform, Enterprise Edition (SCBCD)<br />Sun Certified Enterprise Architect for J2EE (SCEA)<br />IBM Certified Enterprise Developer, WebSphere Studio V5.0<br /></i>
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
Hmm, wierd.
First of all, do you have a field called "decription" (notice the spelling here) in your deployment descriptor that you've removed from the actual implementation?
The roleId message is strange too. Certainly might be worth checking out your deployment descriptor(s) are referencing the same Java classes too.
Hope that helps - let us know how you get on.
Cheers
Simon
Edy Yu
Ranch Hand

Joined: Nov 21, 2000
Posts: 264
Hi Simon:
I believed I must mess up something.
I rebuild the JAR through the tool. Here is the new result.
Thanks,
Deployment Descriptor
<?xml version="1.0" encoding="Cp1252"?>
<!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>
<display-name>CommandBean</display-name>
<enterprise-beans>
<entity>
<display-name>CommandBean</display-name>
<ejb-name>CommandBean</ejb-name>
<home>demo.xy.commands.CommandsHome</home>
<remote>demo.xy.commands.CommandsRemote</remote>
<ejb-class>demo.xy.commands.CommandsBean</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>Commands</abstract-schema-name>
<cmp-field>
<description>no description</description>
<field-name>name</field-name>
</cmp-field>
<cmp-field>
<description>no description</description>
<field-name>id</field-name>
</cmp-field>
<primkey-field>id</primkey-field>
<security-identity>
<description></description>
<use-caller-identity></use-caller-identity>
</security-identity>
</entity>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>CommandBean</ejb-name>
<method-intf>Home</method-intf>
<method-name>create</method-name>
<method-params>
<method-param>java.lang.Integer</method-param>
</method-params>
</method>
<trans-attribute>NotSupported</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>CommandBean</ejb-name>
<method-intf>Home</method-intf>
<method-name>remove</method-name>
<method-params>
<method-param>java.lang.Object</method-param>
</method-params>
</method>
<trans-attribute>NotSupported</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>CommandBean</ejb-name>
<method-intf>Remote</method-intf>
<method-name>getId</method-name>
<method-params />
</method>
<trans-attribute>NotSupported</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>CommandBean</ejb-name>
<method-intf>Remote</method-intf>
<method-name>getName</method-name>
<method-params />
</method>
<trans-attribute>NotSupported</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>CommandBean</ejb-name>
<method-intf>Remote</method-intf>
<method-name>setId</method-name>
<method-params>
<method-param>java.lang.Integer</method-param>
</method-params>
</method>
<trans-attribute>NotSupported</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>CommandBean</ejb-name>
<method-intf>Remote</method-intf>
<method-name>remove</method-name>
<method-params />
</method>
<trans-attribute>NotSupported</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>CommandBean</ejb-name>
<method-intf>Home</method-intf>
<method-name>findByPrimaryKey</method-name>
<method-params>
<method-param>java.lang.Integer</method-param>
</method-params>
</method>
<trans-attribute>NotSupported</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>CommandBean</ejb-name>
<method-intf>Remote</method-intf>
<method-name>setName</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</method>
<trans-attribute>NotSupported</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>CommandBean</ejb-name>
<method-intf>Home</method-intf>
<method-name>remove</method-name>
<method-params>
<method-param>javax.ejb.Handle</method-param>
</method-params>
</method>
<trans-attribute>NotSupported</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>

Result.txt
-------------------------------
FAILED TEST - EJB tests
-------------------------------
***********************************************************
Test Name: tests.ejb.entity.cmp2.CmpFieldsAccessorExposition
Test Assertion: EJB 2.0 Spec 9.4.11 Set Accessor method for primary key fields should not be exposed in the remote interface
Detailed Messages:
Error : Primary key field set accessor method [ id ] is exposed through the remote interface [ demo.xy.commands.CommandsRemote ]
***********************************************************
-------------------------------
WARNING TEST - EJB tests
-------------------------------
There are no EJB tests tests with status of warning.
HanMing Low
Ranch Hand

Joined: Oct 18, 2001
Posts: 196
Hi,
As mentioned in the error, you should not have setId(Integer id)
in your remote interface because you should not allow client to change your primary key value.
In addition, you need to throw CreateException for create and ejbCreate.
And, where is your ejbFindByPrimaryKey?
You need to throw FinderException on it as well.
You might wish to refer to Richard-Monson "EJB" for example, but the examples are just not there yet.
You can refer to my previous post for a couple of changes to get it running in J2EE-RI.
http://www.coderanch.com/t/309559/EJB-JEE/java/Help-CMP-EE-RI
Cheers.

Han Ming
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Urgent J2EE deploytool help
 
Similar Threads
java.lang.NullPointerException: EJB 2.0
Help Requested --> Yep, it's a verifier message!
undifiend primary key
java.lang.NullPointerException: EJB 2.0
how to use finder methods with cmp?