• Post Reply Bookmark Topic Watch Topic
  • New Topic

javax naming NameNotFoundException

 
Joe qiang
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have one servlet to call a MDB to verify login information. I compile it and everything is fine. But when I run it, I got the javax.naming.NameNotFoundException. Here is the partial code for servlet:
String userName;
String userPw;
Queue replyQueue = null;
InitialContext ctx = null;
TopicConnectionFactory factory = null;
TopicConnection connection = null;
TopicSession session = null;
Topic topic = null;
TopicPublisher publisher = null;
TextMessage msg = null;
QueueConnectionFactory queueConnectionFactory = null;
QueueConnection queueConnection = null;
QueueSession qSession = null;
QueueReceiver qReceiver = null;
public void init(ServletConfig config) throws ServletException {
super.init(config);

}
public void service(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
try {
response.setContentType( "text/HTML" );
PrintWriter out = response.getWriter();
//Login login=null;
// Initialize JNDI
//Context ctx = new InitialContext(System.getProperties());
ctx = new InitialContext();
//Context ctx2 = new InitialContext(System.getProperties());
// 1: Lookup ConnectionFactory via JNDI
factory =
(TopicConnectionFactory)
ctx.lookup("javax.jms.TopicConnectionFactory");
// 2: Use ConnectionFactory to create JMS connection
connection =
factory.createTopicConnection();
// 3: Use Connection to create session
session = connection.createTopicSession(
false, Session.AUTO_ACKNOWLEDGE);
// 4: Lookup Desintation (topic) via JNDI
topic = (Topic) ctx.lookup("logtopic");
// 5: Create a Message Producer
publisher = session.createPublisher(topic);
// 6: Create a text message, and publish it
msg = session.createTextMessage();
// 1: Lookup ConnectionFactory via JNDI
queueConnectionFactory =
(QueueConnectionFactory)
ctx.lookup("javax.jms.QueueConnectionFactory");
// 2: Use ConnectionFactory to create JMS connection
queueConnection =
queueConnectionFactory.createQueueConnection();
// 3: Use Connection to create session
qSession = queueConnection.createQueueSession(
false, Session.AUTO_ACKNOWLEDGE);
replyQueue = qSession.createTemporaryQueue();
qReceiver = qSession.createReceiver(replyQueue);
//qReceiver.setMessageListener(new LogBean());
queueConnection.start();
//MapMessage m = null;
userName = request.getParameter("userName");
userPw = request.getParameter("Password");
if (userName.equals("")||userPw.equals("")){
response.sendRedirect("/CourseWebApp/login.jsp?message=novalue");
}
else{
msg.setText(userName+"$"+userPw);
msg.setJMSReplyTo(replyQueue);
publisher.publish(msg);
session.commit();
TextMessage inMessage = (TextMessage)qReceiver.receive();
System.out.println("message in: "+ inMessage.getText());
Here is the error message:
javax.naming.NameNotFoundException: Unable to resolve 'weblogic.jms.TempDestinat
ionFactory' Resolved: 'weblogic.jms' Unresolved:'TempDestinationFactory' ; remai
ning name 'TempDestinationFactory'
at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:17
4)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteR
ef.java:263)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteR
ef.java:230)
at weblogic.jndi.internal.ServerNamingNode_WLStub.lookup(Unknown Source)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:337)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:332)
at weblogic.jms.frontend.FEManager.getTemporaryDestinationFactory(FEMana
ger.java:118)
at weblogic.jms.frontend.FEConnection.createTemporaryDestination(FEConne
ction.java:1371)
at weblogic.jms.frontend.FEConnection.invoke(FEConnection.java:1514)
at weblogic.jms.dispatcher.Request.wrappedFiniteStateMachine(Request.jav
a:602)
at weblogic.jms.dispatcher.DispatcherImpl.dispatchSync(DispatcherImpl.ja
va:275)
at weblogic.jms.client.JMSSession.createTemporaryDestination(JMSSession.
java:1764)
at weblogic.jms.client.JMSSession.createTemporaryQueue(JMSSession.java:1
482)
at course.VerifyServlet.service(VerifyServlet.java:127)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:1058)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:401)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:306)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:5445)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServic
eManager.java:780)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:3105)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2588)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:213)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:189)
I checked the line number and found the server run into the problem in one line:
replyQueue = qSession.createTemporaryQueue();
To me, this code is fine. Could anyone tell me what is wrong? Thanks
 
Greg Charles
Sheriff
Posts: 3010
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's weird. It complains about looking up something called TempDestinationFactory, but the code you posted doesn't show you doing that. What line causes the error? (It's line 127 of VerifyServlet, but which one is that?)
 
Joe qiang
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It failed at this line:
replyQueue = qSession.createTemporaryQueue();
I believe qSession.createTemporaryQueue() will try to use TempDestinationFactory.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!