6 Replies Latest reply on Nov 12, 2006 10:53 PM by philipwu

    Problems accessing jndi from war (not embedded in ear)

    frer

      Hello,

      I am trying to migrate from Jboss4.0.2 to 4.0.5GA but am having jndi problems.

      My application is deployed with three files in the $jboss/server/default/deploy:

      - application.ear
      - application.war
      - application-ds.xml

      The war contains all the client jars it needs to access the ear file which has its datasource defined in the *-ds.xml file.

      When I run a TestCase which tries to access the ear services, I have no problems. i.e:

      Object objRef = new InitialContext().lookup(LocalizationSessionFacadeHome.JNDI_NAME);
       LocalizationSessionFacadeHome sessionHome = (LocalizationSessionFacadeHome) PortableRemoteObject.narrow(objRef, LocalizationSessionFacadeHome.class);
      
       return sessionHome.create();
      


      but when the web application (war) tries to access my ear services, I get the following error:

      16:05:51,406 ERROR [STDERR] Caused by: java.lang.ClassCastException
      16:05:51,406 ERROR [STDERR] at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java
      :229)
      16:05:51,406 ERROR [STDERR] at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
      16:05:51,406 ERROR [STDERR] at org.mdarad.global.ServiceLocatorBase.getLocalizationFacade(ServiceLocatorBase.java:33
      77)
      16:05:51,406 ERROR [STDERR] ... 27 more
      16:05:51,406 ERROR [STDERR] Caused by: java.lang.ClassCastException: $Proxy566
      16:05:51,406 ERROR [STDERR] at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java
      :212)
      16:05:51,406 ERROR [STDERR] ... 29 more


      It has to be some sort of configuration I need to set up in order to get this to work but I can't figure out which one.

      Any help would be greatly appreciated.

      Thanks,

      François

        • 1. Re: Problems accessing jndi from war (not embedded in ear)
          xnuandax

          Hi,

          I have the same problem with JBoss 4.0.5 (ClassCastException when trying to narrow an EJB interface retrieved via a JNDI lookup).

          As with you, my WAR and EJB are colocated in a single Jboss instance.

          I figured setting "Call by Value" semantics everywhere would fix this (assuming the usual JBoss flat-classloader issues) - however that did not resolve the problem in 4.0.5 !?!?

          Have you made any further progress ??

          • 2. Re: Problems accessing jndi from war (not embedded in ear)
            frer

            Hi,

            Yeah I actually got it to work. I modified some configurations. You can see the details here:

            http://mail-archive.com/mdarad-toolbox-devs%40lists.sourceforge.net/msg00127.html

            Hope this helps,

            Francois

            • 3. Re: Problems accessing jndi from war (not embedded in ear)
              xnuandax

              Thanks Francois,

              It seems you just mod'd the CallByValue semantics per your instructions:

              - default/deploy/ear-deployer.xml
               - Isolated => true
               - CallByValue => true
              - default/conf/jboss-service.xml
               - NamingService: CallByValue => true
              - default/conf/jboss-minimal.xml
               - NamingService: CallByValue => true


              This makes sense to do, however this references files that don't appear in my JBoss4.0.5GA - because I used the "jems-installer-1.2.0BETA3.jar" when I set up JBoss (and it re-arranges config files all over the shop for some reason).

              I used the jems-installer to basically turn on "EJB3" mode in JBoss 4.0.5GA. Is there a better way of achieving EJB3/JEE5 in JBoss 4.0.5GA without using the jems-installer (I don't like the way it mangles the JBoss config files) ??

              Many thanks,

              David


              • 4. Re: Problems accessing jndi from war (not embedded in ear)
                frer

                Hmmm...sorry David. That's where my knowledge stops. I haven't yet used EJB3 and don't know anything about jems.

                • 5. Re: Problems accessing jndi from war (not embedded in ear)
                  philipwu

                  hi i used the installer as well to take advantage of ejb3 and im having the same ClassCastException when narrowing. Have you been able to solve this?

                  Thanx

                  • 6. Re: Problems accessing jndi from war (not embedded in ear)
                    philipwu

                    i found a way around it, and it was a change to the way I initizlied my jndi context.

                    before i was doing:
                    Properties p = new Properties();
                    p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
                    p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
                    p.put(Context.PROVIDER_URL, "jnp://localhost:1099");
                    return new InitialContext(p);

                    now i just simply returned new InitialContext() without the properties.