如题,调用service存入list报错
查询数据库
public List getBankRecordFromDataBase() {
NutMap re = new NutMap();
Sql sql = Sqls.create("SELECT * FROM bank_record_detail");
System.out.println(sql);
sql.setCallback(new SqlCallback() {
public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
List<bank_record_detail> list = new ArrayList<bank_record_detail>();
while (rs.next()) {
bank_record_detail b = new bank_record_detail();
b.setAccount(rs.getString("account"));
b.setAccountType(rs.getString("accounttype"));
b.setId(rs.getString("id"));
list.add(b);
}
return list;
}
});
dao().execute(sql);
List<String> list = sql.getList(String.class);
return list;
}
package cn.wizzer.common.webservice;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.By;
import org.nutz.mvc.annotation.Filters;
import cn.wizzer.common.filter.PrivateFilter;
import cn.wizzer.common.util.ListToXml;
import cn.wizzer.modules.back.reconciliation.models.bank_record_detail;
import cn.wizzer.modules.back.reconciliation.services.bank_record_detailService;
import cn.wizzer.modules.back.sw.services.PrisonInformationService;
import net.sf.ehcache.search.Results;
@IocBean
@WebService
@Filters({@By(type = PrivateFilter.class)})
public class WebImpl implements Web{
@Inject
PrisonInformationService prisoninformationservice;
@Inject
Dao dao;
private ListToXml lox = new ListToXml();
@Override
@WebMethod
public String xml_test(String words) {
String ars="<resultRow>\r\n" +
" <result comment=\"JYDM\" property=\"JYDM\">2201</result>\r\n" +
" <result comment=\"JYMC\" property=\"JYMC\">��������</result>\r\n" +
" <result comment=\"STRUCTURE_CODE\" property=\"STRUCTURE_CODE_NEW\">22010001</result>\r\n" +
" <result comment=\"ELEMENT_ID\" property=\"ELEMENT_ID\">8a8081863efeeaab013efeeaab940000</result>\r\n" +
" <result comment=\"ELEMENT_ORDER\" property=\"ELEMENT_ORDER\">2</result>\r\n" +
" </resultRow>";
return ars;
}
@WebMethod
public String sayHi(@WebParam(name = "text") String text) {
return "Hello,"+text;
}
/**
* @return
* @throws Exception
*/
@RequiresAuthentication
public String fromBean() throws Exception {
List list ;
//此处报错
list = prisoninformationservice.getBankRecordFromDataBase();
String x = lox.parseNodeToXML(list);
return x;
}
}
异常 日志
严重: null
java.lang.NullPointerException
at cn.wizzer.common.webservice.WebImpl.fromBean(WebImpl.java:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.xml.internal.ws.api.server.MethodUtil.invoke(MethodUtil.java:68)
at com.sun.xml.internal.ws.api.server.InstanceResolver$1.invoke(InstanceResolver.java:235)
at com.sun.xml.internal.ws.server.InvokerTube$2.invoke(InvokerTube.java:134)
at com.sun.xml.internal.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:73)
at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:1121)
at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:1035)
at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:1004)
at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:862)
at com.sun.xml.internal.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:404)
at com.sun.xml.internal.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:706)
at com.sun.xml.internal.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:260)
at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handleExchange(WSHttpHandler.java:98)
at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handle(WSHttpHandler.java:82)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:82)
at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:675)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:647)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
```