Hi,
I can't seem to get a CMP bean with multiple fields to actually find a
bean
I would rather not wish to implement as a stateless session bean becuase
a CMP should work for this.

Can any give a suggestion on what I may be doing wrong?
Or possible a concrete example of a CMP with multiple fields in the
primary key class?  Below is a listing of a prior message I sent.

I have over 30 various beans in my web app using xa.QspDBPool  mostly
BMP and stateless session beans.

The two CMP beans that that I'm able to make work do not have a
primaryKey class since only one string is used as the primary key.

For the CMP using a primaryKey class with multiple fields, I know the
table name is correct in jaws.xml and that a row with the primary key
fields does indeed exist.

here is the requested jboss.xml and stack trace

<?xml version="1.0" encoding="ISO-8859-1"?>

<jboss>
   <resource-managers>
       <resource-manager
res-class="org.jboss.ejb.deployment.JDBCResource">
      <res-name>QspDBPool</res-name>
      <res-jndi-name>xa.QspDBPool</res-jndi-name>
       </resource-manager>
   </resource-managers>
   <enterprise-beans>
       <entity>
  <ejb-name>TebNomlHome</ejb-name>
  <jndi-name>qsp.TebNomlHome</jndi-name>
  <configuration-name></configuration-name>
         <resource-ref>
        <res-ref-name>QspDBPool</res-ref-name>
        <resource-name>QspDBPool</resource-name>
  </resource-ref>
       </entity>
   </enterprise-beans>
</jboss>

StackTrace

javax.ejb.ObjectNotFoundException: Object with primary key
net.qspasp.ejbs.gl.tebnoml.TebNomlPk@25844f not found in
storage<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at
sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:245)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at

sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at

sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at

org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker_Stub.invokeHome(Unknown

Source)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at
org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invoke(HomeProxy.java:221)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at

$Proxy2.findByPrimaryKey(Unknown
Source)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at
net.qspasp.servlets.shared.base.AcctEjbServlet.doAcctDescEditEjb(AcctEjbServlet.java:85)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at

net.qspasp.servlets.netcontrol.account.AcctDescEditServlet.doPost(AcctDescEditServlet.java:82)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at

javax.servlet.http.HttpServlet.service(HttpServlet.java:760)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at

javax.servlet.http.HttpServlet.service(HttpServlet.java:853)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at

org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at

org.apache.tomcat.core.Handler.service(Handler.java:286)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at

org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at

org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at

org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at

org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java:166)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at

org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at

org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at

java.lang.Thread.run(Thread.java:484)<br>
javax.ejb.ObjectNotFoundException: Object with primary key
net.qspasp.ejbs.gl.tebnoml.TebNomlPk@25844f not found in storage

Hey,

always report full stack traces, please.

Do you have also a jboss.xml ? You should, and probably you have it,
since
the ejb-name of the bean is TebNomlHome and you lookup it using
qsp.TebNomlHome (or is a mistake ?).
And what about jboss.jcml ?
Double check also the fact that the datasource is called xa.QspDBPool in

jaws.xml and QspDBPool in the ejb-jar.xml (the missing piece is
jboss.xml).
When JBoss starts, it tells you where does it bind the datasource, like
"XA
Connection pool DefaultDS bound to java:/DefaultDS". Where is yours
bound ?

>From all the above, are you really sure that you're looking in the
right
table, and that the EJB table is in the datasource you're looking at ?
(and
that the pk really exists in that table in that database ? :)

Simon

> Hi Simone,
>
> I'll try doing String.hashCode()
>
> 1. OS: I'm using Slackware Linux, Blackdown JDK1.3 with Jbos
> PRE2-1 Dec 3
> 2. Client code:
>     /**
>      * doAcctDescrEdit - changes account description names
>      * @param Map dbMap - a map html form values to database
> table columns
>      */
> protected void doAcctDescEditEjb(Map dbMap) throws Exception {
>    TebNomlHome tebNomlHome = (TebNomlHome)
> initialContext.lookup("qsp.TebNomlHome");
>    TebNomlPk tebNomlPk = new TebNomlPk((String)dbMap.get(DB_CMPY),
>
> (String)dbMap.get(DB_NOMLVAL),1);
>    TebNoml tebNoml = tebNomlHome.findByPrimaryKey(tebNomlPk);
>    tebNoml.setDescr_30((String)dbMap.get(DB_DESCR30));
> }
>
> 3. Err msg
>  Unknown status code: javax.ejb.ObjectNotFoundException:
> Object with primary key
> net.qspasp.ejbs.gl.tebnoml.TebNomlPk@3ad33d not found in
> storage
>
> 4. Also I'm using whatever default CMP server the comes with Jboss
> Paul Russo wrote:
>
> > I have a primary key with multiple fields.
> > When I try to do a findByPrimary key from a client, I get Object not

> > found in storage. I know the database row exists.  Also, I can make
> > other findByPrimaryKey for CMP work by using a single field with no
> > primary key class.
> >
> > I've included the primaryKey class and ejb-jar.xml and jaws
> xml files.
> >
> > I thank anybody who would take the time to look at this.
> >
> > package net.qspasp.ejbs.gl.tebnoml;
> >
> > public class TebNomlPk implements java.io.Serializable {
> >     public String cmpy;
> >     public String noml;
> >     public int path;
> >
> >     private int hashCode;
> >
> >     public TebNomlPk() {
> >     }
> >
> >     public TebNomlPk(String cmpy, String noml, int path) {
> >  this.cmpy = cmpy;
> >  this.noml = noml;
> >  this.path = path;
> >
> >  StringBuffer buff = new StringBuffer();
> >  buff.append(cmpy);
> >  buff.append(noml);
> >  buff.append(path);
> >  hashCode =  buff.hashCode();
> >     }
> >
> >     public boolean equals(Object key) {
> >  System.out.println("equals method");
> >  if ( (key == null)
> >       || !(key instanceof TebNomlPk) ) {
> >      System.out.println("equals =f1");
> >      return false;
> >  }
> >  if ( (((TebNomlPk)key).cmpy.equals(cmpy))
> >       && (((TebNomlPk)key).noml.equals(noml))
> >       && (((TebNomlPk)key).path == (path)) ) {
> >      System.out.println("equals =t1");
> >      return true;
> >  } else {
> >      System.out.println("equals =f2");
> >      return false;
> >  }
> >     }
> >
> >     public int hashCode() {
> >  return hashCode;
> >     }
> > }
> >
> > 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>
> >       <description>Deployment descriptor for TebNoml
> bean</description>
> >       <ejb-name>TebNomlHome</ejb-name>
> >       <home>net.qspasp.ejbs.gl.tebnoml.TebNomlHome</home>
> >       <remote>net.qspasp.ejbs.gl.tebnoml.TebNoml</remote>
> >       <ejb-class>net.qspasp.ejbs.gl.tebnoml.TebNomlBean</ejb-class>
> >       <persistence-type>Container</persistence-type>
> >
> >
> <prim-key-class>net.qspasp.ejbs.gl.tebnoml.TebNomlPk</prim-key-class>
> >       <reentrant>False</reentrant>
> >       <cmp-field><field-name>cmpy</field-name></cmp-field>
> >       <cmp-field><field-name>path</field-name></cmp-field>
> >       <cmp-field><field-name>noml</field-name></cmp-field>
> >       <cmp-field><field-name>descr_30</field-name></cmp-field>
> >       <resource-ref>
> >          <description>A jdbc connection for the CMP
> bean</description>
> >                 <res-ref-name>QspDBPool</res-ref-name>
> >                 <res-type>javax.sql.DataSource</res-type>
> >                 <res-auth>Container</res-auth>
> >       </resource-ref>
> >     </entity>
> >   </enterprise-beans>
> > </ejb-jar>
> >
> > jaws.xml
> > ---------
> >
> > <jaws>
> >     <datasource>xa.QspDBPool</datasource>
> >     <type-mapping>Oracle</type-mapping>
> >
> >     <default-entity>
> >        <create-table>true</create-table>
> >        <remove-table>false</remove-table>
> >        <tuned-updates>true</tuned-updates>
> >        <read-only>false</read-only>
> >        <time-out>300</time-out>
> >     </default-entity>
> >
> >     <type-mappings>
> >         <type-mapping>
> >             <name>Oracle</name>
> >             <mapping>
> >                 <java-type>java.lang.Long</java-type>
> >                 <jdbc-type>BIGINT</jdbc-type>
> >                 <sql-type>NUMBER</sql-type>
> >             </mapping>
> >             <mapping>
> >                 <java-type>java.lang.String</java-type>
> >                 <jdbc-type>VARCHAR</jdbc-type>
> >                 <sql-type>VARCHAR(256)</sql-type>
> >             </mapping>
> >             <mapping>
> >                 <java-type>java.lang.String</java-type>
> >                 <jdbc-type>VARCHAR</jdbc-type>
> >                 <sql-type>CHAR</sql-type>
> >             </mapping>
> >             <mapping>
> >                 <java-type>java.lang.Character</java-type>
> >                 <jdbc-type>CHAR</jdbc-type>
> >                 <sql-type>CHAR</sql-type>
> >             </mapping>
> >             <mapping>
> >                 <java-type>java.lang.Short</java-type>
> >                 <jdbc-type>INTEGER</jdbc-type>
> >                 <sql-type>NUMBER</sql-type>
> >             </mapping>
> >             <mapping>
> >                 <java-type>java.sql.TimeStamp</java-type>
> >                 <jdbc-type>TIMESTAMP</jdbc-type>
> >                 <sql-type>TIMESTAMP</sql-type>
> >             </mapping>
> >             <mapping>
> >                 <java-type>java.lang.Double</java-type>
> >                 <jdbc-type>DOUBLE</jdbc-type>
> >                 <sql-type>NUMBER</sql-type>
> >             </mapping>
> >             <mapping>
> >                 <java-type>java.lang.Byte</java-type>
> >                 <jdbc-type>TINYINT</jdbc-type>
> >                 <sql-type>NUMBER</sql-type>
> >             </mapping>
> >             <mapping>
> >                 <java-type>java.lang.Boolean</java-type>
> >                 <jdbc-type>BIT</jdbc-type>
> >                 <sql-type>NUMBER</sql-type>
> >             </mapping>
> >             <mapping>
> >                 <java-type>java.lang.Float</java-type>
> >                 <jdbc-type>FLOAT</jdbc-type>
> >                 <sql-type>NUMBER</sql-type>
> >             </mapping>
> >             <mapping>
> >                 <java-type>java.lang.Object</java-type>
> >                 <jdbc-type>JAVA_OBJECT</jdbc-type>
> >                 <sql-type>JAVA_OBJECT</sql-type>
> >             </mapping>
> >             <mapping>
> >                 <java-type>java.util.Date</java-type>
> >                 <jdbc-type>DATE</jdbc-type>
> >                 <sql-type>DATE</sql-type>
> >             </mapping>
> >             <mapping>
> >                 <java-type>java.lang.Integer</java-type>
> >                 <jdbc-type>INTEGER</jdbc-type>
> >                 <sql-type>NUMBER</sql-type>
> >             </mapping>
> >         </type-mapping>
> >     </type-mappings>
> >
> > <enterprise-beans>
> >      <entity>
> >        <ejb-name>TebNomlHome</ejb-name>
> >        <table-name>TEBNOML</table-name>
> >        <create-table>false</create-table>
> >        <cmp-field>
> >          <field-name>cmpy</field-name>
> >          <column-name>CMPY</column-name>
> >    <jdbc-type>VARCHAR</jdbc-type>
> >           <sql-type>VARCHAR(2)</sql-type>
> >        </cmp-field>
> >        <cmp-field>
> >          <field-name>noml</field-name>
> >          <column-name>NOML</column-name>
> >    <jdbc-type>VARCHAR</jdbc-type>
> >           <sql-type>VARCHAR(20)</sql-type>
> >        </cmp-field>
> >        <cmp-field>
> >          <field-name>path</field-name>
> >          <column-name>PATH</column-name>
> >   <jdbc-type>INTEGER</jdbc-type>
> >           <sql-type>NUMBER</sql-type>
> >        </cmp-field>
> >        <cmp-field>
> >          <field-name>descr_30</field-name>
> >          <column-name>DESCR_30</column-name>
> >        </cmp-field>
> >      </entity>
> >    </enterprise-beans>
> > </jaws>





--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
List Help?:          [EMAIL PROTECTED]

Reply via email to