7 Replies Latest reply on May 29, 2013 9:38 AM by jaikiran

    During migration from AS7.1.1 final to EAP6.1 beta remote lookup fails with ClassCastException

    nabitashka

      Hi everyone,

      we're in a middle of migration to JBoss EAP6.1 from JBoss AS7.1.1 because of the memory leake issue:

      https://community.jboss.org/thread/220655

       

      But now, in EAP6.1 beta remote lookups fails with the following exception:

      java.lang.ClassCastException: org.jboss.naming.remote.client.RemoteContext cannot be cast to javax.jms.ConnectionFactory

       

      This code perfectly worked in AS7.1.1 final.

      Any ideas what's missing?

       

      I have the jboss-eap-6.1\bin\client\jboss-client.jar in the class path.

      The lookup code is:

      Properties jndiProps = new Properties();

                          jndiProps.put("java.naming.security.principal", "applicationRealmUser");

                          jndiProps.put("java.naming.security.credentials", "applicationRealmPwd1!");

                          jndiProps.put("java.naming.provider.url", "remote://localhost:4447");

                          jndiProps.put("java.naming.factory.initial", "org.jboss.naming.remote.client.InitialContextFactory");

                          jndiProps.put("jboss.naming.client.ejb.context",true);

       

                          try {

                                    InitialContext context = new InitialContext(jndiProps);

                                    ConnectionFactory factory =  (ConnectionFactory) context.lookup("ConnectionFactoryPersistent");

                                    System.out.println(factory);

                          } catch (Exception e) {

                                    System.out.println("Error " + e);

                          }

        • 1. Re: During migration from AS7.1.1 final to EAP6.1 beta remote lookup fails with ClassCastException
          jaikiran

          ConnectionFactory factory =  (ConnectionFactory) context.lookup("");

          Is that real code? I don't see how someone would expect a ConnectionFactory to be returned when the lookup is being passed an empty string on the context root.

          • 2. Re: During migration from AS7.1.1 final to EAP6.1 beta remote lookup fails with ClassCastException
            nabitashka

            Sorry, of cause not, I pass the factory name as it's written in the JNDI, will try to update the post

            • 3. Re: During migration from AS7.1.1 final to EAP6.1 beta remote lookup fails with ClassCastException
              nabitashka

              Can it be that my specific ObjectFactory.getObjectInstance method is not called?

              Should I define it somewhere?

              • 4. Re: During migration from AS7.1.1 final to EAP6.1 beta remote lookup fails with ClassCastException
                nabitashka

                It looks like it's a real defect in JBoss.

                I created some very simple class and ObjectFactory:

                 

                {code}

                public class Fruit implements Referenceable {

                          String fruit;

                 

                          public Fruit(String f) {

                                    fruit = f;

                          }

                 

                          public Reference getReference() throws NamingException {

                                    return new Reference(

                                                        Fruit.class.getName(),

                                                        new StringRefAddr("fruit", fruit),

                                                        FruitFactory.class.getName(),

                                                        null);

                          }

                 

                          public String toString() {

                                    return fruit;

                          }

                }

                 

                 

                public class FruitFactory implements ObjectFactory {

                          @Override

                          public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception {

                                    Reference localObject1;

                                    if (obj instanceof Reference) {

                                              localObject1 = (Reference) obj;

                                              Object fruit = localObject1.get("fruit").getContent();

                                              return new Fruit((String)fruit);

                                    } else {

                                              return obj;

                                    }

                          }

                }

                {code}

                 

                I bind the object into JNDI, when I lookup for this object inside JBoss the right ObjectFactory is called and I get Fruit as a result:

                 

                {code}

                Fruit f = new Fruit("apple");

                context.bind("apple", f);

                Fruit f1 = (Fruit)context.lookup("apple");

                {code}

                 

                But when I do the lookup from remote client, I get the Reference object and not the Fruit, look like the FruitFactory is never called.

                 

                Can it be a real defect?

                Maybe there is someone for him the remote lookups are woking?

                Was it tested?

                • 5. Re: During migration from AS7.1.1 final to EAP6.1 beta remote lookup fails with ClassCastException
                  jaikiran

                  So you are binding some object to the context and then trying to look it up? What exactly are you looking up and why are you binding it? Isn't it made available by the server?

                  • 6. Re: During migration from AS7.1.1 final to EAP6.1 beta remote lookup fails with ClassCastException
                    nabitashka

                    Hi,

                    thanks for your response.

                     

                    What do you mean by "Isn't it made available by the server"?

                    We have multi-processes application with JMS.

                    During JBoss startup we write JMS Connection Facories and some Queues/Topics into JBoss JNDI,

                    when many processes, not only JBoss, can access the JMS by lookup for the needed Connection Factory - this is why we need the remote lookups working.

                     

                    This functionality worked very well in JBoss4 and JBoss AS7.1.1 final and seems to be broken in JBoss EAP6 Alfa (and Beta)

                    • 7. Re: During migration from AS7.1.1 final to EAP6.1 beta remote lookup fails with ClassCastException
                      jaikiran

                      Natasha Biryukov wrote:

                       

                       

                      This functionality worked very well in JBoss4 and JBoss AS7.1.1 final and seems to be broken in JBoss EAP6 Alfa (and Beta)

                       

                      Please file a JIRA https://issues.jboss.org/browse/WFLY with the relevant details and if possible a reproducible application.