Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

J2EE CMP RosterApp sample and DB2

Status
Not open for further replies.

jsimone

Programmer
Jun 26, 2002
3
US
I am trying to get the J2EE tutorial sample application, RosterApp which is example of using EJB 2.0 CMP/CMR to work with DB2. I am running Sun's J2EE 1.3.1 reference implementation app server.

The sample works fine with default Cloudscape DB driver. The tables are created automatically and the app runs fine.

I seem to have configured the DB2 driver successfully, but when I run the RosterApp sample I get the following exception:

Binding name:`java:comp/env/ejb/SimpleRoster`
Caught an exception:



java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.RemoteException: Exception thrown from bean; nested exception i
s: javax.ejb.EJBException: nested exception is: COM.ibm.db2.jdbc.DB2Exception: [
IBM][CLI Driver][DB2/NT] SQL0204N "ADMIN.LeagueBeanTable" is an undefined name.
SQLSTATE=42704

java.rmi.RemoteException: Exception thrown from bean; nested exception is: javax
.ejb.EJBException: nested exception is: COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI
Driver][DB2/NT] SQL0204N "ADMIN.LeagueBeanTable" is an undefined name. SQLSTA
TE=42704

<<no stack trace available>>
Caught an exception:
java.rmi.NoSuchObjectException: CORBA OBJECT_NOT_EXIST 9999 No; nested exception
is:
org.omg.CORBA.OBJECT_NOT_EXIST: minor code: 9999 completed: No
org.omg.CORBA.OBJECT_NOT_EXIST: minor code: 9999 completed: No
at java.lang.Class.newInstance0(Native Method)
at java.lang.Class.newInstance(Class.java:237)
at com.sun.corba.ee.internal.iiop.messages.ReplyMessage_1_2.getSystemExc
eption(ReplyMessage_1_2.java:93)
at com.sun.corba.ee.internal.iiop.ClientResponseImpl.getSystemException(
ClientResponseImpl.java:108)
at com.sun.corba.ee.internal.POA.GenericPOAClientSC.invoke(GenericPOACli
entSC.java:132)
at org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.java:459)
at roster._Roster_Stub.getPlayersOfTeam(Unknown Source)
at client.RosterClient.getSomeInfo(RosterClient.java:54)
at client.RosterClient.main(RosterClient.java:33)
at java.lang.reflect.Method.invoke(Native Method)
at com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:22
9)
at com.sun.enterprise.appclient.Main.main(Main.java:155)


Any help is greatly appreciated.

Many thanks,
joe
 
&quot;COM.ibm.db2.jdbc.DB2Exception: [
IBM][CLI Driver][DB2/NT] SQL0204N &quot;ADMIN.LeagueBeanTable&quot; is an undefined name.
SQLSTATE=42704&quot;

It seems odd.I think that you forget to add your schema of your table and then you logged as &quot;admin&quot; so your DB2 used your login user name as table schema.What is your correct schema of your table?
If you don't know this,simply open db2 control center
instances,db2,databases then find your database and open the tables then find your table and its schema.

Salih Sipahi
Software Engineer.
City of Istanbul Turkey
openyourmind77@yahoo.com
 
Problem found.

Inspection of the error.log file in the j2ee dir of the logs directory revealed two error conditions that did not display in the system console. This is true even if -verbose option is enabled.

1. Primary keys for the League, Team and Player table are nullable. DB2 will not allow this. The fix is to edit the SQL Query for the CreateTable container methods:

a) in deployment tool for each LeagueEJB, TeamEJB and PlayerEJB under TeamJAR select the entity tab and the deployement settings button.
b) Make sure create table on deploy check box is checked.
c) generate SQL
d) Select the Container Methods radio button and click on CreateTable method.
e) Add NOT NULL following each primary key id (eg &quot;leagueId&quot; VARCHAR(255) NOT NULL ,)
f) OK, save and deploy again.


2) DB2 does not like constraint names to exceed 18 chars.
The error is:
COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0107N The name &quot;pk_TeamEJB_players_PlayerEJB_teamsTabl&quot; is too long. The maximum length is &quot;18&quot;. SQLSTATE=42622

The fix for this is to edit the sun-j2ee-ri.xml in the ear file and jar file and shorten all strings:
a) TeamEJB_players_PlayerEJB_teamsTabl
b) LeagueEJB_teams_TeamEJB_Tabl
to some string less than or equal to 18 characters. This will make DB2 happy.

This will be a little tricky and may involve decompressing the ear and jar, editing and then reconstructing the files with the correct structure.

Hope this helps all who stumble here.

Kind regards,
joe



 
Additonal notes:

You must also add the NOT NULL to primary ids for the auto-created join tables as well. Make sure _PlayerEJB_playerId and _TeamEJB_teamId are specified as NOT NULL.

When deploying the .ear file with the correct sun-j2ee-ri.xml file PLEASE MAKE SURE to uncheck the save object before deploying button or else ALL YOUR EDITING CHANGES WILL BE OVERWRITTEN.

The combination of a missing NOT NULL on the primary keys as well as the length the limitation on the constraint names makes the J2EE RI and DB2 combination pretty much unusables. Too bad.

You can make it work, but its a pain to fix up.

regards,
joe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top