2 Replies Latest reply on May 20, 2010 8:59 AM by New Close

    JBoss 4 to JBoss 5 (JNDI question)

    New Close Newbie

      I've searched, but haven't seen anyone bring up this issue... so I'm assuming we have a configuration problem.  We're trying to test our code with JBoss 5 (jboss-5.1.0.GA), and have run into trouble when looking up the datasource (DefaultDS and XAOracleDS) in JNDI. It appears in the JMX console:

       

      java: Namespace


        +- securityManagement (class: org.jboss.security.integration.JNDIBasedSecurityManagement)
        +- comp (class: javax.namingMain.Context)
        +- DeploymentManager (class: org.jboss.aop.generatedproxies.AOPProxy$4)
        +- policyRegistration (class: org.jboss.security.plugins.JBossPolicyRegistration)
        +- TransactionPropagationContextImporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
        +- app (class: org.jnp.interfaces.NamingContext)
        |   +- Manager (class: javax.inject.manager.Manager)
        +- Mail (class: javax.mail.Session)
        +- TransactionPropagationContextExporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
        +- DefaultDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
        +- jaas (class: javax.naming.Context)
        |   +- profileservice (class: org.jboss.security.plugins.SecurityDomainContext)
        +- TransactionSynchronizationRegistry (class: com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple)
        +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
        +- XAOracleDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
        +- DefaultJMSProvider (class: org.jboss.jms.jndi.JNDIProviderAdapter)
        +- TransactionManager (class: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate)
        +- timedCacheFactory (class: javax.naming.Context)
      Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy cannot be cast to javax.naming.NamingEnumeration
        +- ManagementView (class: org.jboss.aop.generatedproxies.AOPProxy$3)

       

      but in the code all we see is:

       

      Using bound name < java: > found class < javax.namingMain.Context > with object name < comp >

      Using bound name < java: > found class < org.jnp.interfaces.NamingContext > with object name < app >

      Using bound name < java: > found class < javax.inject.manager.Manager > with object name < Manager >

      Using bound name < java: > found class < org.jboss.security.SubjectSecurityProxyFactory > with object name < SecurityProxyFactory >

      Using bound name < java: > found class < javax.naming.Context > with object name < timedCacheFactory >

       

      which appears to be a subset of the available objects.  The above log statements were output by:

       

         Context context =  new InitialContext();

         listContext(context, "java:");

       

        private void listContext(Context ctx, String bName)

         {

              try

              {

                  NamingEnumeration<Binding> list = ctx.listBindings(bName);

                  while (list.hasMore())

                  {

                      Binding item = (Binding) list.next();

                      String className = item.getClassName();

                      String objectName = item.getName();

                      log.info("Using bound name < " + bName + " > found class < "

                              + className + " > with object name < " + objectName + " >");

                      Object o = item.getObject();

                      if (o instanceof javax.naming.Context)

                      {

                          listContext((Context) o, bName);

                      }

                  }

             }

              catch (NamingException ex)

              {

                  log.warn("JNDI failure: ", ex);

              }

         }

       

      There were no errors and/or warnings at this point in our code.  Any help would be appreciated.  Thanks in advance.

        • 1. Re: JBoss 4 to JBoss 5 (JNDI question)
          New Close Newbie

          I was able to look into this some more, and reproduced the problem without using any of our legacy code.  Creating a simple SAR with a single mbean (Simple) showed the behavior.  When the mbean's "preRegister" method is invoked by the application server it calls the same code in JNDIView (used to display the names registered in "java:").  So when JBoss is first started it shows a partial list:

           

           

          10:09:07,400 INFO  [Simple]
          This Context name: <>
          +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
          +- app (class: org.jnp.interfaces.NamingContext)
          |   +- Manager (class: javax.inject.manager.Manager)
          +- comp (class: javax.namingMain.Context)
          +- timedCacheFactory (class: javax.naming.Context)
          Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy

           

           

          when the SAR is then "hot deployed", it shows the complete list:

           

           

          10:17:23,003 INFO  [Simple]
          This Context name: <>
          +- XAOracleDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
          +- DefaultDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
          +- policyRegistration (class: org.jboss.security.plugins.JBossPolicyRegistration)
          +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
          +- app (class: org.jnp.interfaces.NamingContext)
          |   +- Manager (class: javax.inject.manager.Manager)
          +- comp (class: javax.namingMain.Context)
          +- TransactionPropagationContextExporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
          +- TransactionManager (class: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate)
          +- timedCacheFactory (class: javax.naming.Context)
          Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy
          +- ManagementView (class: org.jboss.aop.generatedproxies.AOPProxy$3)
          +- jaas (class: javax.naming.Context)
          |   +- profileservice (class: org.jboss.security.plugins.SecurityDomainContext)
          +- TransactionPropagationContextImporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
          +- DeploymentManager (class: org.jboss.aop.generatedproxies.AOPProxy$4)
          +- Mail (class: javax.mail.Session)
          +- TransactionSynchronizationRegistry (class: com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple)
          +- DefaultJMSProvider (class: org.jboss.jms.jndi.JNDIProviderAdapter)
          +- securityManagement (class: org.jboss.security.integration.JNDIBasedSecurityManagement)

           

          So I'm assuming that we need to put the SAR into some type of dependency file, so that it only loads *after* the system is fully "up"?

          • 2. Re: JBoss 4 to JBoss 5 (JNDI question)
            New Close Newbie

            Got the SAR to work after creating a new directory, "deploy.last", inside the deploy directory.  Found this mentioned here:

             

                 http://www.datadisk.co.uk/html_docs/java_app/jboss5/jboss5_deployment.htm

             

            and here:

             

                 http://www.mastertheboss.com/en/jboss-howto/42-jboss-config/86-jboss-deploy-application.html