File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes CMP EJB Getters/Setters already defined error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "CMP EJB Getters/Setters already defined error" Watch "CMP EJB Getters/Setters already defined error" New topic
Author

CMP EJB Getters/Setters already defined error

Tom Griffith
Ranch Hand

Joined: Aug 06, 2004
Posts: 272
Hello. If somebody has a minute, I am really frustrated on this one. What I am close to setting up here is a stateless session wrapping two entities...the first entity obtains/creates two values...it derives a sequential tracking number from the database and creates a unique primary key. The second entity does an insert based on 65 or so other fields that are passed to it along with the new tracking number and the primary key. The trigger for the stateless session ejb will be a submit from a frontend form.

The first entity that obtains the control number works fine wrapped in the session. Now when I go to compile the session with ~both~ entities, I get an error on the getter/setter method for ~most~ of the database fields in the insert entity. But not all of the fields...the control number that I derived via the first entity is fine, as well as the unid field, which is derived from the UUID class in the first entity and serves as the primary key. However, the error occurs on the fields that are passed via the form submit and subsequently through parameter method calls. Here is a chopped down version of the insert entity bean...the unid and control number are generated via the first entity and the c_subject field is passed from the form. I get the getter/setter already defined error in this bean class on the c_subject field. As a test, I compiled this class as a stand-alone and it compiles fine. Any help is greatly appreciated...thank you so much for reading this.

package com.cn;
import java.util.Collection;
import javax.ejb.*;

import java.io.*;

import java.util.*;

import javax.naming.*;

public abstract class CnInsertBean implements EntityBean
{
abstract public String getUnid();
public abstract void setUnid( String value );

abstract public String getControl_no();
public abstract void setControl_no( String value );

abstract public String getC_subject();
public abstract void setC_subject( String value );

public EntityContext ctx;

public void setEntityContext(EntityContext ctx) {
this.ctx = ctx;
}
public void unsetEntityContext() {
this.ctx = null;
}
// THE EJB METHODS TO HANDLE ROWS

public String ejbCreate()
throws CreateException {
return null;
}
public String ejbCreate(String unid,
String control_no,
String c_subject) throws CreateException {

setUnid( unid );
setControl_no( control_no );
setC_subject( c_subject );

return unid;}

public void ejbPostCreate(String unid,
String control_no,
String c_subject) {
}
public CnInsertBean() {}

public void ejbActivate() {}
public void ejbPassivate() {}
public void ejbLoad() {}
public void ejbStore() {}
public void ejbRemove() throws RemoveException {}
}
[ April 07, 2005: Message edited by: Tom Griffith ]
Tom Griffith
Ranch Hand

Joined: Aug 06, 2004
Posts: 272
just a little more information or whatever...this is the entity in my ejb descriptor...

<entity>
<ejb-name>CnInsertBean</ejb-name>
<jndi-name>CnInsertBean</jndi-name>
<local-home>com.cn.CnInsertHome</local-home>
<local>com.cn.CnInsert</local>
<ejb-class>com.cn.CnInsertBean</ejb-class>

<prim-key-class>String</prim-key-class>
<primkey-field>unid</primkey-field>

<persistence-type>Container</persistence-type>
<reentrant>True</reentrant>

<abstract-schema-name>data_table</abstract-schema-name>
<sql-table>data_table</sql-table>

<cmp-field>
<field-name>unid</field-name>
</cmp-field>

<cmp-field>
<field-name>control_no</field-name>
</cmp-field>

<cmp-field>
<field-name>c_subject</field-name>
</cmp-field>


</entity>
Tom Griffith
Ranch Hand

Joined: Aug 06, 2004
Posts: 272
ok...this is really bizarre. I have been slipping different CMP fields in for the third getter/setter (the c_subject column insert in the code above). I get this "Already defined" error on the getter/setter whenever the column name incorporates one letter followed an underscore...in my case, I have three fields...

c_subject
p_sort
s_sort

All other field names I toss in there, so far, have no problems. I'm going to keep messing wiht this.
Tom Griffith
Ranch Hand

Joined: Aug 06, 2004
Posts: 272
yep, I have one other field with the one letter followed by an underscore format...

a_ad_instr

and it gives me the error. I have another field, ad_instr, which compiles fine. I've tested about 40 fields and all compile except for these four with the single letter and underscore. I'm convinced this has to be something with how this ejb compiler parses values (resin 3.0.11). I think I will e-mail caucho or whatever with this...but it's here if somebody else comes across this quirk.

I'm not sure what to do here...if I change the column names on these four, then I have to drop the table, redo the data migration, then change all the setters/getters and fields in all the beans and jsps (not to mention the javascript routines). Heavy burden. I guess I'll have to do jdbc for the insert part...but I really wanted to do this via entity since I already have CMP. Anyone know of a way to mask the true column name in CMP and map to it from a phony?
[ April 07, 2005: Message edited by: Tom Griffith ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: CMP EJB Getters/Setters already defined error