我想創建RESTful Web服務作爲驅動Bean消息的客戶端,但是當我調用RESTful方法它給我以下錯誤,當無法從RESTful Web服務
Connection connection = connectionFactory.createConnection();
SEVERE: The RuntimeException could not be mapped to a response, re-throwing to the HTTP container
java.lang.NullPointerException
at com.quant.ws.GetConnection.startThread(GetConnection.java:99)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
這裏是調用的messge豆下面的代碼:
// Inside class declaration
@Resource(mappedName = "jms/testFactory")
private static ConnectionFactory connectionFactory;
@Resource(mappedName = "jms/test")
private static Queue queue;
Web服務方法
@GET
@Path("startThread")
@Produces("application/xml")
public String startThread()
{
try{
Connection connection = connectionFactory.createConnection(); // its line number 99
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(queue);
Message message = session.createTextMessage();
message.setStringProperty("name", "start");
producer.send(message);
}catch(JMSException e){
System.out.println(e);
}
return "<data>START</data>";
}
我是否需要指定anyt在sun-web.xml或web.xml中進行操作?
的NullPointerException異常說,它發生在99線也就是上面一行99解決了嗎? – 2011-04-23 08:30:20
Connection connection = connectionFactory.createConnection();是行號99 – Hunt 2011-04-23 08:50:14