1 2 Previous Next 19 Replies Latest reply on Sep 12, 2006 11:51 AM by peterj

    java.naming.provider.url parsing problem?

    csturtz

      I'm running integration tests from outside of the JBoss AS and am using the "jndi.properties" file to access the context.

      I'm unable to ever get the connection because it seems there's a problem parsing the java.naming.provider.url value. I've tried many different values that i've found on the net.

      if i use "jnp://localhost:1099":

      javax.naming.CommunicationException: Could not obtain connection to any of these urls: "jnp://localhost:1099" and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server "jnp:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server "jnp:1099 [Root exception is java.net.UnknownHostException: "jnp: "jnp]]]
      at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1414)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:594)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
      at javax.naming.InitialContext.lookup(Unknown Source)
      at com.gestalt.gccsa.fp.adhoc.db.objectmanager.ws.FunctGroupObjectManager.getConnection(FunctGroupObjectManager.java:866)
      at com.gestalt.gccsa.fp.adhoc.db.objectmanager.ws.FunctGroupObjectManager.saveFunctGroupVersionObject(FunctGroupObjectManager.java:305)
      at com.gestalt.gccsa.fp.adhoc.db.objectmanager.ws.SqlQueryManagerTest.<clinit>(SqlQueryManagerTest.java:34)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at junit.framework.TestSuite.createTest(TestSuite.java:56)
      at junit.framework.TestSuite.addTestMethod(TestSuite.java:279)
      at junit.framework.TestSuite.<init>(TestSuite.java:142)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at org.apache.maven.surefire.junit.JUnitTestSet.constructTestObject(JUnitTestSet.java:148)
      at org.apache.maven.surefire.junit.JUnitTestSet.getTestCount(JUnitTestSet.java:244)
      at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.locateTestSets(AbstractDirectoryTestSuite.java:101)
      at org.apache.maven.surefire.Surefire.createSuiteFromDefinition(Surefire.java:147)
      at org.apache.maven.surefire.Surefire.run(Surefire.java:108)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:225)
      at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:747)
      Caused by: javax.naming.CommunicationException: Failed to connect to server "jnp:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server "jnp:1099 [Root exception is java.net.UnknownHostException: "jnp: "jnp]]
      at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:269)
      at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1385)
      ... 28 more
      Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server "jnp:1099 [Root exception is java.net.UnknownHostException: "jnp: "jnp]
      at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:243)
      ... 29 more
      Caused by: java.net.UnknownHostException: "jnp: "jnp
      at java.net.InetAddress.getAllByName0(Unknown Source)
      at java.net.InetAddress.getAllByName0(Unknown Source)
      at java.net.InetAddress.getAllByName(Unknown Source)
      at java.net.InetAddress.getByName(Unknown Source)
      at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:76)
      at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:239)


      what happend to the url for it to print this: [Root exception is java.net.UnknownHostException: "jnp: "jnp] ???


      I can list all the other values i've tried and their corresponding results, but that would take more time than i have right now. Before i go to all that trouble, are there any known problems with this? Is there something i'm missing?


      jndi.properties
      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.provider.url=jnp://localhost:1099
      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

        • 1. Re: java.naming.provider.url parsing problem?
          peterj

          Which OS are you using? If Linux, what is in your /etc/hosts file? Do you have an entry for localhost?

          If you telnet to port 1099 (telnet loachost 1099), what response do you get?

          • 2. Re: java.naming.provider.url parsing problem?
            csturtz

            OS is Windows XP

            here's the response i'm getting from: telnet localhost 1099

            ¼?sr?java.rmi.MarshalledObject|??ù?c?>??I?hashlocBytest?[BobjBytesq~?xp?ÆZöur?[B¼??°T??xp$¼?thttp://B-0319:8083/q~q~uq~??¼?sr org.jnp.server.NamingServer_Stub??xrjava.rmi.server.RemoteStub????ïße?xr?java.rmi.server.RemoteObject?a?æ
            a3??xpw5
            UnicastRef2
            Z 10.9.5.151?Jn??S?
            ?5Çx

            Connection to host lost.

            C:\>






            • 3. Re: java.naming.provider.url parsing problem?
              csturtz

              I was finally able to get a connection using some different properties. Here's the jndi.propperties I am now using:

              java.naming.factory.initial=org.jboss.naming.HttpNamingContextFactory
              java.naming.provider.url=http://localhost:8080/invoker/JNDIFactory
              java.naming.factory.url.=org.jboss.naming.client



              Now, I'm getting:
              javax.naming.NameNotFoundException: OracleDS not bound


              even though the log during jboss startup says that it's bound:
              11:33:47,819 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=OracleDS' to JNDI name 'java:OracleDS'


              Plus, i have no problems when running the actual web application. It's only during integration tests where I'm outside the JBoss JVM that I am having this problem. So, I know the data source is bound and can be used without problems.

              Here's the code getting the DS:
              InitialContext initialContext = new InitialContext();
              javax.sql.DataSource ds = (javax.sql.DataSource) initialContext.lookup("java:OracleDS");
              Connection connection = ds.getConnection();



              Ideas?

              • 4. Re: java.naming.provider.url parsing problem?
                peterj

                Change your jndi.properties file to read:

                java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
                java.naming.provider.url=jnp://localhost:1099
                java.naming.factory.url=org.jboss.naming:org.jnp.interfaces


                I hope I transcibed these correctly, I usually don't use a properties file preferring to set them in code.

                • 5. Re: java.naming.provider.url parsing problem?
                  csturtz

                  When i use the settings you've specified, I can't even get a connection, let alone try and get the data source. Those are the exact settings that I started out using, and gave me the exception that is posted in the first message of this thread.

                  Is there no way to get the DS with my current jndi.properties file (the only settings that i've been able to get a connection with)?

                  Thanks!

                  • 6. Re: java.naming.provider.url parsing problem?
                    peterj

                    If you change this one line:

                    java.naming.provider.url=localhost:1099


                    does it still not work?

                    The response you got from telnet looks correct, it is fairly similar to what I get. So port 1099 is listening. Can you also access port 1098? In this case, telnet should connect but not show any response.

                    If you want to use your jndi property file settings, try dumping out the contents of the namepsace. See my sample code in http://www.jboss.com/index.html?module=bb&op=viewtopic&t=89429

                    Also see http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3968093


                    • 7. Re: java.naming.provider.url parsing problem?
                      csturtz

                      When using that provder url i get:

                      javax.naming.CommunicationException [Root exception is java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
                      java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
                      java.net.MalformedURLException: no protocol: and]



                      Also, I added the code you linked that prints out all the bindings for "java:". However, I am getting a NoClassDefFound for the class: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory

                      I have yet to find the jar containing that class.

                      • 8. Re: java.naming.provider.url parsing problem?
                        peterj

                        How did you install JBoss? I am asking because the HiLoKeyGeneratorFactory class, while it is part of the source and gets compiled, it never gets placed into any of the jar files (it would be in jboss.jar since that contains the regular key generators).

                        • 9. Re: java.naming.provider.url parsing problem?
                          peterj

                          I used JNDVIew and I can see at least one HiLoKeyGeneratorFactory entry in the JNDI. So I guess that is normal. I still don't see how a class could exist without it being anywhere in the classpath, though. Found it. It is in server/default/deploy/uuid-key-generator.sar. Looks like I will have to enhance my class finder.

                          • 10. Re: java.naming.provider.url parsing problem?
                            csturtz

                            Ok. I got the list of bindings. This first list is printed while running the application in JBoss. You can see a binding with name "OracleDS" (the datasource i'm needing). The second list is printed while running my integration tests. There are no datasource bindings at all!



                            13:18:09,465 INFO [STDOUT] binding name=XAConnectionFactory
                            13:18:09,465 INFO [STDOUT] binding name=DefaultDS
                            13:18:09,465 INFO [STDOUT] binding name=SecurityProxyFactory
                            13:18:09,475 INFO [STDOUT] binding name=PostgresDS
                            13:18:09,475 INFO [STDOUT] binding name=OracleDS
                            13:18:09,475 INFO [STDOUT] binding name=DefaultJMSProvider
                            13:18:09,475 INFO [STDOUT] binding name=comp
                            13:18:09,475 INFO [STDOUT] binding name=JmsXA
                            13:18:09,475 INFO [STDOUT] binding name=ConnectionFactory
                            13:18:09,475 INFO [STDOUT] binding name=jaas
                            13:18:09,475 INFO [STDOUT] binding name=timedCacheFactory
                            13:18:09,475 INFO [STDOUT] binding name=TransactionPropagationContextExporter
                            13:18:09,475 INFO [STDOUT] binding name=StdJMSPool
                            13:18:09,475 INFO [STDOUT] binding name=Mail
                            13:18:09,475 INFO [STDOUT] binding name=TransactionPropagationContextImporter
                            13:18:09,475 INFO [STDOUT] binding name=TransactionManager


                            binding name=TopicConnectionFactory
                            binding name=jmx
                            binding name=HTTPXAConnectionFactory
                            binding name=ConnectionFactory
                            binding name=UserTransactionSessionFactor
                            binding name=HTTPConnectionFactory
                            binding name=XAConnectionFactory
                            binding name=UserTransaction
                            binding name=UILXAConnectionFactory
                            binding name=UIL2XAConnectionFactory
                            binding name=queue
                            binding name=topic
                            binding name=console
                            binding name=UIL2ConnectionFactory
                            binding name=HiLoKeyGeneratorFactory
                            binding name=UILConnectionFactory
                            binding name=EventDispatcher
                            binding name=QueueConnectionFactory
                            binding name=UUIDKeyGeneratorFactory


                            • 11. Re: java.naming.provider.url parsing problem?
                              peterj

                              The first list looks like what you typically get from the "java:" namepsace. The second list is from the default, or root, namespace. Not sure why you would get the root namepsace when you asked for "java:". I have a remote client around here somewhere. When I have a minute I will give it a try and let you know if that gives me any further insight into this issue.

                              • 12. Re: java.naming.provider.url parsing problem?
                                csturtz

                                I think I've figured it out. I found an article that states that any name under "java:" is restricted to use inside the JBoss JVM. Through a little more searching, I found that by adding the following to your *-ds.xml file, the "java:" will not be added infront of whatever you have defined in the <jndi-name> tag. I haven't confirmed this will fix my problem, but i have a good feeling it will. I'll post back with the results.

                                <use-java-context>false</use-java-context>


                                • 13. Re: java.naming.provider.url parsing problem?
                                  peterj

                                  Now that you mention it, the client app I have looks up EJB names in the root context. Never did look up data sources.

                                  • 14. Re: java.naming.provider.url parsing problem?
                                    csturtz

                                    I've run into another exception that doesn't provide much information. Line 881 of the following code is causing the error. Atleast i'm now getting past the lookup method!

                                    879 InitialContext initialContext = new InitialContext();
                                    880 javax.sql.DataSource ds = (javax.sql.DataSource) initialContext.lookup("OracleDS");
                                    881 Connection connection = ds.getConnection();


                                    org.apache.maven.surefire.booter.SurefireExecutionException: com.gestalt.gccsa.fp.adhoc.db.objectmanager.ws.SqlQueryManagerTest; nested excepti
                                    org.apache.maven.surefire.testset.TestSetFailedException: com.gestalt.gccsa.fp.adhoc.db.objectmanager.ws.SqlQueryManagerTest; nested exception
                                    java.lang.ExceptionInInitializerError
                                    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                                    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
                                    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
                                    at java.lang.reflect.Constructor.newInstance(Unknown Source)
                                    at junit.framework.TestSuite.createTest(TestSuite.java:56)
                                    at junit.framework.TestSuite.addTestMethod(TestSuite.java:279)
                                    at junit.framework.TestSuite.<init>(TestSuite.java:142)
                                    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                                    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
                                    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
                                    at java.lang.reflect.Constructor.newInstance(Unknown Source)
                                    at org.apache.maven.surefire.junit.JUnitTestSet.constructTestObject(JUnitTestSet.java:148)
                                    at org.apache.maven.surefire.junit.JUnitTestSet.getTestCount(JUnitTestSet.java:244)
                                    at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.locateTestSets(AbstractDirectoryTestSuite.java:101)
                                    at org.apache.maven.surefire.Surefire.createSuiteFromDefinition(Surefire.java:147)
                                    at org.apache.maven.surefire.Surefire.run(Surefire.java:108)
                                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                                    at java.lang.reflect.Method.invoke(Unknown Source)
                                    at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:225)
                                    at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:747)
                                    Caused by: java.lang.reflect.UndeclaredThrowableException
                                    at $Proxy1.getConnection(Unknown Source)
                                    at com.gestalt.gccsa.fp.adhoc.db.objectmanager.ws.FunctGroupObjectManager.getConnection(FunctGroupObjectManager.java:881)
                                    at com.gestalt.gccsa.fp.adhoc.db.objectmanager.ws.FunctGroupObjectManager.saveFunctGroupVersionObject(FunctGroupObjectManager.java:308)
                                    at com.gestalt.gccsa.fp.adhoc.db.objectmanager.ws.SqlQueryManagerTest.<clinit>(SqlQueryManagerTest.java:34)
                                    ... 22 more
                                    Caused by: java.rmi.MarshalException: error marshalling arguments; nested exception is:
                                    java.net.SocketException: Software caused connection abort: socket write error
                                    at sun.rmi.server.UnicastRef.invoke(Unknown Source)
                                    at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
                                    at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:133)
                                    at org.jboss.invocation.InvokerInterceptor.invokeInvoker(InvokerInterceptor.java:331)
                                    at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:194)
                                    at org.jboss.proxy.ClientMethodInterceptor.invoke(ClientMethodInterceptor.java:74)
                                    at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100)
                                    ... 26 more
                                    Caused by: java.net.SocketException: Software caused connection abort: socket write error
                                    at java.net.SocketOutputStream.socketWrite0(Native Method)
                                    at java.net.SocketOutputStream.socketWrite(Unknown Source)
                                    at java.net.SocketOutputStream.write(Unknown Source)
                                    at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
                                    at java.io.BufferedOutputStream.write(Unknown Source)
                                    at java.io.ObjectOutputStream$BlockDataOutputStream.drain(Unknown Source)
                                    at java.io.ObjectOutputStream$BlockDataOutputStream.writeByte(Unknown Source)
                                    at java.io.ObjectOutputStream.writeFatalException(Unknown Source)
                                    at java.io.ObjectOutputStream.writeObject(Unknown Source)
                                    at sun.rmi.server.UnicastRef.marshalValue(Unknown Source)


                                    1 2 Previous Next