1 Reply Latest reply on Nov 18, 2005 3:49 PM by Karen Ploski

    lookup failure

    Karen Ploski Newbie

      Problem:

      lookup fails:
      InitialContext ctx = new InitialContext();
      LoadStudioBeanInterface lsbInterface
      = (LoadStudioBeanInterface) ctx.lookup(LoadStudioBeanInterface.class.getName());

      (full stack trace appears later)

      The same small app deployed successfully using RC1 and JBoss 4.0.2. I recompiled all class files when I upgraded the app to use JBoss 4.0.3SP1 with EJBRC2.

      I've spent several hours combing the documentation, including the packaging and stateless tutorials, also the EJB3 forum, but I'm not able to determine what's wrong. I'm hoping someone can spot the problem using the information provided below, or possibly suggest some way to troubleshoot the problem.

      Thank you very much!
      - Karen

      Environment:

      JBoss 4.0.3SP1
      EJB3RC2 -- I used the installer to install EJB3; after reading the forum, it seems that the installer installs RC2, not RC3
      Windows XP SP2
      J2SE 5.0

      When I ran the installer, I did *not* check the box labelled "Enable deployment isolation/call by value".

      Environment variables:

      ANT_HOME=F:\ANT-1-6-5\apache-ant-1.6.5
      JAVA_HOME=F:\j2se1.5.0
      JBOSS_HOME=F:\JBoss-403SP1-EJB3RC3
      Path=F:\j2se1.5.0\bin;F:\ANT-1-6-5\apache-ant-1.6.5\bin;C:\WINDOWS\system32;C:\WINDOWS;
      C:\WINDOWS\System32\Wbem

      CLASSPATH is *not* set prior to entering run -c all

      EAR file contents:

      META-INF/application.xml
      em1.par

      The EAR file is deployed successfully. In JNDIView I see:


      java: Namespace
      +- jaas (class: javax.naming.Context)
      | +- JmsXARealm (class: org.jboss.security.plugins.SecurityDomainContext)
      | +- jbossmq (class: org.jboss.security.plugins.SecurityDomainContext)
      | +- HsqlDbRealm (class: org.jboss.security.plugins.SecurityDomainContext)
      +- TransactionPropagationContextImporter (class: org.jboss.tm.TransactionPropagationContextImporter)
      +- comp.ejb3 (class: javax.naming.Context)
      | NonContext: null
      +- JmsXA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
      +- managedEntityFactories (class: org.jnp.interfaces.NamingContext)
      | +- manager1 (class: org.jboss.ejb3.entity.ManagedEntityManagerFactory)
      +- DefaultDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
      +- StdJMSPool (class: org.jboss.jms.asf.StdServerSessionPoolFactory)
      +- TransactionManager (class: org.jboss.tm.TxManager)
      +- RDMSDriverDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
      +- TransactionPropagationContextExporter (class: org.jboss.tm.TransactionPropagationContextFactory)
      +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
      +- DefaultJMSProvider (class: org.jboss.jms.jndi.JNDIProviderAdapter)
      +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
      +- EntityManagerFactories (class: org.jnp.interfaces.NamingContext)
      | +- manager1 (class: org.jboss.ejb3.entity.InjectedEntityManagerFactory)
      +- timedCacheFactory (class: javax.naming.Context)
      Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy
      +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
      +- ActualEntityManagerFactories (class: org.jnp.interfaces.NamingContext)
      | +- manager1 (class: org.hibernate.ejb.EntityManagerFactoryImpl)
      +- comp (class: javax.naming.Context)
      +- EntityManagers (class: org.jnp.interfaces.NamingContext)
      | +- manager1 (class: org.jboss.ejb3.entity.InjectedEntityManager)


      em1.par contents:

      META-INF/manifest.mf
      META-INF/persistence.xml
      <...all class files...>
      log4j.properties

      persistence.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <entity-manager>
      manager1
      <jta-data-source>java:/RDMSDriverDS</jta-data-source>














      </entity-manager>

      application.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE application PUBLIC
      "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
      "http://java.sun.com/dtd/application_1_3.dtd">


      <display-name>EJB3 LoadStudios tutorial</display-name>


      em1.par




      Client program (LoadStudioClient.java):

      InitialContext ctx = new InitialContext();
      LoadStudioBeanInterface lsbInterface
      = (LoadStudioBeanInterface) ctx.lookup(LoadStudioBeanInterface.class.getName());

      This lookup fails; here is the full stack trace:

      run:
      [copy] Copying 1 file to F:\jboss-403SP1-rdms-ejb3-rc3\examples\LoadStudios
      \build\classes
      [java] LoadStudiosClient(): doTask
      [java] LoadStudiosClient() done.
      [java] Exception in thread "main" java.lang.NoClassDefFoundError: [Lorg/jbo
      ss/aop/advice/Interceptor;
      [java] at java.lang.Class.getDeclaredFields0(Native Method)
      [java] at java.lang.Class.privateGetDeclaredFields(Class.java:2232)
      [java] at java.lang.Class.getDeclaredField(Class.java:1852)
      [java] at java.io.ObjectStreamClass.getDeclaredSUID(ObjectStreamClass.j
      ava:1555)
      [java] at java.io.ObjectStreamClass.access$600(ObjectStreamClass.java:4
      7)
      [java] at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:381)
      [java] at java.security.AccessController.doPrivileged(Native Method)
      [java] at java.io.ObjectStreamClass.(ObjectStreamClass.java:373)
      [java] at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:268)
      [java] at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java
      :504)
      [java] at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.
      java:1546)
      [java] at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.jav
      a:1460)
      [java] at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.
      java:1546)
      [java] at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.jav
      a:1460)
      [java] at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.
      java:1546)
      [java] at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.jav
      a:1460)
      [java] at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStrea
      m.java:1693)
      [java] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:
      1299)
      [java] at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream
      .java:1912)
      [java] at java.io.ObjectInputStream.readSerialData(ObjectInputStream.ja
      va:1836)
      [java] at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStrea
      m.java:1713)
      [java] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:
      1299)
      [java] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:3
      39)
      [java] at java.rmi.MarshalledObject.get(MarshalledObject.java:135)
      [java] at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePai
      r.java:57)
      [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:63
      7)
      [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:57
      2)
      [java] at javax.naming.InitialContext.lookup(InitialContext.java:351)
      [java] at com.demos.hibernatemoviesclients.LoadStudiosClient.doTask(Loa
      dStudiosClient.java:22)
      [java] at com.demos.hibernatemoviesclients.LoadStudiosClient.main(LoadS
      tudiosClient.java:63)
      [java] Java Result: 1

      BUILD SUCCESSFUL
      Total time: 5 seconds

      Here is LoadStudiosBeanInterface.java:


      package com.demos.hibernatemovies;

      import java.util.List;

      public interface LoadStudioBeanInterface {

      Studio loadStudio(String line);

      public Studio queryStudio(String studioName);

      public void flush();

      public void merge(Studio studio);


      }

      Here is LoadStudiosBean.java:


      package com.demos.hibernatemovies;

      import java.util.StringTokenizer;
      import javax.ejb.Remote;
      import javax.ejb.Stateless;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;
      import com.demos.hibernatemovies.Actor;
      import com.demos.hibernatemovies.Category;
      import com.demos.hibernatemovies.Movie;
      import com.demos.hibernatemovies.Studio;
      import com.demos.hibernatemovies.BasicQueries;
      import com.demos.hibernatemovies.LoadStudioBeanInterface;

      @Stateless
      @Remote(LoadStudioBeanInterface.class)
      public class LoadStudioBean implements LoadStudioBeanInterface, java.io.Serializable{

      @PersistenceContext(unitName="manager1") EntityManager manager1;

      public LoadStudioBean() {}


      public Studio loadStudio(String line) {
      System.out.println("StudioBean: loadStudio()");
      Studio studio = parseStudioData(line);
      System.out.println("StudioBean: loadStudio() done.");
      return studio;

      }

      public Studio parseStudioData(String line)
      {
      StringTokenizer tokenizer = new StringTokenizer(line, ";");
      String studioName = tokenizer.nextToken();
      studioName = studioName.trim();
      System.out.println(
      "Studio: " + studioName );

      Studio studio = BasicQueries.findStudioById(manager1, studioName);
      if (studio != null) {
      System.err.println("Duplicate studio: " + studioName);
      studio = null;
      return studio;
      }
      Studio studio2 = new Studio(studioName);

      // session.merge(studio2);
      manager1.persist(studio2);
      return studio2;
      }

      public Studio queryStudio(String studioName)
      {
      Studio studio = BasicQueries.findStudioById(manager1, studioName);
      if (studio != null)
      {
      System.out.println("queryStudio() found: " + studioName);
      }
      return studio;
      }

      public void flush()
      {
      manager1.flush();
      System.out.println("manager1.flush(): Done");
      }


      public void merge(Studio studio)
      {
      manager1.merge(studio);
      System.out.println("manager1.merge(studio): Done");
      }

      }

        • 1. Re: lookup failure
          Karen Ploski Newbie

          Solved the problem on my own. In case it may be of help to someone else, here's what I did:

          (1) in the client, changed ctx.lookup() to:
          InitialContext ctx = new InitialContext();
          LoadStudioBeanInterface lsbInterface =
          (LoadStudioBeanInterface) ctx.lookup("LoadStudioBeanInterface");

          (2) in the Bean, added:
          @RemoteBinding(jndiBinding="LoadStudioBeanInterface")

          The Bean already contained this code:
          @Stateless
          @Remote(LoadStudioBeanInterface.class)
          public class LoadStudioBean implements LoadStudioBeanInterface, java.io.Serializable{

          @PersistenceContext(unitName="manager1") EntityManager manager1;

          (3) in the CLASSPATH, I added
          jbossall-client.jar and
          all jars in server/all/deploy/jboss-aop.deployer

          Information that helped me:

          The documentation in
          http://docs.jboss.org/ejb3/app-server/tutorial/jndibinding/jndi.html

          A messages posted 'way back in June by another Forum user:
          Posted: Tue Jun 21, 2005 08:42 AM Post subject: Re: Unable to connect to Queue from remote client