service层文件:
public class FnMongoEntityLogicImpl implements FnEntityLogic {
private BaseMongoDao dao;
public BaseMongoDao getDao() {
return dao;
}
public void setDao(BaseMongoDao dao) {
this.dao = dao;
}
@Override
public void addEntityList(List<FnEntity> entityList) {
dao.addEntityList(entityList);
}
}
dao层文件:
public class BaseMongoDaoImpl implements BaseMongoDao {
private static final Log logger = LogFactory.getLog(BaseMongoDaoImpl.class);
protected MongoTemplate mongoTemplate;
//get、set方法省略了。。。。
@Override
public String addEntity(FnEntity entity) {
entity.initAddInfo();
//Write operations that use this write concern will wait for acknowledgement from the primary server before returning.
mongoTemplate.setWriteConcern(WriteConcern.FSYNC_SAFE);
mongoTemplate.insert(entity);
// mongoTemplate.save(entity, collectionName);
return entity.getId();
}
}
配置文件:
<bean id=”baseMongoDao” class=”com.moxi.forum.framework.mongo.dao.BaseMongoDaoImpl”>
<!–<constructor-arg name=”mongoDbFactory” ref=”mongoDbFactory” />–>
<property name=”mongoTemplate” ref=”mongoTemplate”></property>
</bean>
<bean id=”mongoLogic” class=”com.moxi.forum.framework.logic.FnMongoEntityLogicImpl”>
<property name=”dao” ref=”baseMongoDao”></property>
<property name=”pageDao” ref=”fnPageBaseMongoDao”></property>
<property name=”fileDao” ref=”fileMongoDao”></property>
</bean>
2014-09-28 16:33:18,751 DEBUG [com.moxi.forum.framework.interceptor.servlet.FnDispatcherServlet] – Handler execution resulted in exception – forwarding to resolved error view: ModelAndView: reference to view with name “”/error””; model is {exception=java.lang.NullPointerException}
java.lang.NullPointerException
at com.moxi.forum.framework.logic.FnMongoEntityLogicImpl.addEntity(FnMongoEntityLogicImpl.java:64)
at com.moxi.forum.post.logic.PostingLogicImpl.addPost(PostingLogicImpl.java:29)
at com.moxi.forum.post.controller.PostController.addPost(PostController.java:110)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at com.moxi.forum.framework.interceptor.servlet.FnDispatcherServlet.doService(FnDispatcherServlet.java:28)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
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.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
2014-09-28 16:33:18,761 DEBUG [com.moxi.forum.framework.interceptor.servlet.FnDispatcherServlet] – Rendering view [org.springframework.web.servlet.view.JstlView: name “”/error””; URL [/page//error.jsp]] in DispatcherServlet with name “”spring””
2014-09-28 16:33:18,818 DEBUG [com.moxi.forum.framework.interceptor.servlet.FnDispatcherServlet] – Successfully completed request