2 Replies Latest reply on Feb 7, 2007 12:46 PM by Xiaofeng Xu

    What is happening?...  DefaultDS?

    Randall Fields Newbie

      Greetings Gurus!

      I am having difficulty referencing the DefaultDS from a
      client running outside the JBoss JVM. Any advice or examples would be greatly
      appreciated. I am running JBoss version 4.0.5GA. I eventually want to load
      and use the datasource in the client application. For simplicity of example,
      I set up a default JBoss install. It seems that I do not have access
      to anything in the java: context from outside the JBoss JVM. Are there
      security constraints that need to be modified?

      Here is my source code:

      ---

      import java.util.*;
      import javax.naming.*;

      public class JNDI {

      public static void main(String[] args) {
      try {
      Context ic = new InitialContext();

      // Print the environment settings
      System.out.println("Printing environment keys:");
      Hashtable hash = ic.getEnvironment();
      Enumeration keys = hash.keys();
      while (keys.hasMoreElements()) {
      Object key = keys.nextElement();
      Object value = hash.get(key);
      System.out.println(key + "=" + value);
      }

      // We can see several bindings, just not the ones we need
      System.out.println();
      System.out.println("Printing bindings in jmx:");
      NamingEnumeration b = ic.listBindings("jmx");
      while ( b.hasMoreElements() ) {
      Object key = b.nextElement();
      System.out.println(key);
      }

      System.out.println();
      System.out.println("Get the default datasource:");

      // Both of the following lines choke:
      // b = ic.listBindings("");
      // Context compEnv = (Context) ic.lookup("java:/DefaultDS");
      }
      catch (Exception e) {
      e.printStackTrace();
      }
      }
      }

      ---

      The first few lines of output look like:

      Printing environment keys:
      jnp.parsedName=
      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.provider.url=localhost:1099
      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

      Printing bindings in jmx:
      invoker:
      org.jnp.interfaces.NamingContext:org.jnp.interfaces.NamingContext@a4e743
      rmi: org.jnp.interfaces.NamingContext:org.jnp.interfaces.NamingContext@4aeb52

      ---

      The "listBindings" call throws the following stack dump:

      Get the default datasource:
      javax.naming.CommunicationException [Root exception is
      java.lang.ClassNotFoundException:
      org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory (no security
      manager: RMI class loader disabled)]
      at org.jnp.interfaces.NamingContext.listBindings(NamingContext.java:853)
      at org.jnp.interfaces.NamingContext.listBindings(NamingContext.java:821)
      at javax.naming.InitialContext.listBindings(InitialContext.java:406)
      at JNDI.main(JNDI.java:42)
      Caused by: java.lang.ClassNotFoundException:
      org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory (no security
      manager: RMI class loader disabled)
      at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:371)
      at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:165)
      at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:620)
      at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:247)
      at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:197)
      at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1544)
      at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1699)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
      at java.rmi.MarshalledObject.get(MarshalledObject.java:135)
      at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:72)
      at org.jnp.interfaces.NamingContext.listBindings(NamingContext.java:849)
      ... 3 more

      ---

      The "ic.lookup("java:/DefaultDS")" throws the following stack trace:

      javax.naming.NameNotFoundException: DefaultDS not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
      at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
      at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
      at sun.reflect.GeneratedMethodAccessor105.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
      at sun.rmi.transport.Transport$1.run(Transport.java:153)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
      at java.lang.Thread.run(Thread.java:595)
      at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
      at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
      at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
      at javax.naming.InitialContext.lookup(InitialContext.java:351)
      at JNDI.main(JNDI.java:43)

      ---

      I am certain that the DefaultDS is up and running since the out of the box
      examples work, however they are all running inside JBoss. I have tried many
      many things to no avail.

      ---

      The XML view from the jboss4guide prints the following
      > ant -Dchap=chap2 -Dex=4 run-example

      JNDIView Class: org.jboss.mx.modelmbean.XMBean
      JNDIView Operations:
      + java.lang.String list(boolean jboss:service=JNDIView)
      + java.lang.String listXML()
      + void create()
      + void start()
      + void stop()
      + void destroy()
      + void jbossInternalLifecycle(java.lang.String jboss:service=JNDIView)
      JNDIView.list(true) output:
      <h1>Web Applications</h1>
      <h2>java:comp namespace of the console-mgr.sar/web-console.war application:</h2>

      +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
      +- ORB (class: org.jacorb.orb.ORB)
      +- env (class: org.jnp.interfaces.NamingContext)
      | +- security (class: org.jnp.interfaces.NamingContext)
      | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
      | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
      | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
      | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)

      <h2>java:comp namespace of the jbossws14.sar/jbossws-context.war application:</h2>

      +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
      +- ORB (class: org.jacorb.orb.ORB)
      +- env (class: org.jnp.interfaces.NamingContext)
      | +- security (class: org.jnp.interfaces.NamingContext)
      | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
      | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
      | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
      | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)

      <h2>java:comp namespace of the jmx-console.war application:</h2>

      +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
      +- ORB (class: org.jacorb.orb.ORB)
      +- env (class: org.jnp.interfaces.NamingContext)
      | +- security (class: org.jnp.interfaces.NamingContext)
      | | +- realmMapping[link -> java:/jaas/jmx-console] (class: javax.naming.LinkRef)
      | | +- subject[link -> java:/jaas/jmx-console/subject] (class: javax.naming.LinkRef)
      | | +- securityMgr[link -> java:/jaas/jmx-console] (class: javax.naming.LinkRef)
      | | +- security-domain[link -> java:/jaas/jmx-console] (class: javax.naming.LinkRef)

      <h2>java:comp namespace of the http-invoker.sar/invoker.war application:</h2>

      +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
      +- ORB (class: org.jacorb.orb.ORB)
      +- env (class: org.jnp.interfaces.NamingContext)
      | +- security (class: org.jnp.interfaces.NamingContext)
      | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
      | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
      | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
      | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)

      <h2>java:comp namespace of the jbossweb-tomcat55.sar/ROOT.war application:</h2>

      +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
      +- ORB (class: org.jacorb.orb.ORB)
      +- env (class: org.jnp.interfaces.NamingContext)
      | +- security (class: org.jnp.interfaces.NamingContext)
      | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
      | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
      | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
      | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)

      <h2>java:comp namespace of the jbossmq-httpil.sar/jbossmq-httpil.war application:</h2>

      +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
      +- ORB (class: org.jacorb.orb.ORB)
      +- env (class: org.jnp.interfaces.NamingContext)
      | +- security (class: org.jnp.interfaces.NamingContext)
      | | +- realmMapping[link -> java:/jaas/jbossmq] (class: javax.naming.LinkRef)
      | | +- subject[link -> java:/jaas/jbossmq/subject] (class: javax.naming.LinkRef)
      | | +- securityMgr[link -> java:/jaas/jbossmq] (class: javax.naming.LinkRef)
      | | +- security-domain[link -> java:/jaas/jbossmq] (class: javax.naming.LinkRef)

      <h1>java: Namespace</h1>

      +- jaas (class: javax.naming.Context)
      | +- HsqlDbRealm (class: org.jboss.security.plugins.SecurityDomainContext)
      | +- jmx-console (class: org.jboss.security.plugins.SecurityDomainContext)
      | +- jbossmq (class: org.jboss.security.plugins.SecurityDomainContext)
      | +- JmsXARealm (class: org.jboss.security.plugins.SecurityDomainContext)
      +- TransactionPropagationContextImporter (class: org.jboss.tm.TransactionPropagationContextImporter)
      +- JmsXA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
      +- JBossCorbaNaming (class: org.omg.CosNaming.NamingContextExt)
      +- DefaultDS (class: javax.sql.DataSource)
      +- StdJMSPool (class: org.jboss.jms.asf.StdServerSessionPoolFactory)
      +- TransactionManager (class: org.jboss.tm.TxManager)
      +- JBossCorbaPOA (class: org.omg.PortableServer.POA)
      +- TransactionPropagationContextExporter (class: org.jboss.tm.TransactionPropagationContextFactory)
      +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
      +- DefaultJMSProvider (class: org.jboss.jms.jndi.JNDIProviderAdapter)
      +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
      +- JBossCorbaInterfaceRepositoryPOA (class: org.omg.PortableServer.POA)
      +- Mail (class: javax.mail.Session)
      +- JBossCorbaORB (class: org.omg.CORBA.ORB)
      +- timedCacheFactory (class: javax.naming.Context)
      Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy
      +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
      +- comp (class: javax.naming.Context)

      <h1>Global JNDI Namespace</h1>

      +- HASessionState (class: org.jnp.interfaces.NamingContext)
      | +- Default (class: org.jboss.ha.hasessionstate.server.HASessionStateImpl)
      +- TopicConnectionFactory (class: org.jboss.naming.LinkRefPair)
      +- jmx (class: org.jnp.interfaces.NamingContext)
      | +- invoker (class: org.jnp.interfaces.NamingContext)
      | | +- RMIAdaptor (proxy: $Proxy49 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
      | +- rmi (class: org.jnp.interfaces.NamingContext)
      | | +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef)
      +- HTTPXAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
      +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
      +- UserTransactionSessionFactory (proxy: $Proxy12 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
      +- HTTPConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
      +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
      +- invokers (class: org.jnp.interfaces.NamingContext)
      | +- dionysus (class: org.jnp.interfaces.NamingContext)
      | | +- iiop (class: org.jboss.invocation.iiop.IIOPInvoker)
      +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
      +- UILXAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
      +- UIL2XAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
      +- HAPartition (class: org.jnp.interfaces.NamingContext)
      | +- DefaultPartition (class: org.jboss.ha.framework.server.HAPartitionImpl)
      +- queue (class: org.jnp.interfaces.NamingContext)
      | +- A (class: org.jboss.mq.SpyQueue)
      | +- testQueue (class: org.jboss.mq.SpyQueue)
      | +- ex (class: org.jboss.mq.SpyQueue)
      | +- DLQ (class: org.jboss.mq.SpyQueue)
      | +- D (class: org.jboss.mq.SpyQueue)
      | +- C (class: org.jboss.mq.SpyQueue)
      | +- B (class: org.jboss.mq.SpyQueue)
      +- topic (class: org.jnp.interfaces.NamingContext)
      | +- testDurableTopic (class: org.jboss.mq.SpyTopic)
      | +- testTopic (class: org.jboss.mq.SpyTopic)
      | +- securedTopic (class: org.jboss.mq.SpyTopic)
      +- console (class: org.jnp.interfaces.NamingContext)
      | +- PluginManager (proxy: $Proxy50 implements interface org.jboss.console.manager.PluginManagerMBean)
      +- UIL2ConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
      +- HiLoKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory)
      +- UILConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
      +- QueueConnectionFactory (class: org.jboss.naming.LinkRefPair)
      +- UUIDKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGeneratorFactory)

      <h1>HA-JNDI Namespace</h1>



      ---

      I really want to use JBoss, and eventually lend my support to the efforts
      surrounding what appears to be an awesome project, but I am beginning to
      have doubts in my choice as I have been trying to get this to work for
      some time. What am I doing wrong?

      I am completely confused. Please advise.

      Thanks,
      Randall


        • 1. Re: What is happening?...  DefaultDS?
          jaikiran pai Master

          You are right, you cannot access the java: context from outside the server JVM. And that's the reason why you are not able to access the DefaultDS, which gets bound to the java: namepsace. Have a look at:

          http://wiki.jboss.org/wiki/Wiki.jsp?page=HowCanIAccessADataSourceFromAClient

          • 2. Why JBoss always look for DefaultPartition for bound even I
            Xiaofeng Xu Newbie

            I set up a JBoss4.0.5 (ejb3-clustered installation) cluster with 3 nodes, and I use the following:
            "run -Djboss.partition.name=newPartition -c a11"


            I received the following log info:

            11:36:26,544 ERROR [URLDeploymentScanner] Incomplete Deployment listing:

            --- MBeans waiting for other MBeans ---
            ObjectName: jboss.j2ee:ear=CMgmt.ear,jar=CMgmt.jar,name=CManagerImpl,service=EJB3
            State: FAILED
            Reason: javax.naming.NameNotFoundException: DefaultPartition not bound
            I Depend On:
            persistence.units:ear=CMgmt.ear,jar=CMgmt.jar,unitName=CMgmt

            --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
            ObjectName: jboss.j2ee:ear=CMgmt.ear,jar=CMgmt.jar,name=CManagerImpl,service=EJB3
            State: FAILED
            Reason: javax.naming.NameNotFoundException: DefaultPartition not bound
            I Depend On:
            persistence.units:ear=CMgmt.ear,jar=CMgmt.jar,unitName=CMgmt

            When I use "run -c all" all problem gone. How can I setup the partition name correctly?

            Thanks a lot.