Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Urgent J2EE deploytool help

 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
https://coderanch.com/t/309559/EJB-JEE/java/Help-CMP-EE-RI
Cheers.

Han Ming
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic