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

      <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>



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

        • 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
          Remove "application"
          2. ServiceLocator.java
          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

          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