Discussion:
[Middlegen-user] Error Deploying beans with relationships to weblogic
Ben Litchfield
2003-10-05 13:37:02 UTC
Permalink
Has anybody been able to deploy to weblogic? I am using local entity
beans and the local facade pattern.

The application deploys but when I try to create beans with relationships
I get the following error

javax.ejb.EJBException: [EJB:010145]When a cmp-field and a cmr-field
(relationship) are mapped to the same column, the setXXX method for the
cmp-field may not be called. The cmp-field is read-only.

The generated code looks like this and bombs on the setVendorId call.

public java.lang.Integer ejbCreate(slims.entity.TitleLightValue value)
throws javax.ejb.CreateException {
// Use Middlegen's Sequence Block PK generator. Only works for
numeric fields
try {
slims.entity.SequenceSession sequenceGenerator =
slims.entity.SequenceSessionUtil.getLocalHome().create();
setTitleId(new
java.lang.Integer(Integer.toString(sequenceGenerator.getNextSequenceNumber(
"title.title_id" ))));
} catch( javax.naming.NamingException e ) {
throw new javax.ejb.CreateException(e.getMessage());
}
setVendorId(value.getVendorId());
setName(value.getName());
// EJB 2.0 spec says return null for CMP ejbCreate methods.
return null;
}

/**
* The container invokes this method immediately after it calls
ejbCreate.
*
* @param value the value object used to initialise the new instance
*/
public void ejbPostCreate(slims.entity.TitleLightValue value) throws
javax.ejb.CreateException {
}


Any help would be great.
Higdon, Brian [VIS-Non J&J]
2003-10-06 10:28:15 UTC
Permalink
I had something similar over the weekend and this is what I found.

Let's say there is a table called 'Asset_Type' with a primary key called
'Asset_type_cd'. Then you have a foreign key from another table, let's say
'Asset' which uses the asset_type_cd field to get the related asset_type.
This should work fine.

Now let's say that instead of calling the table 'Asset_type' you goof (like
I did) and call it 'Asset_type_cd' with a primary key of 'Asset_type_cd'.
Then when the attempt is to made to create the FK relationship, their is a
clash in the names and that is most likely what your problem is. Just
rename either your table or the primary key of the table and all the FKs
that refer to it and you should be fine.

BTW, yes, I have deployed to Weblogic 7 and things work fine. My problem
now is I have ~120 tables which results in ~620 files in my jar file and
weblogic.ejbc fails on an OutOfMemory error regardless of my ms/mx
parameters.

HTH

-----Original Message-----
From: Ben Litchfield [mailto:***@csh.rit.edu]
Sent: Sunday, October 05, 2003 11:36 AM
To: middlegen-***@lists.sourceforge.net
Subject: [Middlegen-user] Error Deploying beans with relationships to
weblogic



Has anybody been able to deploy to weblogic? I am using local entity
beans and the local facade pattern.

The application deploys but when I try to create beans with relationships
I get the following error

javax.ejb.EJBException: [EJB:010145]When a cmp-field and a cmr-field
(relationship) are mapped to the same column, the setXXX method for the
cmp-field may not be called. The cmp-field is read-only.

The generated code looks like this and bombs on the setVendorId call.

public java.lang.Integer ejbCreate(slims.entity.TitleLightValue value)
throws javax.ejb.CreateException {
// Use Middlegen's Sequence Block PK generator. Only works for
numeric fields
try {
slims.entity.SequenceSession sequenceGenerator =
slims.entity.SequenceSessionUtil.getLocalHome().create();
setTitleId(new
java.lang.Integer(Integer.toString(sequenceGenerator.getNextSequenceNumber(
"title.title_id" ))));
} catch( javax.naming.NamingException e ) {
throw new javax.ejb.CreateException(e.getMessage());
}
setVendorId(value.getVendorId());
setName(value.getName());
// EJB 2.0 spec says return null for CMP ejbCreate methods.
return null;
}

/**
* The container invokes this method immediately after it calls
ejbCreate.
*
* @param value the value object used to initialise the new instance
*/
public void ejbPostCreate(slims.entity.TitleLightValue value) throws
javax.ejb.CreateException {
}


Any help would be great.



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Ben Litchfield
2003-10-06 22:51:04 UTC
Permalink
Thanks for the reply but none of my table names match columns in them.
This is a bidirectional one-many relationship. Did you have to set
anything in the gui to get it to work? I left everything as the default.

Any other thoughts on what it might be?

Ben
Post by Higdon, Brian [VIS-Non J&J]
I had something similar over the weekend and this is what I found.
Let's say there is a table called 'Asset_Type' with a primary key called
'Asset_type_cd'. Then you have a foreign key from another table, let's say
'Asset' which uses the asset_type_cd field to get the related asset_type.
This should work fine.
Now let's say that instead of calling the table 'Asset_type' you goof (like
I did) and call it 'Asset_type_cd' with a primary key of 'Asset_type_cd'.
Then when the attempt is to made to create the FK relationship, their is a
clash in the names and that is most likely what your problem is. Just
rename either your table or the primary key of the table and all the FKs
that refer to it and you should be fine.
BTW, yes, I have deployed to Weblogic 7 and things work fine. My problem
now is I have ~120 tables which results in ~620 files in my jar file and
weblogic.ejbc fails on an OutOfMemory error regardless of my ms/mx
parameters.
HTH
-----Original Message-----
Sent: Sunday, October 05, 2003 11:36 AM
Subject: [Middlegen-user] Error Deploying beans with relationships to
weblogic
Has anybody been able to deploy to weblogic? I am using local entity
beans and the local facade pattern.
The application deploys but when I try to create beans with relationships
I get the following error
javax.ejb.EJBException: [EJB:010145]When a cmp-field and a cmr-field
(relationship) are mapped to the same column, the setXXX method for the
cmp-field may not be called. The cmp-field is read-only.
The generated code looks like this and bombs on the setVendorId call.
public java.lang.Integer ejbCreate(slims.entity.TitleLightValue value)
throws javax.ejb.CreateException {
// Use Middlegen's Sequence Block PK generator. Only works for
numeric fields
try {
slims.entity.SequenceSession sequenceGenerator =
slims.entity.SequenceSessionUtil.getLocalHome().create();
setTitleId(new
java.lang.Integer(Integer.toString(sequenceGenerator.getNextSequenceNumber(
"title.title_id" ))));
} catch( javax.naming.NamingException e ) {
throw new javax.ejb.CreateException(e.getMessage());
}
setVendorId(value.getVendorId());
setName(value.getName());
// EJB 2.0 spec says return null for CMP ejbCreate methods.
return null;
}
/**
* The container invokes this method immediately after it calls
ejbCreate.
*
*/
public void ejbPostCreate(slims.entity.TitleLightValue value) throws
javax.ejb.CreateException {
}
Any help would be great.
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
Higdon, Brian [VIS-Non J&J]
2003-10-07 09:46:04 UTC
Permalink
Not sure off hand, but here are a couple of things to look at:

1. Make sure the relationship between the tables is specified in the "right"
direction. Should it be the reverse of what you have?

2. If you are creating your tables by hand, I would try using a tool like:
http://www.casestudio.com/ The tool is free to use and you can design all
the tables you want in it, however you can only save a model with five
tables in it in the "free" version. Anyway, this could help you work any
issues with the data model. BTW, it has very nice reverse engineering
capability for any db you can think of so you can reverse out what you have
now, make sure it looks right, correct it, whatever. Oh, and of course it
will generate all the DDL for the (re)creation of your tables and
relationships.

3. As far as the GUI goes, when I use it for the first time on a new model,
I tend to turn off the remote references for the tables and turn on the
local references if it is not already done (white x in the box means on,
grayed out x means?? and the no x means completely off.) The relationships
among tables should be solid black lines. Clicking them turns this off. If
the PK/FK relations are set correctly in the db, the default that comes up
should be correct in the GUI. BTW, all this can be done via the GUI, but
when you have lots of tables, it gets to be a mess. There is a <your jar
file>.properties file which has all this information in it that you can edit
by hand if you are so inclined. It allows you to make changes very quickly.

4. For those of you who may have read this thread, I mentioned that I had
~120 tables and was having trouble ejbc'ing in WLS 7. I kept having
OutOfMemory problems. Anyway, I switched to WLS 8.1 and it works like a
charm now; no problems whatsoever.

Brian

-----Original Message-----
From: Ben Litchfield [mailto:***@csh.rit.edu]
Sent: Monday, October 06, 2003 8:50 PM
To: 'middlegen-***@lists.sourceforge.net'
Subject: RE: [Middlegen-user] Error Deploying beans with relationships
to weblogic


Thanks for the reply but none of my table names match columns in them.
This is a bidirectional one-many relationship. Did you have to set
anything in the gui to get it to work? I left everything as the default.

Any other thoughts on what it might be?

Ben
Post by Higdon, Brian [VIS-Non J&J]
I had something similar over the weekend and this is what I found.
Let's say there is a table called 'Asset_Type' with a primary key called
'Asset_type_cd'. Then you have a foreign key from another table, let's
say
Post by Higdon, Brian [VIS-Non J&J]
'Asset' which uses the asset_type_cd field to get the related asset_type.
This should work fine.
Now let's say that instead of calling the table 'Asset_type' you goof
(like
Post by Higdon, Brian [VIS-Non J&J]
I did) and call it 'Asset_type_cd' with a primary key of 'Asset_type_cd'.
Then when the attempt is to made to create the FK relationship, their is a
clash in the names and that is most likely what your problem is. Just
rename either your table or the primary key of the table and all the FKs
that refer to it and you should be fine.
BTW, yes, I have deployed to Weblogic 7 and things work fine. My problem
now is I have ~120 tables which results in ~620 files in my jar file and
weblogic.ejbc fails on an OutOfMemory error regardless of my ms/mx
parameters.
HTH
-----Original Message-----
Sent: Sunday, October 05, 2003 11:36 AM
Subject: [Middlegen-user] Error Deploying beans with relationships to
weblogic
Has anybody been able to deploy to weblogic? I am using local entity
beans and the local facade pattern.
The application deploys but when I try to create beans with relationships
I get the following error
javax.ejb.EJBException: [EJB:010145]When a cmp-field and a cmr-field
(relationship) are mapped to the same column, the setXXX method for the
cmp-field may not be called. The cmp-field is read-only.
The generated code looks like this and bombs on the setVendorId call.
public java.lang.Integer ejbCreate(slims.entity.TitleLightValue value)
throws javax.ejb.CreateException {
// Use Middlegen's Sequence Block PK generator. Only works for
numeric fields
try {
slims.entity.SequenceSession sequenceGenerator =
slims.entity.SequenceSessionUtil.getLocalHome().create();
setTitleId(new
java.lang.Integer(Integer.toString(sequenceGenerator.getNextSequenceNumber(
Post by Higdon, Brian [VIS-Non J&J]
"title.title_id" ))));
} catch( javax.naming.NamingException e ) {
throw new javax.ejb.CreateException(e.getMessage());
}
setVendorId(value.getVendorId());
setName(value.getName());
// EJB 2.0 spec says return null for CMP ejbCreate methods.
return null;
}
/**
* The container invokes this method immediately after it calls
ejbCreate.
*
*/
public void ejbPostCreate(slims.entity.TitleLightValue value) throws
javax.ejb.CreateException {
}
Any help would be great.
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

Loading...