2 Replies Latest reply on Mar 11, 2005 2:11 AM by wong sc

    Call remote EJB on other JBoss from web

    wong sc Newbie

      Hi all,
      as title, I can access remote EJB through standalone client, but failed for web client. All in jboss-4.0.0.

      Exception thrown is ClassCastException when casting to EJBHome.
      Source failed on PortableRemoteObject.narrow(...)

      Below is my config. any hints? thanks much
      jboss-service.xml

      <mbean code="org.jboss.naming.ExternalContext" name="jboss.jndi:service=ExternalContext,jndiName=time/arr/UstCourseInfoService">
       <attribute name="JndiName">time/arr/UstCourseInfoService</attribute>
       <attribute name="Properties">jnp.properties</attribute>
       <attribute name="InitialContext">javax.naming.InitialContext</attribute>
       </mbean>


      jnp.properties
      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.provider.url=jnp://myremotehost:1099/time/arr/UstCourseInfoService
      java.naming.factory.url.pkgs=org.jnp.interfaces

      jboss-web.xml

      <ejb-ref>
      <ejb-ref-name>time/arr/UstCourseInfoService</ejb-ref-name> <jndi-name>jnp://myremotehost:1099/application/time/arr/UstCourseInfoService</jndi-name>
      </ejb-ref>


        • 1. Re: Call remote EJB on other JBoss from web
          wong sc Newbie

          Solved it but even not require ExternalContext.

          Changes :
          1. jboss-web.xml
          <jndi-name>jnp://myremotehost:1099/time/arr/UstCourseInfoService</jndi-name>
          Remove "application"
          2. ServiceLocator.java
          java:comp/env/time/arr/UstCourseInfoService
          Add "java:comp/env/

          Yet, my scheduler in SAR still can't access remote EJB with
          javax.naming.NameNotFoundException: env not bound

          Following workarounds failed :
          1. package WAR into SAR (hope to able to use jboss-web.xml JNDI)
          2. add

          <depends>jboss.j2ee:service=EJB,jndiName=time/arr/UstCourseInfoService</depends>
          
          into jboss-service.xml of SAR

          Any help? thanks much

          • 2. Re: Call remote EJB on other JBoss from web
            wong sc Newbie

            Fixed by setup InitialContext in code without java:comp/env

            Since ServiceLocator.getRemoteHome is centralized.
            add utility method StackTrace.findInStackTrace(String classNamePattern)
            to distinguish the caller from WEB or SAR.

            Also JAAS is added for both case.

            Thanks anyway