【发布时间】:2011-08-11 09:39:25
【问题描述】:
我正在尝试创建 Restful Webservice 作为 Message Driven Bean 的客户端,但是当我调用 restful 方法时,它给了我以下错误
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)
下面是代码:
// Inside class declaration
@Resource(mappedName = "jms/testFactory")
private static ConnectionFactory connectionFactory;
@Resource(mappedName = "jms/test")
private static Queue queue;
网络服务方法
@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>";
}
我需要在 sun-web.xml 或 web.xml 中指定任何内容吗?
【问题讨论】:
-
NullPointerException 说它发生在第 99 行。上面的第 99 行是哪一行?
-
连接连接 = connectionFactory.createConnection();是行号 99
标签: web-services rest jms ejb nullpointerexception