Hello User-help
I have had no problem configuring and using 0.9.2 for one jar deployment. But two bean jar deployments is problematic. I am running tomcat on linux, using postgresql. Have added appropriate container and connector elements to the openejb.conf in the conf dir. The beans in the jar each map to a database with three tables.
I set up my second web app bean configuration to look like the first, with appropriate attribute changes.
Am running openejb-0.9.2 as embedded VM server. Using tomcat 5.0.28
Beans deployed using deploy tool successfully, etc.
When I restart tomcat, whichever of the two web apps that I test first runs and queries the database just fine. But when I then test the second web app, as soon as it tries to query its appropriate table in its database, it gets the following message below: (this error is symmetrical with respect to the other EJB jar and its respective tables when app starting sequence is reversed after restarting tomcat.) Also note that after tomcat is restarted, there are no errors indicated either in the tomcat log file or the openejb.log file, and all beans appear to have been appropriately deployed by the openejb container system, as indicated in the openejb.log.
javax.ejb.FinderException: Castor JDO could not execute query for
this finder method.
QueryException: Could not find mapping for class nphonecard.beans.userdata.UserDataBean
at org.openejb.alt.containers.castor_cmp11.CastorCMP11_EntityContainer.findEJBObject(CastorCMP11_EntityContainer.java:1103)
at org.openejb.alt.containers.castor_cmp11.CastorCMP11_EntityContainer.invoke(CastorCMP11_EntityContainer.java:524)
at org.openejb.core.entity.EntityEjbHomeHandler.findX(EntityEjbHomeHandler.java:125)
at org.openejb.core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:152)
at org.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:327)
at org.openejb.util.proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:89)
at $Proxy1.findByUserName(Unknown Source)
at nphonecard.servlets.PassWordCheckServlet.doPost(PassWordCheckServlet.java:128)
etc...
Before we go any further: *many*, *many* thanks to anyone who attemps to tackle this problem!
Now, certainly, it would be impossible for anyone to help me diagnose this error I am getting without including the appropriate configuration
and resource files. And this, of course, is where this letter will get
to be a little bit of a mess, because there are a bunch of these files.
However, here they are: (Note that the mozilla mailer is forcing some newlines into these included texts, but the actual files do not contain these)
(Note: If I have ommitted from this letter any file that is important for diagnosing the indicated problem, do not hesitate to send a request to me for this information.)
There are two bean jars: nphonecardEJB.jar and getimgEJB.jar
The openejb.xml for nphonecardEJB.jar:
<!-- ------------------------------------------------------------ -->
<openejb xmlns="http://www.openejb.org/System/Configuration">
<Container id="nphonecardEJB CMP Container" ctype="CMP_ENTITY">
Global_TX_Database /home/yarrow/NPhoneCard/src/nphonecard/beans/conf/postgresql.cmp_global_database.xml
Local_TX_Database /home/yarrow/NPhoneCard/src/nphonecard/beans/conf/postgresql.cmp_local_database.xml
</Container>
<Deployments jar="beans/nphonecardEJB.jar"/>
<Connector id="nphonecardEJB JDBC Database">
JdbcDriver org.postgresql.Driver
JdbcUrl jdbc:postgresql://localhost/nphonecard?compatible=7.1
UserName yarrow
Password ""
</Connector>
<SecurityService id="Default Security Service"/>
<TransactionService id="Default Transaction Manager"/>
</openejb>
<!-- ------------------------------------------------------------ -->
The openejb.xml for getimgEJB.jar:
<!-- ------------------------------------------------------------ --> <openejb xmlns="http://www.openejb.org/System/Configuration">
<Container id="getimgEJB CMP Container" ctype="CMP_ENTITY">
Global_TX_Database /home/yarrow/GetImg/src/getimg/beans/conf/postgresql.cmp_global_database.xml
Local_TX_Database /home/yarrow/GetImg/src/getimg/beans/conf/postgresql.cmp_local_database.xml
</Container>
<Deployments jar="beans/getimgEJB.jar"/>
<Connector id="getimgEJB JDBC Database">
JdbcDriver org.postgresql.Driver
JdbcUrl jdbc:postgresql://localhost/getimg?compatible=7.1
UserName yarrow
Password ""
</Connector>
<SecurityService id="Default Security Service"/>
<TransactionService id="Default Transaction Manager"/>
</openejb>
<!-- ------------------------------------------------------------ -->
Here is the main openejb/conf/openejb.conf file: (default definitions have been deleted in this included copy for brevity's sake)
<!-- ------------------------------------------------------------ -->
<Container id="getimgEJB CMP Container" ctype="CMP_ENTITY">
Global_TX_Database /home/yarrow/GetImg/src/getimg/beans/conf/postgresql.cmp_global_database.xml
Local_TX_Database /home/yarrow/GetImg/src/getimg/beans/conf/postgresql.cmp_local_database.xml
</Container>
<Container id="nphonecardEJB CMP Container" ctype="CMP_ENTITY">
Global_TX_Database /home/yarrow/NPhoneCard/src/nphonecard/beans/conf/postgresql.cmp_global_database.xml
Local_TX_Database /home/yarrow/NPhoneCard/src/nphonecard/beans/conf/postgresql.cmp_local_database.xml
</Container>
<Connector id="getimgEJB JDBC Database">
JdbcDriver org.postgresql.Driver
JdbcUrl jdbc:postgresql://localhost/getimg?compatible=7.1
UserName yarrow
Password ""
</Connector> <Connector id="nphonecardEJB JDBC Database">
JdbcDriver org.postgresql.Driver
JdbcUrl jdbc:postgresql://localhost/nphonecard?compatible=7.1
UserName yarrow
Password ""
</Connector>
<!-- ------------------------------------------------------------ -->Next, I am including the various postgresql.cmp_{global,local}_database.xml files:
The nphonecardEJB postgresql.cmp_global_database.xml:
<!-- ------------------------------------------------------------ -->
<?xml version="1.0"?>
<database name="Global_TX_Database" engine="postgresql">
<jndi name="java:comp/env/jdbc/nphonecard" />
<mapping href="/home/yarrow/NPhoneCard/src/nphonecard/beans/conf/postgresql.cmp_or_mapping.xml" />
</database>
<!-- ------------------------------------------------------------ -->
The nphonecardEJB postgresql.cmp_local_database.xml:
<!-- ------------------------------------------------------------ -->
<?xml version="1.0"?>
<database name="Local_TX_Database" engine="postgresql">
<driver class-name="org.postgresql.Driver" url="jdbc:postgresql://localhost/nphonecard?compatible=7.1">
<param name="user" value="yarrow"/>
<param name="password" value=""/>
</driver>
<mapping href="/home/yarrow/NPhoneCard/src/nphonecard/beans/conf/postgresql.cmp_or_mapping.xml"/>
</database>
<!-- ------------------------------------------------------------ -->
The nphonecardEJB postgresql.cmp_or_mapping.xml:
<!-- ------------------------------------------------------------ --> <?xml version="1.0"?>
<mapping>
<class name="nphonecard.beans.phonecardlist.PhoneCardListBean"
identity="PCLId"
key-generator="SEQUENCE">
<map-to table="phonecardlist"/>
<!-- (Note: cache-type none goes along with Blob type) -->
<cache-type type="none" />
<field name="PCLId" type="integer" direct="true">
<sql name="pcl_id" type="integer"/>
</field>
<field name="UserName" type="string" direct="true">
<sql name="user_name" type="varchar" dirty="check"/>
</field>
<field name="AccountID" type="string" direct="true">
<sql name="account_id" type="varchar" dirty="check"/>
</field>
<field name="CreateDate" type="string" direct="true">
<sql name="create_date" type="varchar" dirty="check"/>
</field>
<field name="ChangeDate" type="string" direct="true">
<sql name="change_date" type="varchar" dirty="check"/>
</field>
<field name="PCLName" type="string" direct="true">
<sql name="pcl_name" type="varchar" dirty="check"/>
</field>
<field name="PCLBlob" type="bytes" direct="true">
<sql name="pcl_blob" type="blob" dirty="ignore"/>
</field>
</class> <class name="nphonecard.beans.userdata.UserDataBean"
identity="UDId"
key-generator="SEQUENCE">
<map-to table="userdata"/>
<field name="UDId" type="integer" direct="true">
<sql name="ud_id" type="integer"/>
</field>
<field name="UserName" type="string" direct="true">
<sql name="user_name" type="varchar" dirty="check"/>
</field>
<field name="PassWord" type="string" direct="true">
<sql name="pass_word" type="varchar" dirty="check"/>
</field>
<field name="AccountID" type="string" direct="true">
<sql name="account_id" type="varchar" dirty="check"/>
</field>
<field name="CreditCardNumber" type="string" direct="true">
<sql name="credit_card_number" type="varchar" dirty="check"/>
</field>
<field name="CreditCardIssuer" type="string" direct="true">
<sql name="credit_card_issuer" type="varchar" dirty="check"/>
</field>
<field name="CreditCardExp" type="string" direct="true">
<sql name="credit_card_exp" type="varchar" dirty="check"/>
</field>
<field name="FirstName" type="string" direct="true">
<sql name="first_name" type="varchar" dirty="check"/>
</field>
<field name="LastName" type="string" direct="true">
<sql name="last_name" type="varchar" dirty="check"/>
</field>
<field name="MidInitial" type="string" direct="true">
<sql name="mid_initial" type="varchar" dirty="check"/>
</field>
<field name="Title" type="string" direct="true">
<sql name="title" type="varchar" dirty="check"/>
</field>
<field name="WholeName" type="string" direct="true">
<sql name="whole_name" type="varchar" dirty="check"/>
</field>
<field name="HomePhoneNumber" type="string" direct="true">
<sql name="home_phone_number" type="varchar" dirty="check"/>
</field>
<field name="WorkPhoneNumber" type="string" direct="true">
<sql name="work_phone_number" type="varchar" dirty="check"/>
</field>
<field name="HomeAddress" type="string" direct="true">
<sql name="home_address" type="varchar" dirty="check"/>
</field>
<field name="CityName" type="string" direct="true">
<sql name="city_name" type="varchar" dirty="check"/>
</field>
<field name="CSZString" type="string" direct="true">
<sql name="csz_string" type="varchar" dirty="check"/>
</field>
<field name="State" type="string" direct="true">
<sql name="state" type="varchar" dirty="check"/>
</field>
<field name="ZipCode" type="string" direct="true">
<sql name="zip_code" type="varchar" dirty="check"/>
</field>
<field name="EMail" type="string" direct="true">
<sql name="email" type="varchar" dirty="check"/>
</field>
<field name="Extra1" type="string" direct="true">
<sql name="extra1" type="varchar" dirty="check"/>
</field>
<field name="Extra2" type="string" direct="true">
<sql name="extra2" type="varchar" dirty="check"/>
</field>
</class> <class name="nphonecard.beans.userlist.UserListBean"
identity="PCLId"
key-generator="SEQUENCE">
<map-to table="phonecardlist"/>
<!-- (Note: cache-type none goes along with Blob type) -->
<cache-type type="none" />
<field name="PCLId" type="integer" direct="true">
<sql name="pcl_id" type="integer"/>
</field>
<field name="UserName" type="string" direct="true">
<sql name="user_name" type="varchar" dirty="check"/>
</field>
<field name="PCLName" type="string" direct="true">
<sql name="pcl_name" type="varchar" dirty="check"/>
</field>
</class></mapping> <!-- ------------------------------------------------------------ -->
Now, the appropriate such files for the getimgEJB.jar
<!-- ------------------------------------------------------------ -->
<database name="Global_TX_Database" engine="postgresql">
<jndi name="java:comp/env/jdbc/getimg" />
<mapping href="/home/yarrow/GetImg/src/getimg/beans/conf/postgresql.cmp_or_mapping.xml" />
</database>
<database name="Local_TX_Database" engine="postgresql">
<driver class-name="org.postgresql.Driver" url="jdbc:postgresql://localhost/getimg?compatible=7.1">
<param name="user" value="yarrow"/>
<param name="password" value=""/>
</driver>
<mapping href="/home/yarrow/GetImg/src/getimg/beans/conf/postgresql.cmp_or_mapping.xml"/>
</database>
<mapping>
<class name="getimg.beans.pcuserdata.PCUserDataBean"
identity="UDId"
key-generator="SEQUENCE">
<map-to table="pcuserdata"/>
<field name="UDId" type="integer" direct="true">
<sql name="ud_id" type="integer"/>
</field>
<field name="UserName" type="string" direct="true">
<sql name="user_name" type="varchar" dirty="check"/>
</field>
<field name="PassWord" type="string" direct="true">
<sql name="pass_word" type="varchar" dirty="check"/>
</field>
<field name="AccountID" type="string" direct="true">
<sql name="account_id" type="varchar" dirty="check"/>
</field>
<field name="CreditCardNumber" type="string" direct="true">
<sql name="credit_card_number" type="varchar" dirty="check"/>
</field>
<field name="CreditCardIssuer" type="string" direct="true">
<sql name="credit_card_issuer" type="varchar" dirty="check"/>
</field>
<field name="CreditCardExp" type="string" direct="true">
<sql name="credit_card_exp" type="varchar" dirty="check"/>
</field>
<field name="FirstName" type="string" direct="true">
<sql name="first_name" type="varchar" dirty="check"/>
</field>
<field name="LastName" type="string" direct="true">
<sql name="last_name" type="varchar" dirty="check"/>
</field>
<field name="MidInitial" type="string" direct="true">
<sql name="mid_initial" type="varchar" dirty="check"/>
</field>
<field name="Title" type="string" direct="true">
<sql name="title" type="varchar" dirty="check"/>
</field>
<field name="WholeName" type="string" direct="true">
<sql name="whole_name" type="varchar" dirty="check"/>
</field>
<field name="HomePhoneNumber" type="string" direct="true">
<sql name="home_phone_number" type="varchar" dirty="check"/>
</field>
<field name="WorkPhoneNumber" type="string" direct="true">
<sql name="work_phone_number" type="varchar" dirty="check"/>
</field>
<field name="HomeAddress" type="string" direct="true">
<sql name="home_address" type="varchar" dirty="check"/>
</field>
<field name="CityName" type="string" direct="true">
<sql name="city_name" type="varchar" dirty="check"/>
</field>
<field name="CSZString" type="string" direct="true">
<sql name="csz_string" type="varchar" dirty="check"/>
</field>
<field name="State" type="string" direct="true">
<sql name="state" type="varchar" dirty="check"/>
</field>
<field name="ZipCode" type="string" direct="true">
<sql name="zip_code" type="varchar" dirty="check"/>
</field>
<field name="EMail" type="string" direct="true">
<sql name="email" type="varchar" dirty="check"/>
</field>
<field name="Extra1" type="string" direct="true">
<sql name="extra1" type="varchar" dirty="check"/>
</field>
<field name="Extra2" type="string" direct="true">
<sql name="extra2" type="varchar" dirty="check"/>
</field>
</class> <class name="getimg.beans.photoclubdata.PhotoClubDataBean"
identity="PCId"
key-generator="SEQUENCE">
<map-to table="photoclubdata"/>
<field name="PCId" type="integer" direct="true">
<sql name="pc_id" type="integer"/>
</field>
<field name="PhotoClub" type="string" direct="true">
<sql name="photo_club" type="varchar" dirty="check"/>
</field>
<field name="UserName" type="string" direct="true">
<sql name="user_name" type="varchar" dirty="check"/>
</field>
<field name="CreateDate" type="string" direct="true">
<sql name="create_date" type="varchar" dirty="check"/>
</field>
</class> <class name="getimg.beans.clubuserdata.ClubUserDataBean"
identity="CUId"
key-generator="SEQUENCE">
<map-to table="clubuserdata"/>
<field name="CUId" type="integer" direct="true">
<sql name="cu_id" type="integer"/>
</field>
<field name="PhotoClub" type="string" direct="true">
<sql name="photo_club" type="varchar" dirty="check"/>
</field>
<field name="UserName" type="string" direct="true">
<sql name="user_name" type="varchar" dirty="check"/>
</field>
</class></mapping> <!-- ------------------------------------------------------------ -->
This is the nphonecardEJB META-INF/ejb-jar.xml:
<!-- ------------------------------------------------------------ -->
<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN"
"http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd">
<ejb-jar>
<enterprise-beans>
<entity>
<ejb-name>PhoneCardListBean</ejb-name>
<home>nphonecard.beans.phonecardlist.PhoneCardListHome</home>
<remote>nphonecard.beans.phonecardlist.PhoneCardList</remote> <ejb-class>nphonecard.beans.phonecardlist.PhoneCardListBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
<reentrant>False</reentrant>
<cmp-field>
<field-name>PCLId</field-name>
</cmp-field>
<cmp-field>
<field-name>UserName</field-name>
</cmp-field>
<cmp-field>
<field-name>AccountID</field-name>
</cmp-field>
<cmp-field>
<field-name>CreateDate</field-name>
</cmp-field>
<cmp-field>
<field-name>ChangeDate</field-name>
</cmp-field>
<cmp-field>
<field-name>PCLName</field-name>
</cmp-field>
<cmp-field>
<field-name>PCLBlob</field-name>
</cmp-field>
<primkey-field>PCLId</primkey-field>
<resource-ref>
<res-ref-name>jdbc/postgresql</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</entity>
<entity> <ejb-name>UserDataBean</ejb-name> <home>nphonecard.beans.userdata.UserDataHome</home> <remote>nphonecard.beans.userdata.UserData</remote> <ejb-class>nphonecard.beans.userdata.UserDataBean</ejb-class> <persistence-type>Container</persistence-type> <prim-key-class>java.lang.Integer</prim-key-class> <reentrant>False</reentrant> <cmp-field> <field-name>UDId</field-name> </cmp-field> <cmp-field> <field-name>UserName</field-name> </cmp-field> <cmp-field> <field-name>PassWord</field-name> </cmp-field> <cmp-field> <field-name>AccountID</field-name> </cmp-field> <cmp-field> <field-name>CreditCardNumber</field-name> </cmp-field> <cmp-field> <field-name>CreditCardIssuer</field-name> </cmp-field> <cmp-field> <field-name>CreditCardExp</field-name> </cmp-field> <cmp-field> <field-name>FirstName</field-name> </cmp-field> <cmp-field> <field-name>LastName</field-name> </cmp-field> <cmp-field> <field-name>MidInitial</field-name> </cmp-field> <cmp-field> <field-name>Title</field-name> </cmp-field> <cmp-field> <field-name>WholeName</field-name> </cmp-field> <cmp-field> <field-name>HomePhoneNumber</field-name> </cmp-field> <cmp-field> <field-name>WorkPhoneNumber</field-name> </cmp-field> <cmp-field> <field-name>HomeAddress</field-name> </cmp-field> <cmp-field> <field-name>CityName</field-name> </cmp-field> <cmp-field> <field-name>CSZString</field-name> </cmp-field> <cmp-field> <field-name>State</field-name> </cmp-field> <cmp-field> <field-name>ZipCode</field-name> </cmp-field> <cmp-field> <field-name>EMail</field-name> </cmp-field> <cmp-field> <field-name>Extra1</field-name> </cmp-field> <cmp-field> <field-name>Extra2</field-name> </cmp-field> <primkey-field>UDId</primkey-field> <resource-ref> <res-ref-name>jdbc/postgresql</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> </entity>
<entity>
<ejb-name>UserListBean</ejb-name>
<home>nphonecard.beans.userlist.UserListHome</home>
<remote>nphonecard.beans.userlist.UserList</remote>
<ejb-class>nphonecard.beans.userlist.UserListBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
<reentrant>False</reentrant>
<cmp-field>
<field-name>PCLId</field-name>
</cmp-field>
<cmp-field>
<field-name>UserName</field-name>
</cmp-field>
<cmp-field>
<field-name>PCLName</field-name>
</cmp-field>
<primkey-field>PCLId</primkey-field>
<resource-ref>
<res-ref-name>jdbc/postgresql</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</entity></enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>PhoneCardListBean</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Supports</trans-attribute>
</container-transaction> <container-transaction>
<method>
<ejb-name>UserDataBean</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Supports</trans-attribute>
</container-transaction> <container-transaction>
<method>
<ejb-name>UserListBean</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Supports</trans-attribute>
</container-transaction></assembly-descriptor>
</ejb-jar> <!-- ------------------------------------------------------------ -->
At this point, I am refraining from including the openejb-jar.xml's that are produced by the deploy tool for the two beans jar sets because they include no linefeeds and are very difficult to scan visually. However, I did peruse them carefully and see no evident errors in them. The embedded SQL SELECTs in them are appropriate for the findByUserName, etc that are indicated by the bean Home files.
Maurice Yarrow
