3 Replies Latest reply on Oct 8, 2002 3:49 AM by Benjamin Rasmussen

    Problem with finder methods

    Benjamin Rasmussen Newbie

      Hi everyone

      I am working on a project (ejbs + servlets) that has been developed in visual age for java. I now wish to use
      jboss in connection to the project.

      I have manage (after many days) to deploy the servlets and the ejbs. But now I have another problem.
      The finder method results in an error message: javax.ejb.ObjectNotFoundException: No such entity!

      I have tried in the following ways (see below). If anyone can help me I would be very happy :-)

      ejb-jar.xml

      <?xml version="1.0" encoding="UTF-8"?>

      <ejb-jar id="ejb-jar_ID">
      Generated by Export Tool for Enterprise Java Beans 1.1 version 1.0 from IBM VisualAge for Java version 4.0.
      <display-name>...</display-name>
      <enterprise-beans>

      <ejb-name>Author</ejb-name>
      ...

      <query-method>
      <method-name>findFromNameAndPassword</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql><![CDATA[SELECT OBJECT(a) FROM Author a WHERE a.username = ?1 AND a.password = ?2]]></ejb-ql>

      </enterprise-beans>


      servlet.class

      try {

      InitialContext jndiContext = new InitialContext();
      Object ref = jndiContext.lookup("java:comp/env/ejb/entity/Author");
      AuthorHome authorHome = (AuthorHome) PortableRemoteObject.narrow(ref, AuthorHome.class);

      Author remote = (Author)home.findFromNameAndPassword("User", "password");

      } catch(Exception e) {
      out.println(e.toString());
      }

      I am using jboss-3.0.2 with jetty and mysql.

      Best regards, Benjam

        • 1. Re: Problem with finder methods
          Benjamin Rasmussen Newbie

          Hi

          I have found out that the homeinterface looks like this:

          public interface AuthorHome extends javax.ejb.EJBHome {

          Author findFromNameAndPassword(String username, String password) throws java.rmi.RemoteException, javax.ejb.FinderException;

          }

          The returnvalue is Author and not java.util.Collection as specified in the documentation. But should that make any difference?

          Regards, Benjamin

          • 2. Re: Problem with finder methods
            Christian Riege Newbie

            did you map the cmp-fields of the author bean against the correct table/fields in the database (in file jbosscmp-jdbc.xml which should be in the META-INF of your .jar)? are you sure your EJB is accessing your MySQL server instead of the built-in Hypersonic DB?

            • 3. Re: Problem with finder methods
              Benjamin Rasmussen Newbie

              I got it to work :-) Thanks!

              But now I have another problem. I am using visual age SingleLink and ManyLink to make relations between the entity beans and that is the problem.

              I get the following error then I try to us one of the relations (A functioncall):

              08:47:54,485 ERROR [LogInterceptor] EJBException:
              javax.ejb.EJBException: Deprecated
              at org.jboss.ejb.EnterpriseContext$EJBContextImpl.getEnvironment(EnterpriseContext.java:340)
              at natnet.ejb.AuthorToAuthorIconLink.getTargetHome(AuthorToAuthorIconLink.java:55)
              at natnet.ejb.AuthorToAuthorIconLink.fetchTarget(AuthorToAuthorIconLink.java:31)
              at com.ibm.ivj.ejb.associations.links.SingleLinkImpl.value(SingleLinkImpl.java:129)
              at natnet.ejb.AuthorBean.getAuthorIcon(AuthorBean.java:151)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:324)
              at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1194)
              at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:335)
              at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
              at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:90)
              at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:152)
              at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:107)
              at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:69)
              at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)
              at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:151)
              at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:60)
              at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
              at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:203)
              at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:493)
              at org.jboss.ejb.Container.invoke(Container.java:712)
              at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1058)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
              at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:98)
              at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:102)
              at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:77)
              at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:80)
              at org.jboss.proxy.ejb.EntityInterceptor.invoke(EntityInterceptor.java:116)
              at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
              at $Proxy193.getAuthorIcon(Unknown Source)

              Can anyone help me?!

              Regards, Benjamin