6 Replies Latest reply on Jun 28, 2011 8:52 PM by Marcio Dantas

    Seam Persistence 3 Fails on Tomcat 6

    Edem Morny Novice

      Hi,


      I've been attempting to replicate an example of ZK Framework integration with CDI, this time using Seam 3 modules. Everything works alright, including all CDI related configuration specific to a non-Java EE environment, until i attempt to integrate seam-persistence into the application.


      As specified in the documentation, I've put the ff in my seam-beans.xml




      <t:SeSynchronizations>
              <s:modifies/>
          </t:SeSynchronizations>
          <t:EntityTransaction>
              <s:modifies />
          </t:EntityTransaction>





      Also, I've added hibernate 3.5.0-Final to my maven dependency declarations. However, I get a NoClassDefFoundError: javax/ejb/EJBContext. I didn't think I needed any EJB related code to be able to deploy my application with Seam Persistence.
      Here's my exception stacktrace



      SEVERE: Exception sending context initialized event to listener instance of class org.jboss.weld.environment.servlet.Listener
      com.google.common.collect.ComputationException: java.lang.NoClassDefFoundError: javax/ejb/EJBContext
              at com.google.common.collect.MapMaker$StrategyImpl.compute(MapMaker.java:602)
              at com.google.common.collect.MapMaker$StrategyImpl.compute(MapMaker.java:462)
              at com.google.common.collect.CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2045)
              at org.jboss.weld.resources.ClassTransformer.loadClass(ClassTransformer.java:164)
              at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:61)
              at org.jboss.weld.bootstrap.BeanDeployer.addClasses(BeanDeployer.java:88)
              at org.jboss.weld.bootstrap.BeanDeployment.deployBeans(BeanDeployment.java:134)
              at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:377)
              at org.jboss.weld.environment.servlet.Listener.contextInitialized(Listener.java:171)
              at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972)
              at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
              at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
              at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
              at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
              at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
              at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:521)
              at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1359)
              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.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
              at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
              at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
              at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1500)
              at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:849)
              at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:351)
              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.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:558)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
              at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
              at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
              at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
              at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.NoClassDefFoundError: javax/ejb/EJBContext
              at java.lang.Class.getDeclaredMethods0(Native Method)
              at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
              at java.lang.Class.getDeclaredMethods(Class.java:1791)
              at org.jboss.weld.util.reflection.Reflections.isTypeOrAnyMethodFinal(Reflections.java:162)
              at org.jboss.weld.util.Proxies.isClassProxyable(Proxies.java:262)
              at org.jboss.weld.util.Proxies.isTypeProxyable(Proxies.java:201)
              at org.jboss.weld.util.Proxies.isTypesProxyable(Proxies.java:229)
              at org.jboss.weld.introspector.jlr.AbstractWeldAnnotated.<init>(AbstractWeldAnnotated.java:179)
              at org.jboss.weld.introspector.jlr.WeldClassImpl.<init>(WeldClassImpl.java:145)
              at org.jboss.weld.introspector.jlr.WeldClassImpl.of(WeldClassImpl.java:140)
              at org.jboss.weld.resources.ClassTransformer$TransformTypeToWeldClass.apply(ClassTransformer.java:50)
              at org.jboss.weld.resources.ClassTransformer$TransformTypeToWeldClass.apply(ClassTransformer.java:38)
              at com.google.common.collect.MapMaker$StrategyImpl.compute(MapMaker.java:592)
              ... 41 more
      Caused by: java.lang.ClassNotFoundException: javax.ejb.EJBContext
              at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
              at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
              at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)



      Any idea what I could be doing wrong?

        • 1. Re: Seam Persistence 3 Fails on Tomcat 6
          Horacio Lagandara Newbie
          Hi Edem,

          add ejb-api in your pom:

          <dependency>
              <groupId>javax.ejb</groupId>
              <artifactId>ejb-api</artifactId>
              <version>3.0</version>
          </dependency>

          h.
          • 2. Re: Seam Persistence 3 Fails on Tomcat 6
            MIklos Piklos Newbie

            No, you actually doen't need ejb dependancy. I hav strugled with persistance and tomcat and it works without it.
            Can you perhaps post your pom.xml, beans.xml and seam-beans.xml?

            • 3. Re: Seam Persistence 3 Fails on Tomcat 6
              Edem Morny Novice

              Ok, let me give as much detail as possible.


              Here's my maven dependencies:



              <dependencies>       
                      <dependency>
                          <groupId>org.jboss.seam.solder</groupId>
                          <artifactId>seam-solder</artifactId>
                          <version>3.0.0.CR4</version>
                      </dependency>
                      <dependency>
                          <groupId>org.jboss.seam.servlet</groupId>
                          <artifactId>seam-servlet</artifactId>
                          <version>3.0.0.CR3</version>
                      </dependency>
                      <dependency>
                          <groupId>org.jboss.seam.config</groupId>
                          <artifactId>seam-config-xml</artifactId>
                          <version>3.0.0.CR4</version>
                          <exclusions>
                              <exclusion>
                                  <artifactId>seam-solder-impl</artifactId>
                                  <groupId>org.jboss.seam.solder</groupId>
                              </exclusion>
                          </exclusions>
                      </dependency>
                      <dependency>
                          <groupId>org.jboss.seam.catch</groupId>
                          <artifactId>seam-catch</artifactId>
                          <version>3.0.0.CR3</version>
                      </dependency>
                      <dependency>
                          <groupId>org.jboss.seam.persistence</groupId>
                          <artifactId>seam-persistence</artifactId>
                          <version>3.0.0.CR4</version>
                      </dependency>
                      <dependency>
                          <groupId>org.jboss.weld.servlet</groupId>
                          <artifactId>weld-servlet</artifactId>
                          <version>1.0.1-Final</version>
                      </dependency>
                      <dependency>
                          <groupId>joda-time</groupId>
                          <artifactId>joda-time</artifactId>
                          <version>1.6</version>
                      </dependency>
                      <dependency>
                          <groupId>javax.enterprise</groupId>
                          <artifactId>cdi-api</artifactId>
                          <version>1.0-SP4</version>
                      </dependency>
              
                      <dependency>
                          <groupId>org.glassfish.web</groupId>
                          <artifactId>el-impl</artifactId>
                          <version>2.2.1-b05</version>
                          <exclusions>
                              <exclusion>
                                  <groupId>javax.el</groupId>
                                  <artifactId>el-api</artifactId>
                              </exclusion>
                          </exclusions>
                      </dependency>
                      <dependency>
                          <groupId>org.jboss.logging</groupId>
                          <artifactId>jboss-logging</artifactId>
                          <version>3.0.0.Beta4</version>
                          <scope>compile</scope>
                      </dependency>
                      <dependency>
                          <groupId>org.jboss.logmanager</groupId>
                          <artifactId>jboss-logmanager</artifactId>
                          <version>1.1.0.GA</version>
                      </dependency>
                      <dependency>
                          <groupId>log4j</groupId>
                          <artifactId>log4j</artifactId>
                          <version>1.2.16</version>
                      </dependency>
                      <dependency>
                          <groupId>org.reflections</groupId>
                          <artifactId>reflections</artifactId>
                          <version>0.9.5-RC2</version>
                          <exclusions>
                              <exclusion>
                                  <artifactId>servlet-api</artifactId>
                                  <groupId>javax.servlet</groupId>
                              </exclusion>
                          </exclusions>
                      </dependency>
                       <dependency>
                          <groupId>org.hibernate</groupId>
                          <artifactId>hibernate-entitymanager</artifactId>
                          <version>3.3.2.GA</version>
                          <scope>runtime</scope>
                          <exclusions>
                              <exclusion>
                                  <artifactId>javassist</artifactId>
                                  <groupId>jboss</groupId>
                              </exclusion>
                          </exclusions>
                      </dependency>
                      <dependency>
                          <groupId>javassist</groupId>
                          <artifactId>javassist</artifactId>
                          <version>3.9.0.GA</version>
                          <scope>runtime</scope>
                      </dependency>
              
                      <dependency>
                          <artifactId>hibernate-jpa-2.0-api</artifactId>
                          <groupId>org.hibernate.javax.persistence</groupId>
                          <type>jar</type>
                          <version>1.0.0.Final</version>
                      </dependency>
                      <dependency>
                          <groupId>org.hibernate</groupId>
                          <artifactId>hibernate</artifactId>
                          <version>3.2.5.ga</version>
                      </dependency>
                      <dependency>
                          <groupId>org.hibernate</groupId>
                          <artifactId>ejb3-persistence</artifactId>
                          <version>1.0.1.GA</version>
                      </dependency>
                      <dependency>
                          <groupId>javax.transaction</groupId>
                          <artifactId>jta</artifactId>
                          <version>1.0.1B</version>
                      </dependency>
                  </dependencies>





              Here's my beans.xml




              <?xml version="1.0" encoding="UTF-8"?>
              <beans xmlns="http://java.sun.com/xml/ns/javaee"
               xmlns:s="urn:java:ee"
                     xmlns:t="urn:java:org.jboss.seam.persistence.transaction"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="
                    http://java.sun.com/xml/ns/javaee
                    http://docs.jboss.org/cdi/beans_1_0.xsd">
                  <interceptors>
                      <class>org.jboss.seam.transaction.TransactionInterceptor</class>
                  </interceptors>
                  <t:SeSynchronizations>
                      <s:modifies/>
                  </t:SeSynchronizations>
                  <t:EntityTransaction>
                      <s:modifies />
                  </t:EntityTransaction>
              </beans>





              My seam-beans.xml is empty





              <?xml version="1.0" encoding="UTF-8"?>
              <beans xmlns="http://java.sun.com/xml/ns/javaee"
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xmlns:s="urn:java:ee"
                     xmlns:t="urn:java:org.jboss.seam.persistence.transaction"
                     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee  http://docs.jboss.org/cdi/beans_1_0.xsd">    
              
              </beans>





              Here's my web.xml




              <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
                  <display-name>mavencdi</display-name>
                  <listener>
                      <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
                  </listener>
                  <listener>
                      <listener-class>org.jboss.weld.el.WeldELContextListener</listener-class>
                  </listener>
                  <resource-env-ref>
                      <description>Object factory for the CDI Bean Manager</description>
                      <resource-env-ref-name>BeanManager</resource-env-ref-name>
                      <resource-env-ref-type>javax.enterprise.inject.spi.BeanManager
                      </resource-env-ref-type>
                  </resource-env-ref>
                  <session-config>
                      <session-timeout>
                          30
                      </session-timeout>
                  </session-config>
                  <welcome-file-list>
                      <welcome-file>index.jsp</welcome-file>
                  </welcome-file-list>
              </web-app>






              Here's my META-INF/context.xml




              <Context antiJARLocking="true" path="mavencdi">
                <Resource auth="Container" factory="org.jboss.weld.resources.ManagerObjectFactory" name="BeanManager" type="javax.enterprise.inject.spi.BeanManager"/>
                <Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxActive="100" maxIdle="30" maxWait="10000" name="jdbc/textforce" password="textforce" type="javax.sql.DataSource" url="jdbc:mysql://localhost:3306/textforce" username="textforce"/>
              </Context>





              And my persistence.xml goes like this





              <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
                <persistence-unit name="textforce" transaction-type="RESOURCE_LOCAL">
                  <provider>org.hibernate.ejb.HibernatePersistence</provider>
                  <jta-data-source>java:comp/env/jdbc/textforce</jta-data-source>
                    <properties> 
                       <property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
                       <property name="hibernate.hbm2ddl.auto" value="update"/>
                  </properties>
                </persistence-unit>
              </persistence>
              




              Any help miklos?


              • 4. Re: Seam Persistence 3 Fails on Tomcat 6
                MIklos Piklos Newbie

                Well first thing i see is that seam-beans.xml shouldn't be empty. It should look like this:




                <?xml version="1.0" encoding="UTF-8"?>
                <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xmlns:s="urn:java:ee" xmlns:t="urn:java:org.jboss.seam.transaction"
                     xsi:schemaLocation="
                      http://java.sun.com/xml/ns/javaee
                      http://docs.jboss.org/cdi/beans_1_0.xsd">
                     <t:SeSynchronizations>
                          <s:modifies />
                     </t:SeSynchronizations>
                     <t:EntityTransaction>
                          <s:modifies />
                     </t:EntityTransaction>
                </beans>



                and beans.xml should look like this:



                <?xml version="1.0" encoding="UTF-8"?>
                <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                      http://docs.jboss.org/cdi/beans_1_0.xsd">
                     <interceptors>
                          <class>org.jboss.seam.transaction.TransactionInterceptor</class>
                     </interceptors>
                </beans>



                Try those two first, and if you continue having troubles write here.


                Good luck.



                • 5. Re: Seam Persistence 3 Fails on Tomcat 6
                  Marcio Dantas Newbie

                  having the same problem. did you get ahead??


                  my beans and seam-beans config is just like above, but the error continues.

                  • 6. Re: Seam Persistence 3 Fails on Tomcat 6
                    Marcio Dantas Newbie

                    I changed the weld-servlet version to:


                    <dependency>
                       <groupId>org.jboss.weld.servlet</groupId>
                       <artifactId>weld-servlet</artifactId>
                       <scope>runtime</scope>
                       <version>1.1.1.Final</version>
                     </dependency>



                    and the error above is solved.


                    Tomcat console:


                    INFO: Tomcat 6 detected, CDI injection will be available in Servlets and Filters. Injection into Listeners is not supported