You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by stevegula <st...@stevegula.net> on 2010/03/05 02:35:40 UTC
tomcat+jndi+activemq namingexception cannot create resource
instance
tomcat 6.0.20
activemq 5.3.0
the following are in tomcat/lib :
activemq-all
geronimo j2ee management 1.0
geronimo jms 1.1
geronimo jta 1.0.1B
commons httpclient 3.1
this is in a portlet running in openportal within tomcat
web.xml
----------
<resource-ref>
<res-ref-name>jms/ConnectionFactory</res-ref-name>
<res-type>org.apache.activemq.ActiveMQConnectionFactory</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<res-ref-name>jms/MyAppQueue</res-ref-name>
<res-type>org.apache.activemq.command.ActiveMQQueue</res-type>
<res-auth>Container</res-auth>
</resource-ref>
context.xml
----------
<Context>
<Resource
name="jms/ConnectionFactory"
auth="Container"
type="org.apache.activemq.ActiveMQConnectionFactory"
description="JMS Connection Factory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
brokerURL="tcp://localhost:61616"
brokerName="LocalActiveMQBroker"
useEmbeddedBroker="false" />
<Resource name="jms/MyAppQueue"
auth="Container"
type="org.apache.activemq.command.ActiveMQQueue"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
physicalName="MyApp.queue" />
</Context>
the code
------
public void sendMessageToQueue(String submitId, String capabilitiesURL)
{
logger.debug("sendMessageToQueue start");
Context jndiContext = null;
ConnectionFactory connectionFactory = null;
Connection connection = null;
Session session = null;
Destination destination = null;
MessageProducer producer = null;
String destinationName = "MyApp";
TextMessage message = null;
try
{
Context initCtx = new InitialContext();
jndiContext = (Context) initCtx.lookup("java:comp/env");
connectionFactory = (ConnectionFactory)
jndiContext.lookup("jms/ConnectionFactory");
destination = (Destination) jndiContext.lookup("jms/MyAppQueue");
connection = connectionFactory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
producer = session.createProducer(destination);
message = session.createTextMessage();
// message.setText(submitId+"|"+capabilitiesURL);
message.setStringProperty("submitId", submitId);
message.setStringProperty("capabilitiesURL", capabilitiesURL);
logger.debug("Message for queue : "+message.getText());
producer.send(message);
}
catch(NamingException e)
{
logger.debug("Naming exception : ",e);
}
catch(JMSException e)
{
logger.debug("Message exception : ",e);
}
finally
{
if(connection != null)
{
try
{
logger.debug("connection.toString() - "+connection.toString());
connection.close();
}
catch(JMSException e)
{
logger.debug("Failed to close - ",e);
}
}
}
logger.debug("sendMessageToQueue end");
}
the problem -
the line -> connectionFactory = (ConnectionFactory)
jndiContext.lookup("jms/ConnectionFactory");
is causing
javax.naming.NamingException: Cannot create resource instance
at
org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceF
actory.java:143)
I have spent roughly 10 hours on this now. I have searched all of Google,
Nabble, activemq/tomcat.apache.org ... all I can find is people more or less
asking "what have I done wrong" but I have not found anyone offering a
solution. The best documentation I can find on apache.org contains the
phrase "This is completely untested but should work" ... and it does not.
At one point I thought I was nearing success by doing the "Look Inside this
Book" on Amazon.com looking at "Tomcat: The Definitive Guide (Paperback)"
but ultimately that did not work either. My Junit tests (in Eclipse using
jndi.properties) all work with no problem. When I try doing this within
tomcat w/ web.xml and context.xml it fails horribly.
Any input would be desperately appreciated.
--
View this message in context: http://old.nabble.com/tomcat%2Bjndi%2Bactivemq--namingexception-cannot-create-resource-instance-tp27788969p27788969.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: tomcat+jndi+activemq namingexception cannot create resource
instance
Posted by mschaefer <mi...@destatis.de>.
Looking for a way to make ActiveMQ use PooledConnectionFactory through JNDI I
came across your post
and http://www.mail-archive.com/users@tomcat.apache.org/msg66249.html that
one which may not help solve your issue but possibly delivers an
explanation.
Michael
stevegula wrote:
>
> I have spent roughly 10 hours on this now. I have searched all of Google,
> Nabble, activemq/tomcat.apache.org ... all I can find is people more or
> less asking "what have I done wrong" but I have not found anyone offering
> a solution. The best documentation I can find on apache.org contains the
> phrase "This is completely untested but should work" ... and it does not.
> At one point I thought I was nearing success by doing the "Look Inside
> this Book" on Amazon.com looking at "Tomcat: The Definitive Guide
> (Paperback)" but ultimately that did not work either. My Junit tests (in
> Eclipse using jndi.properties) all work with no problem. When I try doing
> this within tomcat w/ web.xml and context.xml it fails horribly.
>
> Any input would be desperately appreciated.
>
--
View this message in context: http://old.nabble.com/tomcat%2Bjndi%2Bactivemq--namingexception-cannot-create-resource-instance-tp27788969p27944216.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.