You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by "tom@hostwebase.com" <to...@hostwebase.com> on 2007/06/15 20:06:34 UTC
Some Issues with JNDI. Please Help
Hi,
I have some issues with JNDI, ActiveMQ and Tomcat.
I already downloaded JNDI taglib and configured it.
Here is the content of the file ROOT/META-INF/context.xml
////////begin//////////////////
<Context antiJARLocking="true">
<Resource
name="jms/ConnectionFactory"
auth="Container"
type="org.activemq.ActiveMQConnectionFactory"
description="JMS Connection Factory"
factory="org.activemq.jndi.JNDIReferenceFactory"
brokerURL="tcp://192.168.0.227:61616"
brokerName="LocalActiveMQBroker"
useEmbeddedBroker="false"/>
<Resource name="jms/topic/MyTopic"
auth="Container"
type="org.activemq.message.ActiveMQTopic"
factory="org.activemq.jndi.JNDIReferenceFactory"
physicalName="TEST.FOO"/>
<Resource name="topic/text"
auth="Container"
type="java.lang.String"
physicalName="TEST.FOO"/>
</Context>
/////////end///////////////////
I have a message consumer waiting for topic "TEST.FOO". This consumer is
the one from ActiveMQ website's example. I already test and this consumer
can receive the message from the producer that locates in the same machine
we install tomcat.
Here is the content of the jsp file that works as a message producer.
////////////Begin//////////////
<%@ taglib uri="http://jakarta.apache.org/taglibs/jndi" prefix="jndi" %>
<%@ page import="javax.naming.*"%>
<%@ page import="javax.jms.*"%>
<%
int i;
try {
InitialContext initCtx = new InitialContext();
Context envContext = (Context) initCtx.lookup("java:comp/env");
ConnectionFactory connectionFactory = (ConnectionFactory)
envContext.lookup("jms/ConnectionFactory");
Connection connection = connectionFactory.createConnection();
javax.jms.Session session1 = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session1.createProducer((Destination)
envContext.lookup("jms/topic/MyTopic"));
Message testMessage = session1.createMessage();
for (i=0; i<10; i++) {
testMessage.setStringProperty("testKey", "testValue");
producer.send(testMessage);
}
} catch (NamingException e) {
// TODO handle exception
} catch (JMSException e) {
// TODO handle exception
}
///////////End//////////
I have the feeling that we have problems with JNDI. So I try with a simple
test as follow
///////////Begin another simple test//////////////
<%@ taglib uri="http://jakarta.apache.org/taglibs/jndi" prefix="jndi" %>
<%@ page import="javax.naming.*"%>
<%@ page import="javax.jms.*"%>
<%
String temp;
temp = "1";
try {
InitialContext initCtx = new InitialContext();
Context envContext = (Context) initCtx.lookup("java:comp/env");
} catch (NamingException e) {
// TODO handle exception
}
temp = (String) envContext.lookup("topic/text"); // I bring this one out
of try block code to see the error
%>
I run this
<%=temp%>
///////////End another simple test//////////////
And I get the error
///////////Begin Error Message/////////////////////
type Exception report
message
description The server encountered an internal error () that prevented it
from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 5 in the jsp file: /test.jsp
Generated servlet error:
envContext cannot be resolved
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 5 in the jsp file: /test.jsp
Generated servlet error:
envContext cannot be resolved
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache
Tomcat/5.5.17 logs.
////////////End Error Message/////////////////////
Can you help me ?
Thanks a lot.
--
View this message in context: http://www.nabble.com/Some-Issues-with-JNDI.-Please-Help-tf3929495s2354.html#a11144858
Sent from the ActiveMQ - User mailing list archive at Nabble.com.