2017-03-05 09:24:35,378 [http-8080-2] WARN org.nutz.mvc.impl.processor.FailProcessor - Error@/dsjk/list :
java.lang.NullPointerException
at com.webro.service.impl.T_dwdsjkServiceImpl.list(T_dwdsjkServiceImpl.java:27)
at com.webro.module.T_dwdsjkModule.list(T_dwdsjkModule.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:25)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:198)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:617)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1760)
at java.lang.Thread.run(Thread.java:744)
//下面是控制层,注入service
@IocBean
@At("/dsjk")
@Ok("json")
@Fail("http:500")
public class T_dwdsjkModule {
@Inject
private T_dwdsjkService dwdsjkService ;
@At
public Object list(@Param("page") int page, @Param("pageSize") int pageSize){
Map<String, Object> res = this.dwdsjkService.list(page,pageSize);
return res;
}
//下面是Service的实现类,注入了DAO (这里是不是有问题)
@IocBean
public class T_dwdsjkServiceImpl implements T_dwdsjkService {
@Inject
private T_dwdsjkDAO dwdsjkDAO;
@Override
public Map<String, Object> list(int page, int size) {
List list = this.dwdsjkDAO.list(page, size);
int count = this.dwdsjkDAO.listcount();
Map<String, Object> res = new HashMap<String, Object>();
res.put("Rows", list);
res.put("pages", count);
return res;
}
}
//下面是DAO的实现类,继承了BaseDAOImpl,BaseDAOImpl中注入了dao数据源(这里没问题)
@IocBean
public class T_dwdsjkDAOImpl extends BaseDAOImpl implements T_dwdsjkDAO {
@Override
public List list(int page, int size) {
Pager pager = this.dao.createPager(page, size);
List list = this.dao.query(T_dwdsjk.class , null, pager);
return list;
}
@Override
public int listcount() {
List query = this.dao.query(T_dwdsjk.class,null);
if(query == null) {
return 0;
}else {
return query.size();
}
}
}
//加 了
@IocBean
public class BaseDAOImpl implements BaseDAO{
private Class clazz;
@Inject
public Dao dao;
@SuppressWarnings("unchecked")
public BaseDAOImpl() {
clazz = (Class) ((ParameterizedType) this.getClass()
.getGenericSuperclass()).getActualTypeArguments()[0];
}
@Override
public void save(T t) {
dao.insert(t);
}