servlet中访问seam组件 报错

我想在我写的servlet里面访问seam组件

protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
			 String	pass=req.getParameter("pass");
			 String name=req.getParameter("name");
			 
			 //访问seam组件   下面在别的地方可以--在本servlet里面访问不到
			 final EmployeeQuery employeeQuery = (EmployeeQuery) Component.getInstance(EmployeeQuery.class); //报错 在seam容器里面这里不会报错
			 //Object object=Component.getInstance("com.sunning.cross.ui.resources.client.rpc.SecurityService");
			 SecurityServiceImpl security=(SecurityServiceImpl) Component.getInstance(SecurityServiceImpl.class);
			 if(security.isLogin()){
				 
			 }else {
				 security.login(name, pass);
				 resp.sendRedirect("/Explorer.seam"); 
			 }
			 
	}


下面是错误信息

16:05:02,437 ERROR [[AutoLoginServlet]] Servlet.service() for servlet AutoLoginServlet threw exception
java.lang.IllegalStateException: No application context active
at org.jboss.seam.Component.forName(Component.java:1945)
at org.jboss.seam.Component.getInstance(Component.java:2005)
at org.jboss.seam.Component.getInstance(Component.java:1983)
at org.jboss.seam.Component.getInstance(Component.java:1977)
at org.jboss.seam.Component.getInstance(Component.java:1957)
at org.jboss.seam.Component.getInstance(Component.java:1952)
at com.sunning.cross.ui.explorer.server.servlet.AutoLoginServlet.doPost(AutoLoginServlet.java:37)
at com.sunning.cross.ui.explorer.server.servlet.AutoLoginServlet.doGet(AutoLoginServlet.java:26)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
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:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)


解决方法
通过get方法访问
 protected void doGet(final HttpServletRequest req, final HttpServletResponse resp)  
            throws ServletException, IOException {  
        new ContextualHttpServletRequest(req) {  
            public void process() throws Exception {  
                doLogin(req,resp);  
            }  
          }.run();  
    }

你可能感兴趣的:(servlet,seam)