救命啊,在weblogic8.1里配置jms怎么不行啊

zhaoyutong 2008-06-30 09:00:30
我用的myeclipse5.0,ecplispe3.2,jdk是weblogic的
在工程里已经包含了weblogic。jar
已经配置好了JMS factory,store,queue
package jms.consumer;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.QueueReceiver;
import javax.jms.TextMessage;
import javax.naming.NamingException;
public class JMSConsumer {
private JMSTemplet templet = null;

private QueueReceiver receiver = null;

public JMSConsumer() throws NamingException, JMSException {
templet = new JMSTemplet();
templet.initEnv();
}

public void consume() throws NamingException, JMSException {
receiver = templet.createReceiver();
Message msg = receiver.receive();
if (msg.getClass().equals(TextMessage.class)) {
TextMessage tmsg = (TextMessage) msg;
System.out.println(tmsg.getText());
}

}

public void close() throws NamingException, JMSException {
receiver.close();
templet.close();
}

/**
* @param args
*/
public static void main(String[] args) throws NamingException, JMSException {
JMSConsumer consumer = new JMSConsumer();
consumer.consume();
consumer.close();
}

}


package jms.consumer;

import javax.jms.JMSException;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueReceiver;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class JMSTemplet {

private QueueConnectionFactory connf = null;

private QueueConnection conn = null;

private QueueSession session = null;

private Context ctx = null;

private String FACTOYR_JNDI_NAME = "jms/SendJMSFactory";

private String QUEUE_JNDI_NAME = "jms/SendJMSQueue";

public void initEnv() throws NamingException, JMSException {
SetENV.setENV();
ctx = new InitialContext();
connf = (QueueConnectionFactory) ctx.lookup(FACTOYR_JNDI_NAME);
conn = connf.createQueueConnection();
session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
System.out.println(ctx.getClass().getName());
System.out.println(connf.getClass().getName());
System.out.println(conn.getClass().getName());
System.out.println(session.getClass().getName());
}

public Queue getQueue() throws JMSException {
return session.createQueue(QUEUE_JNDI_NAME);
}

public QueueReceiver createReceiver() throws JMSException {
return session.createReceiver(getQueue());
}

public QueueSender createSender() throws JMSException {
return session.createSender(getQueue());
}

public TextMessage createTextMessage(String msg) throws JMSException
{
TextMessage tmsg = session.createTextMessage();
tmsg.setText(msg);
return tmsg;
}

public void close() throws JMSException, NamingException {
session.close();
conn.close();
ctx.close();
}
}






package jms.consumer;
import javax.naming.Context;

public class SetENV {

public static void setENV()
{
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
System.setProperty(Context.PROVIDER_URL, "t3://localhost:7001" );
}
}




package jms.producer;

import javax.jms.JMSException;
import javax.jms.QueueSender;
import javax.jms.TextMessage;
import javax.naming.NamingException;

import jms.consumer.JMSTemplet;


public class JMSProducer {
private JMSTemplet templet = null;

private QueueSender sender = null;

public JMSProducer() throws NamingException, JMSException {
templet = new JMSTemplet();
templet.initEnv();
}

public void product(String msg) throws NamingException, JMSException {
sender = templet.createSender();

TextMessage tmsg = templet.createTextMessage(msg);
sender.send(tmsg);

}

public void close() throws NamingException, JMSException {
sender.close();
templet.close();
}

/**
* @param args
*/
public static void main(String[] args) throws NamingException, JMSException {

JMSProducer prod = new JMSProducer();
prod.product("hello");
prod.close();
}

}


为什么我一运行就报下边的错误
javax.naming.InitialContext
weblogic.jms.client.JMSConnectionFactory
weblogic.jms.client.JMSConnection
weblogic.jms.client.JMSSession
Exception in thread "main" weblogic.jms.common.JMSException: Error creating destination
at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:108)
at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:137)
at weblogic.jms.dispatcher.DispatcherImpl_814_WLStub.dispatchSyncNoTranFuture(Unknown Source)
at weblogic.jms.dispatcher.DispatcherWrapperState.dispatchSyncNoTran(DispatcherWrapperState.java:472)
at weblogic.jms.client.JMSSession.createDestination(JMSSession.java:2043)
at weblogic.jms.client.JMSSession.createQueue(JMSSession.java:1511)
at jms.consumer.JMSTemplet.getQueue(JMSTemplet.java:50)
at jms.consumer.JMSTemplet.createSender(JMSTemplet.java:58)
at jms.producer.JMSProducer.product(JMSProducer.java:29)
at jms.producer.JMSProducer.main(JMSProducer.java:47)
Caused by: weblogic.jms.common.JMSException: Error creating destination
at weblogic.jms.frontend.FEManager.destinationCreate(FEManager.java:300)
at weblogic.jms.frontend.FEManager.invoke(FEManager.java:539)
at weblogic.jms.dispatcher.Request.wrappedFiniteStateMachine(Request.java:643)
at weblogic.jms.dispatcher.DispatcherImpl.dispatchAsyncInternal(DispatcherImpl.java:132)
at weblogic.jms.dispatcher.DispatcherImpl.dispatchSyncNoTranFuture(DispatcherImpl.java:262)
at weblogic.jms.dispatcher.DispatcherImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
Caused by: javax.naming.NameNotFoundException: Unable to resolve 'weblogic.jms.backend.jms' Resolved weblogic.jms.backend; remaining name 'jms'
at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:897)
at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:230)
at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:154)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:188)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:196)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:196)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:196)
at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:256)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:359)
at weblogic.jms.frontend.FEManager.destinationCreate(FEManager.java:298)
... 13 more

...全文
274 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhaoyutong 2008-07-03
  • 打赏
  • 举报
回复
没人说话啊

1,220

社区成员

发帖
与我相关
我的任务
社区描述
企业软件 中间件技术
社区管理员
  • 中间件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧