Skip to main content

Glassfish JMS - No object bound to name java:comp/env/jms

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
3 replies [Last post]
cthinkel
Offline
Joined: 2012-03-22

Hello,
I'm attempting to deploy a SmartGWT application in Glassfish and I'm receiving the following error:

?javax.naming.NameNotFoundException: No object bound to name java:comp/env/jms
at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:772)
at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:744)
at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:169)
at com.isomorphic.messaging.JMSMessageDispatcher.reconnect(JMSMessageDispatcher.java:78)
at com.isomorphic.messaging.JMSMessageDispatcher.ensureConnected(JMSMessageDispatcher.java:100)
at com.isomorphic.messaging.JMSMessageDispatcher.subscribe(JMSMessageDispatcher.java:131)
at com.isomorphic.messaging.ISCMessageDispatcher.subscribe(ISCMessageDispatcher.java:149)
at com.isomorphic.messaging.MessagingConnectionHandler.registerSubscriber(MessagingConnectionHandler.java:282)
at com.isomorphic.messaging.MessagingConnectionHandler.process(MessagingConnectionHandler.java:114)
at com.isomorphic.messaging.MessagingServlet.doPost(MessagingServlet.java:91)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:246)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)

I have the following defined in domain.xml:

<jdbc-resource pool-name="__TimerPool" jndi-name="jdbc/__TimerPool" object-type="system-admin"></jdbc-resource>
<jdbc-resource pool-name="DerbyPool" jndi-name="jdbc/__default"></jdbc-resource>
<jdbc-connection-pool datasource-classname="org.apache.derby.jdbc.EmbeddedXADataSource" res-type="javax.sql.XADataSource" name="__TimerPool">
<property name="databaseName" value="${com.sun.aas.instanceRoot}/lib/databases/ejbtimer"></property>
<property name="connectionAttributes" value=";create=true"></property>
</jdbc-connection-pool>
<jdbc-connection-pool is-isolation-level-guaranteed="false" datasource-classname="org.apache.derby.jdbc.ClientDataSource" res-type="javax.sql.DataSource" name="DerbyPool">
<property name="PortNumber" value="1527"></property>
<property name="Password" value="APP"></property>
<property name="User" value="APP"></property>
<property name="serverName" value="localhost"></property>
<property name="DatabaseName" value="sun-appserv-samples"></property>
<property name="connectionAttributes" value=";create=true"></property>
</jdbc-connection-pool>
<admin-object-resource res-adapter="jmsra" res-type="javax.jms.Topic" jndi-name="jms/EventScheduleTopic" class-name="com.sun.messaging.Topic">
<property name="Name" value="jms/EventScheduleTopic"></property>
</admin-object-resource>
<connector-connection-pool max-pool-size="250" steady-pool-size="1" name="jms/TopicConnectionFactory" resource-adapter-name="jmsra" connection-definition-name="javax.jms.TopicConnectionFactory"></connector-connection-pool>
<connector-resource pool-name="jms/MyTopicConnectionFactory" jndi-name="jms/MyTopicConnectionFactory"></connector-resource>

Any help would be appreciated.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
cf126330
Offline
Joined: 2005-03-29

If you want to look up by its global jndi name:

lookup("jms/TopicConnectionFactory"); //use the jndi-name you assigned to it when creating this resource, see domain.xml

If you want to look up a resource reference in the webapp's component environment:

lookup("java:comp/env/jms/TopicConnectionFactory");

you will also need to declare a <resource-ref> or <message-destination-ref>, depends on the type of jms resources, in your web.xml

-cheng

cthinkel
Offline
Joined: 2012-03-22

I added the following to the web.xml and it resolved the NameNotFoundException:

<!-- JMS Connection Factories (java:comp/env/jms) -->
<resource-ref>
<description>MyTopicConnectionFactory</description>
<res-ref-name>jms/MyTopicConnectionFactory</res-ref-name>
<res-type>javax.jms.TopicConnectionFactory</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<description>EventScheduleTopic</description>
<res-ref-name>jms/EventScheduleTopic</res-ref-name>
<res-type>javax.jms.Topic</res-type>
<res-auth>Container</res-auth>

Now I'm getting to following exception:


javax.naming.CommunicationException: Communication exception for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming, com.sun.enterprise.naming.logicalName=java:comp/env/jms/EventScheduleTopic} [Root exception is com.sun.appserv.connectors.internal.api.PoolingException]
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:542)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at com.sun.enterprise.naming.util.JndiNamingObjectFactory.create(JndiNamingObjectFactory.java:90)
at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:776)
at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:744)
at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:169)
at com.isomorphic.messaging.JMSMessageDispatcher.bindToChannel(JMSMessageDispatcher.java:105)
at com.isomorphic.messaging.JMSMessageDispatcher.reconnect(JMSMessageDispatcher.java:95)
at com.isomorphic.messaging.JMSMessageDispatcher.ensureConnected(JMSMessageDispatcher.java:100)
at com.isomorphic.messaging.JMSMessageDispatcher.subscribe(JMSMessageDispatcher.java:131)
at com.isomorphic.messaging.ISCMessageDispatcher.subscribe(ISCMessageDispatcher.java:149)
at com.isomorphic.messaging.MessagingConnectionHandler.registerSubscriber(MessagingConnectionHandler.java:282)
at com.isomorphic.messaging.MessagingConnectionHandler.process(MessagingConnectionHandler.java:114)
at com.isomorphic.messaging.MessagingServlet.doPost(MessagingServlet.java:91)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:246)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)
Caused by: com.sun.appserv.connectors.internal.api.PoolingException
at com.sun.enterprise.resource.beans.AdministeredObjectResource.createAdministeredObject(AdministeredObjectResource.java:204)
at com.sun.enterprise.resource.naming.AdministeredObjectFactory.getObjectInstance(AdministeredObjectFactory.java:134)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:556)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:514)
... 47 more
Caused by: java.security.PrivilegedActionException: com.sun.appserv.connectors.internal.api.ConnectorRuntimeException
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.enterprise.resource.beans.AdministeredObjectResource.createAdministeredObject(AdministeredObjectResource.java:181)
... 51 more
Caused by: com.sun.appserv.connectors.internal.api.ConnectorRuntimeException
at com.sun.enterprise.connectors.util.SetMethodAction.handleException(SetMethodAction.java:152)
at com.sun.enterprise.connectors.util.SetMethodAction.run(SetMethodAction.java:136)
... 53 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor558.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.enterprise.connectors.util.SetMethodAction.run(SetMethodAction.java:105)
... 53 more
Caused by: java.lang.IllegalArgumentException: MQ:Topic:Invalid Topic Name - jms/EventScheduleTopic
at com.sun.messaging.Topic.setName(Topic.java:96)

In Glassfish, I have the following JMS Resources defined:
Connection Factories:
jms/MyTopicConnectionFactory

Destination Resources:
jms/EventScheduleTopic

cthinkel
Offline
Joined: 2012-03-22

Nevermind, I fixed that issue - I had to change the Phyiscal Destination Name in JMS destination resource of glassfish from jms/EventScheduleTopic to EventScheduleTopic. By default it made both the JNDI name and the Physical Destination Name the same (jms/EventScheduleTopic).

Thank you