You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by Jacek Laskowski <jl...@apache.org> on 2005/07/07 17:05:26 UTC

How can I get rid of javax.ejb.NoSuchObjectLocalException?

Hi,

I've got an EAR with a war and CMP. I can deploy it, lookup the CMP home
from within JSP, invoke create(), but when it gets at setting attributes
of the CMP instance, Geronimo blows up with NoSuchObjectLocalException
exception.

Attachments are not allowed so I can't help this way. What's necessary 
to work out the issue?

javax.ejb.NoSuchObjectLocalException
          at
org.openejb.entity.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:128)
          at
org.openejb.entity.cmp.InTxCacheInterceptor.invoke(InTxCacheInterceptor.java:82)
          at
org.openejb.transaction.ContainerPolicy$TxRequired.invoke(ContainerPolicy.java:140)
          at
org.openejb.transaction.TransactionContextInterceptor.invoke(TransactionContextInterceptor.java:80)
          at
org.openejb.SystemExceptionInterceptor.invoke(SystemExceptionInterceptor.java:82)
          at
org.openejb.GenericEJBContainer.invoke(GenericEJBContainer.java:234)
          at
org.openejb.proxy.EJBMethodInterceptor.intercept(EJBMethodInterceptor.java:129)
          at
org.openejb.proxy.EntityEJBLocalObject$$EnhancerByCGLIB$$d23be341.setStreetName1(<generated>)
          at
org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:55)
          at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
          at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
          at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
          at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
          at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:427)
          at
org.apache.geronimo.jetty.JettyServletHolder.handle(JettyServletHolder.java:92)
          at
org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:832)
          at
org.mortbay.jetty.servlet.JSR154Filter.doFilter(JSR154Filter.java:171)
          at
org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:823)
          at
org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:473)
          at
org.mortbay.jetty.servlet.Dispatcher.dispatch(Dispatcher.java:272)
          at
org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:169)
          at org.mortbay.jetty.servlet.Default.handleGet(Default.java:312)
          at org.mortbay.jetty.servlet.Default.service(Default.java:232)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
          at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:427)
          at
org.apache.geronimo.jetty.JettyServletHolder.handle(JettyServletHolder.java:92)
          at
org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:832)
          at
org.mortbay.jetty.servlet.JSR154Filter.doFilter(JSR154Filter.java:171)
          at
org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:823)
          at
org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:473)
          at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567)
          at org.mortbay.http.HttpContext.handle(HttpContext.java:1565)
          at
org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:623)
          at org.mortbay.http.HttpContext.handle(HttpContext.java:1517)
          at org.mortbay.http.HttpServer.service(HttpServer.java:954)
          at 
org.mortbay.http.HttpConnection.service(HttpConnection.java:814)
          at
org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:981)
          at org.mortbay.http.HttpConnection.handle(HttpConnection.java:831)
          at
org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244)
          at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
          at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
Caused by: javax.ejb.NoSuchEntityException: Entity not found
          at
org.openejb.entity.cmp.CMPInstanceContext.associate(CMPInstanceContext.java:152)
          at
org.apache.geronimo.transaction.context.AbstractTransactionContext.associate(AbstractTransactionContext.java:47)
          at
org.apache.geronimo.transaction.context.AbstractTransactionContext.beginInvocation(AbstractTransactionContext.java:85)
          at
org.openejb.entity.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:125)
          ... 42 more

Jacek



Re: How can I get rid of javax.ejb.NoSuchObjectLocalException?

Posted by Gianny Damour <gi...@optusnet.com.au>.
Hi Jaceck,

There is indeed an integration test in OpenEJB itests there:
src/ejb/META-INF/openejb-jar.xml.

Thanks,
Gianny

On 8/07/2005 9:36 PM, Jacek Laskowski wrote:

> Jacek Laskowski wrote:
>
>> Here's the relevant snippet from customer-ejb-plan.xml:
>
>
> ...also I'd be glad to create a test case for it, but I don't know how 
> to proceed. Where can I find sample test cases - OpenEJB itests? Which 
> one would you suggest to start with?
>
> Jacek
>
>


Re: How can I get rid of javax.ejb.NoSuchObjectLocalException?

Posted by Jacek Laskowski <jl...@apache.org>.
Jacek Laskowski wrote:

> Here's the relevant snippet from customer-ejb-plan.xml:

...also I'd be glad to create a test case for it, but I don't know how 
to proceed. Where can I find sample test cases - OpenEJB itests? Which 
one would you suggest to start with?

Jacek


Re: How can I get rid of javax.ejb.NoSuchObjectLocalException?

Posted by Jacek Laskowski <jl...@apache.org>.
Gianny Damour wrote:

> AddressEJB has an unknown primary key. You need to:
> * define an additional CMP field;
> e.g.
>            <cmp-field-mapping>
>                <cmp-field-name>id</cmp-field-name>
>                <cmp-field-class>java.lang.Integer</cmp-field-class>
>                <table-column>id</table-column>
>            </cmp-field-mapping>
> 
> * mark this field as a primary key field (in the openejb-jar.xml DD); and
> e.g.
>           <primkey-field>id</primkey-field>
> 
> * declare an automatic pk generator to set its value.
> There were some recent changes and I do not know how it works.

Here's the relevant snippet from customer-ejb-plan.xml:

    <entity>
       <ejb-name>AddressEJB</ejb-name>
       <table-name>ADDRESSES</table-name>
       <cmp-field-mapping>
         <cmp-field-name>id</cmp-field-name>
         <cmp-field-class>java.lang.Integer</cmp-field-class>
         <table-column>id</table-column>
       </cmp-field-mapping>
       <cmp-field-mapping>
         <cmp-field-name>zipCode</cmp-field-name>
         <table-column>zipCode</table-column>
       </cmp-field-mapping>
       <cmp-field-mapping>
         <cmp-field-name>state</cmp-field-name>
         <table-column>state</table-column>
       </cmp-field-mapping>
       <cmp-field-mapping>
         <cmp-field-name>streetName2</cmp-field-name>
         <table-column>streetName2</table-column>
       </cmp-field-mapping>
       <cmp-field-mapping>
         <cmp-field-name>streetName1</cmp-field-name>
         <table-column>streetName1</table-column>
       </cmp-field-mapping>
       <cmp-field-mapping>
         <cmp-field-name>country</cmp-field-name>
         <table-column>country</table-column>
       </cmp-field-mapping>
       <cmp-field-mapping>
         <cmp-field-name>city</cmp-field-name>
         <table-column>city</table-column>
       </cmp-field-mapping>
       <primkey-field>id</primkey-field>
       <automatic-key-generation>
 
<generator-name>geronimo.server:J2EEServer=geronimo,J2EEApplication=petstore,J2EEModule=customer-ejb,j2eeType=PKGenerator,name=AutoEntityGenerator</generator-name>
         <primary-key-class>java.lang.Integer</primary-key-class>
       </automatic-key-generation>
     </entity>

  <gbean 
gbeanName="geronimo.server:J2EEServer=geronimo,J2EEApplication=petstore,J2EEModule=customer-ejb,j2eeType=PKGenerator,name=AutoEntityGenerator" 
class="org.openejb.entity.cmp.pkgenerator.AutoIncrementTablePrimaryKeyGeneratorWrapper">
     <reference name="ManagedConnectionFactoryWrapper">
 
<gbean-name>geronimo.server:JCAResource=geronimo-derby-connector-1.0-SNAPSHOT.rar,name=DerbyDatasource,J2EEServer=geronimo,J2EEApplication=petstore,j2eeType=JCAManagedConnectionFactory</gbean-name>
     </reference>
     <attribute name="sql" type="java.lang.String">
       insert into customer_ejb_sequence_table (dummy) values (1)
     </attribute>
     <attribute name="returnType" type="java.lang.Class">
       java.lang.Integer
     </attribute>
   </gbean>

Is there anything I missed and should be in the descriptor?

> Gianny

Jacek


Re: How can I get rid of javax.ejb.NoSuchObjectLocalException?

Posted by Gianny Damour <gi...@optusnet.com.au>.
On 8/07/2005 4:08 AM, Jacek Laskowski wrote:

> Jacek Laskowski wrote:
>
>> javax.ejb.NoSuchObjectLocalException
>>          at
>> org.openejb.entity.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:128) 
>>
>>          at
>> <sn>
>
>
> A further investigation has revealed that
>
>   AddressLocal address = addressHome.create();
>
> doesn't write the data to the database and executing
>
>   address.setStreetName1(streetName1);
>
> makes Geronimo (OpenEJB + TranQL) think that the record should already 
> be inserted into the database and tries to issue a SELECT query which 
> returns nothing, which in turn results in NoSuchEntityException.
>
> I'd bet there's something wrong with the logic of the 
> o.o.entity.cmp.CMPInstanceContext class (@see #associate()) or even 
> the o.o.entity.EntityInstanceInterceptor class (@see #invoke).
>
> There's a comment in EntityInstanceInterceptor:
>
> associates the context with the transaction, this may result an a load 
> that throws and NoSuchEntityException, which needs to be converted to 
> the a NoSuchObject[Local]Exception
>
> of which result I'm struggling with.
>
> Any help?

AddressEJB has an unknown primary key. You need to:
* define an additional CMP field;
e.g.
            <cmp-field-mapping>
                <cmp-field-name>id</cmp-field-name>
                <cmp-field-class>java.lang.Integer</cmp-field-class>
                <table-column>id</table-column>
            </cmp-field-mapping>

* mark this field as a primary key field (in the openejb-jar.xml DD); and
e.g.
           <primkey-field>id</primkey-field>

* declare an automatic pk generator to set its value.
There were some recent changes and I do not know how it works.

Thanks,
Gianny

>
> Jacek
>
>


Re: How can I get rid of javax.ejb.NoSuchObjectLocalException?

Posted by Jacek Laskowski <jl...@apache.org>.
Jacek Laskowski wrote:

> javax.ejb.NoSuchObjectLocalException
>          at
> org.openejb.entity.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:128) 
> 
>          at
> org.openejb.entity.cmp.InTxCacheInterceptor.invoke(InTxCacheInterceptor.java:82) 
> 
>          at
> org.openejb.transaction.ContainerPolicy$TxRequired.invoke(ContainerPolicy.java:140) 
> 
>          at
> org.openejb.transaction.TransactionContextInterceptor.invoke(TransactionContextInterceptor.java:80) 
> 
>          at
> org.openejb.SystemExceptionInterceptor.invoke(SystemExceptionInterceptor.java:82) 
> 
>          at
> org.openejb.GenericEJBContainer.invoke(GenericEJBContainer.java:234)
>          at
> org.openejb.proxy.EJBMethodInterceptor.intercept(EJBMethodInterceptor.java:129) 
> 
>          at
> org.openejb.proxy.EntityEJBLocalObject$$EnhancerByCGLIB$$d23be341.setStreetName1(<generated>) 
> 
>          at
> org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:55)

A further investigation has revealed that

   AddressLocal address = addressHome.create();

doesn't write the data to the database and executing

   address.setStreetName1(streetName1);

makes Geronimo (OpenEJB + TranQL) think that the record should already 
be inserted into the database and tries to issue a SELECT query which 
returns nothing, which in turn results in NoSuchEntityException.

I'd bet there's something wrong with the logic of the 
o.o.entity.cmp.CMPInstanceContext class (@see #associate()) or even the 
o.o.entity.EntityInstanceInterceptor class (@see #invoke).

There's a comment in EntityInstanceInterceptor:

associates the context with the transaction, this may result an a load 
that throws and NoSuchEntityException, which needs to be converted to 
the a NoSuchObject[Local]Exception

of which result I'm struggling with.

Any help?

Jacek