1 Reply Latest reply: Apr 30, 2012 4:47 PM by Emir Calabuch RSS

Custom servlet (seam web service) please suggest configuration

navi ghag Newbie

Hi

 

I am pretty new at seam. I have a seam web service. So any web requests that i get, i need to map them to seam web service that I have written. So, If I understand it correctly, then it is the case of using custom servlets in seam, which i need to map in my web.xml file. Below is the code for that

<servlet>

        <servlet-name>pluginhandler</servlet-name>

        <servlet-class>service.PlugInHandler</servlet-class>

        <load-on-startup>1</load-on-startup>

    </servlet>

    <servlet-mapping>

        <servlet-name>pluginhandler</servlet-name>

        <url-pattern>/*</url-pattern>

    </servlet-mapping>

 

 

so if I want to use seam contexts, I read that i have to use a filter as follows

<filter>

        <filter-name>Seam Servlet Filter</filter-name>

        <filter-class>org.jboss.seam.servlet.SeamServletFilter</filter-class>

    </filter>

 

 

    <filter-mapping>

        <filter-name>Seam Servlet Filter</filter-name>

        <url-pattern>/*</url-pattern>

    </filter-mapping>

    <filter>

    <filter-name>Seam Filter</filter-name>

        <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>

    </filter>

 

By doing this seam contexts get created. and added <web:context-filter url-pattern="/*" /> in components.xml file.

 

 

Now whenever my web service class gets a request , it delegates to a seam component "Action", which persists stuff in data base.

But when i try to get entity manager by "EntityManager em = Component.getIntsancr("entityManager"), it throws an exception

 

,java.lang.IllegalArgumentException: EntityManagerFactory not found in JNDI : java:/plugInEntityManagerFactory  followed by

java.lang.IllegalStateException: No active event context

          at org.jboss.seam.core.Manager.instance(Manager.java:250)

          at org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:55)

          at org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:37)

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

          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:230)

          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

          at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)

          at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)

          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:157)

          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)

          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)

          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)

          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)

          at java.lang.Thread.run(Unknown Source)

11:33:51,960 ERROR [[pluginhandler]] Servlet.service() for servlet pluginhandler threw exception

java.lang.IllegalStateException: No active event context

          at org.jboss.seam.core.Manager.instance(Manager.java:250)

          at org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:55)

          at org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:37)

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

          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:230)

          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

          at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)

          at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)

          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:157)

          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)

          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)

          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)

          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)

          at java.lang.Thread.run(Unknown Source)

 

I have done mapping for entitymanager factory , i have added following code in components.xml

<persistence:managed-persistence-context name="eM"

                                      auto-create="true"

                      persistence-unit-jndi-name="java:/plugInEntityManagerFactory"/>

 

and then following code in persistent.xml

<property name="jboss.entity.manager.factory.jndi.name" value="java:/plugInEntityManagerFactory"/>

 

I am running out of ideas now. Please help. I would huighly appreciate your help.

 

Thanks in advance. please response.