Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Deployment of (CMP)Entity bean - Urgent....

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was able to deploy a CMP entity bean in Websphere.However once i try to run the client, instead of retrieving data from the table, the corresponding data gets updated i.e
Initial table data
EMPID NAME
E001 adsf
E002 qewr
On executing the client instead of getting the name corresponding to the EMPID entered, the NAME gets "updated" to E001 and my output is also E001.I'm using DB2 as my backend and using COM.ibm.db2.jdbc.app.DB2Driver as my driver.

Could anyone please help me out on this?Any reason why the bean doesn't behave the way it should.The same bean gives the required result when using Weblogic v 5.1.

 
Ranch Hand
Posts: 1871
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could you please post some code which will be helpful
 
PN Subramanian
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly, thanks for your response.
Attaching alongwith the code (bean.java ) file...
public class PersonalBean implements EntityBean {
protected EntityContext context;
public String EmpId;
public String Name;

public PersonalPrimary ejbCreate(String EmpId)
throws CreateException
{
this.EmpId=EmpId;
return null;//this return implies CMP
}

public void ejbPostCreate(String EmpId) {
//for any follow-up operations
}

public String getEmpName() {
try{
System.out.println("Entered getEmpName method");
}
catch(Exception e){
System.out.println("Exception in getEmpname() :"+e);
}
return Name;

}
public void ejbActivate() {
}

public void ejbPassivate() {
}

public void ejbLoad() {
}

public void ejbStore() {
}

public void ejbRemove()
throws RemoveException
{
}

public void setEntityContext(EntityContext context) {
this.context = context;
}

public void unsetEntityContext() {
this.context = null;
}
}
This is a CMP bean and the getEmpName() method is expected to return the name corresponding to the EMPID being hardcoded in the Client.java file.However, this method returns EMPID itself.
Could you please guide me on this.
Thanks in advance for your help.
 
Rahul Mahindrakar
Ranch Hand
Posts: 1871
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where are you setting the name in the create method. Your name field is "null".
 
PN Subramanian
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your prompt reply.
The ejbCreate method as in the Home interface has only one argument i.e EmpId.
Also, even when two arguments were included,with the corresponding changes to ejbPostCreate method and Home interface the same happens - the Name field getting updated in the table.
Looking forward to your assistance.

 
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Subramanian,
Please do let me know what happens when you try the following version :
<pre>
import java.rmi.RemoteException;
import javax.ejb.*;
public class PersonalBean implements EntityBean {
protected EntityContext context;
public String empId;
public String name;
public String getEmpId() throws RemoteException {
return empId;
}
public String getName() throws RemoteException {
return name;
}
public String setName(String name) throws Remote Exception {
this.name = name;
}
public void ejbCreate(String empId,String name) throws CreateException,RemoteException {
this.empId = empId;
this.name = name;
}
public void ejbPostCreate(String empId,String name) throws RemoteException {
}

public void ejbActivate() throws RemoteException {
}
public void ejbPassivate() throws RemoteException {
}
public void ejbLoad() throws RemoteException {
}

public void ejbStore() throws RemoteException {
}

public void ejbRemove() throws RemoveException,RemoteException {
}
public void setEntityContext(EntityContext context) throws RemoteException {
this.context = context;
}

public void unsetEntityContext() throws RemoteException {
this.context = null;
}
}
</pre>


Noted a few things in your code :

  1. Your getter method doesn't follow the standard naming convention.For instance, if you have an attribute as name, your getter method should be getName().
  2. Since you are going to call the getter method from the client, it should throw a RemoteException.
  3. Apart from the PK, it is a good practice to provide mutator (setter) method for the attributes.You would require it to update/set the name for corresponding empId.
  4. You should use ejbCreate(String,String) format.The format you used is advisable only if you donot know the name for the corresponding empId.Also, you need to initialize ALL the attributes of your bean.

  5. One of the above may be the reasons for your problem.I believe the problem arises due to Entity Bean not being mapped one-to-one with the respective DB fields.Providing proper getter/setter and ejbCreate() methods for the Bean attributes should resolve the problem.

    Let me know if the problem still persists.
    -- Sandeep
    [This message has been edited by Desai Sandeep (edited June 25, 2001).]
 
PN Subramanian
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sandeep,
Thanks for your reply.
As you had suggested i had run the code you had given.During deployment i got an exception
It says Deployment(Open) failed
This is followed by a few statements indicating that the ".ser" file was found etc....and an Exception statement like
com.ibm.ejs.sm.client.command.ExecutionException : Error during deploying jar file
com.ibm.ejs.sm.client.RepositoryOpException
com.ibm.ejs.sm.client.command.ExecutionException
com.ibm.ejs.sm.client.command.DeployJarCommand.execute
com.ibm.ejs.sm.client.command.CommandManager$ExecutionThread.run
I tried restarting the server too, but even then the response was the same.
Couldn't figure out the reason for such a behaviour.
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Subramanian,
The deployment error that you are getting may be due to the following reasons:

  1. Syntax errors in the DD file.
  2. Some of the name,value pairs not specified.
  3. Publishing name for the HomeObject may be incorrect.

  4. Let me know if you are still unable to resolve the problem after taking the above into account.It would be better if you could post the DD file also.
    - Sandeep
 
PN Subramanian
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai Sandeep,
Thanks for your response.
By the way, the DD file you are talking about - isn't it the deployment descriptor file?Here i am making use of jetace tool and there in the details regarding the bean are specified.
And the same gets written to a xml file by making use of File->Write XML option in the jetace tool.If this be the DD file, what could be the syntax errors in it as it is being generated by the jetace tool itself? I'm not quite sure whether this is what you mean by the DD file..Any way the following is the XML output of the jetace tool
Since it is a XML file i've replaced the "< " symbol with "[" here for easier understanding <br /> [?xml version='1.0' encoding="ISO-8859-1" ?>
[ejb-JAR>
[input-file>C:\Personal\JetIn.jar</input-file>
[output-file>C:\Personal\JetOutput.jar</output-file>
[entity-bean dname="test/dd.ser">
[primary-key>test.PersonalPrimary</primary-key>
[re-entrant value="false"/>
[container-managed>Name</container-managed>
[container-managed>EmpId</container-managed>
[home-interface>test.PersonalHome</home-interface>
[remote-interface>test.Personal</remote-interface>
[enterprise-bean>test.PersonalBean</enterprise-bean>
[jndi-name>test</jndi-name>
[transaction-attr value="TX_SUPPORTS"/>
[isolation-level value="READ_COMMITTED"/>
[run-as-mode value="SPECIFIED_IDENTITY"/>
[env-prop name="javax.naming.Context.INITIAL_CONTEXT_FACTORY" comment="">com.ibm.ejs.ns.jndi.CNInitialContextFactory</env-prop>
[env-prop name="JNDIName" comment="">test</env-prop>
[dependency comment="">test.Personal.class</dependency>
[dependency comment="">test.PersonalPrimary.class</dependency>
[dependency comment="">test.PersonalHome.class</dependency>
[dependency comment="">test.PersonalBean.class</dependency>
[/entity-bean>
[/ejb-JAR>
Isn't the JNDIName called the publishing name?It is the same one being specified in the Client.java file also.
Hope, these are what you had mentioned in your response.Please do respond if any of the above are unsatisfactory for the proper functioning of the bean.
Thanks once again for your response.

[This message has been edited by PN Subramanian (edited June 26, 2001).]
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Subramanian,
I am new to IBM Java products.I am conversant with Oracle Java products.That is reason,I am trying to use as generic names as possible, so that there is no ambiguity.Am sorry if I happened to confuse you.Yes, the DD is the Deployment Descriptor file and JNDI Name is the publishing name in the JNDI namespace.
For the Oracle Application Server (OAS 4.0.8.2a), I used to write the DD file myself.Earlier, it used to be text based (EJB 1.0), now it's XML based following the EJB 1.1 specification.
Coming back to the problem, there are couple of things I noted in the your DD file

  1. The CMP fields start with an upper-case.It should be name instead of Name and empId instead of EmpId.I am not sure why your tool is generating the first letter in uppercase!
  2. If you have followed my version of PersonalBean, and if your <primary-key> is mapped to PersonalPrimary, then probably your tool might require a change to the return type of ejbCreate() to PersonalPrimary.You may need to make the following change to the method.
    <pre>
    public PersonalPrimary ejbCreate(String empId,String name) throws CreateException,RemoteException {
    this.empId = empId;
    this.name = name;
    return null;
    }
    </pre>

    However, I donot think this would be required.

  3. If you still face problems, please post all the components.We will try and crack it.
    -- Sandeep
    [This message has been edited by Desai Sandeep (edited June 26, 2001).]
 
Hang a left on main. Then read this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic