5 Replies Latest reply on Jan 21, 2006 8:32 PM by Andrew

    Can't deploy, embedded EJB3 container fails to deploy

    Andrew Apprentice

      I am attempting to run a new seam project on tomcat with EJB3 enabled (I have managed to get the microcontainer working with noejb before, but am not trying the EJB3 solution).

      I was looking at the javax.persistence documentation at the hibernate.org site and their tutorial was showing attribute arguments that did not exist with seam (I am mentioning this, because I'm not sure what I did is supported). So, I downloaded the lastest hibernate and latest hibernate-entity-manager so that I could get the latest javax.persistence functionality (Specifically I wanted the 'access' property: "@Entity(access=AccessType.FIELD)")


      I then updated my seam from CVS and built it.

      In my project, I built a new ant file using the booking build.xml as a template. In my war task I include the libraries from:
      hibernate/hibernate.jar
      hibernate/lib/(only those jars that are in seam and the seam embedded ejb3 lib directories)
      hibernate-entity-manager/hibernate-entity-manager.jar
      hibernate-entity-manager/lib/*.jar
      seam/seam.jar
      seam/lib/(only those not already included)
      seam/embedded-ejb/lib/(only those not already included)

      I have used the web.xml from booking, just slightly altered as with the other meta files (jboss-beans.xml for example)

      When I start tomcat I get the following exception:

      INFO 21-01 12:29:18,963 (Ejb.java:startup:39) -starting the embedded EJB container
      java.lang.RuntimeException: java.lang.NoSuchMethodError: org.jboss.util.CollectionsFactory.createConcurrentReaderMap()Ljava/util/Map;
       at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.boot(EJB3StandaloneBootstrap.java:277)
       at org.jboss.seam.core.Ejb.startup(Ejb.java:40)
       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:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
       at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:32)
       at org.jboss.seam.Component.callComponentMethod(Component.java:1114)
       at org.jboss.seam.Component.callCreateMethod(Component.java:1102)
       at org.jboss.seam.Component.newInstance(Component.java:1091)
       at org.jboss.seam.Component.getInstance(Component.java:1039)
       at org.jboss.seam.Component.getInstance(Component.java:1022)
       at org.jboss.seam.contexts.Lifecycle.startup(Lifecycle.java:88)
       at org.jboss.seam.contexts.Lifecycle.endInitialization(Lifecycle.java:68)
       at org.jboss.seam.init.Initialization.init(Initialization.java:91)
       at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:30)
       at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3669)
       at org.apache.catalina.core.StandardContext.start(StandardContext.java:4104)
       at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
       at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
       at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
       at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
       at org.apache.catalina.core.StandardService.start(StandardService.java:450)
       at org.apache.catalina.core.StandardServer.start(StandardServer.java:683)
       at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
       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:585)
       at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
       at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
      Caused by: java.lang.NoSuchMethodError: org.jboss.util.CollectionsFactory.createConcurrentReaderMap()Ljava/util/Map;
       at org.jboss.kernel.plugins.event.AbstractEventEmitter.<init>(AbstractEventEmitter.java:55)
       at org.jboss.kernel.plugins.AbstractKernelObject.<init>(AbstractKernelObject.java:57)
       at org.jboss.kernel.plugins.bootstrap.AbstractBootstrap.<init>(AbstractBootstrap.java:53)
       at org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap.<init>(BasicBootstrap.java:59)
       at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.createKernel(EJB3StandaloneBootstrap.java:285)
       at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.boot(EJB3StandaloneBootstrap.java:262)
       ... 31 more
      ERROR 21-01 12:29:19,001 (StandardContext.java:listenerStart:3673) -Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
      


      Here is the build.properties:
      #
      #Sun Oct 30 20:49:25 MST 2005
      name=Test Seam on Tomcat
      project.name=test-seam
      src.java.dir=JavaSource
      src.test.dir=${src.java.dir}
      resources.dir=Resources
      version=1.0
      build.dir=build
      classes.dir=${build.dir}/classes
      build.libs.dir=${build.dir}/lib
      javac.debug=yes
      javac.deprecation=yes
      webinf.dir=WebContent/WEB-INF
      content.dir=WebContent
      
      classpath.external=/home/andrew/eclipseworkspace/.metadata/.plugins/com.exadel.project.templates/lib/servlet/2.4/servlet-api.jar;/home/andrew/eclipseworkspace/.metadata/.plugins/com.exadel.project.templates/lib/servlet/2.4/jsp-api.jar;
      seam.dir=/usr/local/java-apps/jboss-seam
      tomcat.home=/usr/local/java-apps/tomcat
      
      entity.manager.dir=/usr/local/java-apps/hibernate-entitymanager
      ejb3.container.dir=${seam.dir}/embedded-ejb
      hibernate.dir=/usr/local/java-apps/hibernate


      Here is the build.xml:
      <?xml version="1.0"?>
      
      <project name="Test Seam" default="war" basedir="..">
      
       <!-- Naming -->
       <property file="ant/build.properties"/>
      
       <patternset id="meta.files">
       <include name="**/*.dtd"/>
       <include name="**/*.xml"/>
       <include name="**/*.xslt"/>
       <include name="**/*.properties"/>
       <include name="**/*.xsd"/>
       </patternset>
      
       <path id="build.classpath">
       <fileset dir="${webinf.dir}/lib" includes="*.jar"/>
       <fileset dir="${build.libs.dir}" includes="*.jar"/>
       </path>
      
       <!-- targets -->
       <target name="clean">
       <delete dir="${build.dir}"/>
       </target>
      
       <target name="init" description="Initialize the build">
       <echo message="Build ${name} ${version}"/>
       <mkdir dir="${build.dir}"/>
       <mkdir dir="${classes.dir}"/>
       <mkdir dir="${build.libs.dir}"/>
      
       <!-- copy non-java files to classes directory -->
       <copy todir="${classes.dir}">
       <fileset dir="${src.java.dir}">
       <patternset refid="meta.files"/>
       </fileset>
       </copy>
      
       <!-- setup 3rd party libs -->
       <copy todir="${build.libs.dir}" flatten="yes">
       <fileset dir="${hibernate.dir}" includes="*.jar"/>
       <fileset dir="${entity.manager.dir}">
       <include name="*.jar"/>
       <include name="lib/*.jar"/>
       </fileset>
       <!-- copy the hibernate libs that are needed by the ejb3 container -->
       <fileset dir="${hibernate.dir}/lib" includes="*.jar">
       <present present="both" targetdir="${ejb3.container.dir}/lib"/>
       </fileset>
       <!-- copy the hibernate libs that are needed by seam -->
       <fileset dir="${hibernate.dir}/lib" includes="*.jar">
       <present present="both" targetdir="${seam.dir}/lib"/>
       </fileset>
       <!-- copy the ejb3 container libs that are not in hibernate -->
       <fileset dir="${ejb3.container.dir}/lib" includes="*.jar">
       <present present="srconly" targetdir="${hibernate.dir}/lib"/>
       <present present="srconly" targetdir="${hibernate.dir}"/>
       <present present="srconly" targetdir="${entity.manager.dir}"/>
       <present present="srconly" targetdir="${entity.manager.dir}/lib"/>
       </fileset>
       <!-- copy the seam libraries -->
       <fileset dir="${seam.dir}" includes="*.jar"/>
       <fileset dir="${seam.dir}/lib" includes="*.jar">
       <present present="srconly" targetdir="${hibernate.dir}/lib"/>
       <present present="srconly" targetdir="${hibernate.dir}"/>
       <present present="srconly" targetdir="${entity.manager.dir}"/>
       <present present="srconly" targetdir="${entity.manager.dir}/lib"/>
       <present present="srconly" targetdir="${ejb3.container.dir}/lib"/>
       </fileset>
       </copy>
       </target>
      
       <target name="compile"
       depends="init"
       description="Compile the Java source code">
       <javac destdir="${classes.dir}"
       classpathref="build.classpath"
       debug="${javac.debug}"
       deprecation="${javac.deprecation}"
       nowarn="on">
       <src path="${src.java.dir}" />
       <src path="${src.test.dir}" />
       </javac>
       </target>
      
       <target name="war" depends="compile">
       <mkdir dir="${build.dir}/${project.name}/WEB-INF/lib" />
       <!-- jar the class files -->
       <jar jarfile="${build.dir}/${project.name}/WEB-INF/lib/${project.name}.jar">
       <fileset dir="${classes.dir}">
       <include name="**/*.class" />
       <exclude name="**/test/*.class" />
       </fileset>
       <fileset dir="${resources.dir}">
       <patternset refid="meta.files"/>
       </fileset>
       </jar>
      
       <copy todir="${build.dir}/${project.name}/WEB-INF/lib">
       <!-- copy 3rd party libraries -->
       <fileset dir="${build.libs.dir}" includes="*.jar">
       <present present="srconly" targetdir="${webinf.dir}/lib"/>
       </fileset>
       <!-- copy project lib dir -->
       <fileset dir="${webinf.dir}/lib" includes="*.jar"/>
       </copy>
      
       <!-- build embedded EJB configuration -->
       <jar jarfile="${build.dir}/${project.name}/WEB-INF/lib/embedded-ejb-conf.jar">
       <fileset dir="${ejb3.container.dir}/conf">
       <include name="ejb3-interceptors-aop.xml" />
       <include name="embedded-jboss-beans.xml" />
       <include name="default.persistence.properties" />
       <include name="log4j.xml" />
       </fileset>
       </jar>
      
       <copy todir="${build.dir}/${project.name}/WEB-INF">
       <fileset dir="${webinf.dir}">
       <patternset refid="meta.files"/>
       </fileset>
       </copy>
      
       <copy todir="${build.dir}/${project.name}">
       <fileset dir="${content.dir}">
       <include name="**/*"/>
       <exclude name="META-INF/*"/>
       <exclude name="WEB-INF/*"/>
       </fileset>
       </copy>
      
       <jar basedir="${build.dir}/${project.name}" compress="false"
       destfile="${build.dir}/${project.name}.war" />
       </target>
      
       <target name="deploy" depends="undeploy,war">
       <copy file="${build.dir}/${project.name}.war"
       todir="${tomcat.home}/webapps" />
       <echo>After you start Tomcat, the project will be available at: http://localhost:8080/${project.name}</echo>
       </target>
      
       <!--
       <target name="redeploy" depends="deploy">
       <reload url="http://localhost:8080/manager"
       username="admin"
       password=""
       path="/${project.name}"/>
       </target>
       -->
      
       <target name="undeploy">
       <delete file="${tomcat.home}/webapps/${project.name}.war" />
       <delete dir="${tomcat.home}/webapps/${project.name}" />
       </target>
      
      </project>


        • 1. Re: Can't deploy, embedded EJB3 container fails to deploy
          Andrew Apprentice

          Oh, by the way, I checked the jar, and found the method that is supposedly missing, it is there. Not sure why the error.

          • 2. Re: Can't deploy, embedded EJB3 container fails to deploy
            Andrew Apprentice

            Well, I just saw the new jars for hibernate, and downloaded them, and saw they broke my code. I hope that using the 'org.hibernate.annotations.@AccessType("field")' will work the same way the entity did. Also I was bummed to find that the FlushMode.NEVER is gone. Really bad as Gavin told me to use it for a solution in seam.

            Besides the above, I still have the same error with the new jars.

            • 3. Re: Can't deploy, embedded EJB3 container fails to deploy
              Gavin King Master

               

              "andrew.rw.robinson" wrote:
              I am attempting to run a new seam project on tomcat with EJB3 enabled


              The booking example in jboss-seam CVS runs on tomcat 5.5. Follow that.

              "andrew.rw.robinson" wrote:
              (Specifically I wanted the 'access' property: "@Entity(access=AccessType.FIELD)")



              AccessType has been removed from the EJB3 spec and from the latest releases of HA/HEM. It is no longer needed.


              "andrew.rw.robinson" wrote:
              When I start tomcat I get the following exception:
              INFO 21-01 12:29:18,963 (Ejb.java:startup:39) -starting the embedded EJB container
              java.lang.RuntimeException: java.lang.NoSuchMethodError:


              NoSuchMethodErrors are *always* a result of incompatible jars. Use the jars in Seam CVS as they are known to all work together.


              • 4. Re: Can't deploy, embedded EJB3 container fails to deploy
                Gavin King Master

                 

                "andrew.rw.robinson" wrote:
                Well, I just saw the new jars for hibernate, and downloaded them, and saw they broke my code. I hope that using the 'org.hibernate.annotations.@AccessType("field")'


                You don't need it anymore. EJB3 decides the access type based upon whether the annotations are defined at field or property level. Check the EJB spec PFD.


                "andrew.rw.robinson" wrote:
                Also I was bummed to find that the FlushMode.NEVER is gone. Really bad as Gavin told me to use it for a solution in seam.


                Yes, this is shit. There was a big fight in the EG and JBoss/Sun/Sybase lost (for now). You'll need to use a vendor-extension annotation to do this elegantly. We'll make sure that this vendor-specific annotation is actually the same in both JBoss and in the Sun RI (so not quite vendor-specific).


                • 5. Re: Can't deploy, embedded EJB3 container fails to deploy
                  Andrew Apprentice

                  Any clue on the NoSuchMethodError? I can only find one jar with that deployed class so it doesn't seem to be a classpath issue (though I won't say I'm 100% sure). When I deploy the booking example it works, so I am thinking it may be the updated jars from the hibernate-entity-manager, but can't be sure. Has anyone else tried last nights jars with the embedded EJB3 container yet?