刚开始使用JAX-WS。我创建了服务类和DAO类。我的服务运行正常,但它给NullPointerExeption b'coz它找不到DAO;我试图从服务类调用DAO:
package com.nmmc.works.service.impl;
@WebService(serviceName="MyService")
public class SecurityServiceImpl extends GenericServiceImpl implements ISecurityService
{
private ISecurityDAO securityDAO;
....getter setter methods....
@WebMethod
public Integer getBidAcceptanceIdForSDPayment(Integer tMastNo)
{
InternalResultsResponse<Object> response = getSecurityDAO().getMyMethod(tenderMastNo);
if(response != null && response.getResultsList().size() > 0){
return Integer.parseInt(response.getFirstResult().toString());
}else{
return -1;
}
}
和sun-jaxws.xml .....
<b>
<?xml version="1.0" encoding="UTF-8"?>
<endpoints version="2.0" xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime">
<endpoint
implementation="com.nmmc.works.service.impl.SecurityDepositServiceImpl"
name="MyServices"
url-pattern="myPath/SecurityServiceImpl"
/>
</endpoints></b>
在web.xml ....
<b><listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>WebServices</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>WebServices</servlet-name>
<url-pattern>/ws/*</url-pattern>
</servlet-mapping></b>
答案 0 :(得分:1)
运行时,SecurityServiceImpl中没有DAO。您必须确保正确创建DAO并将其注入/获取。