Since I’d been using Eclipse for a while now, I decided to give the JBoss Tools 2.0.1.GA a spin, with a focus on using it with Tomcat 6 instead of JBoss AS. JBoss Tools is a set of plugins released by the JBoss team for rapid Seam application development. However, by default it supports development to the JBoss Application Server, although Seam applications can be deployed to most application servers.
I followed the instructions detailed in the new Chapter 3 of the Seam Reference Manual in Seam 2.0.2.GA, making sure that I rather specified my installed Tomcat 6 instead of JBAS and also specified a WAR instead of EAR structure. After the project structure is created, there are a few changes that need to be made to make things nice and easy.
To make sure that we all have the same view of the project structure, open the Seam perspective.
Tomcat enables us to put resources that are needed in each application (like datasources) in a META-INF/context.xml. Here is what mine looks like.
<?xml version="1.o" encoding="UTF-8"?>
<Context crossContext="true" debug="5" docBase="seamweb" path="/seamweb" reloadable="true">
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxActive="20" maxIdle="10" maxWait="-1" name="jdbc/seamweb" password="" type="javax.sql.DataSource" url="jdbc:mysql://localhost:3306/seamweb" username="edem"/>
</Context>
In Eclipse, this file should go into the WebContent/META-INF folder.
Next is to work on the persitence.xml file which will be found under src/model/META-INF. Change the following line in that file which looks like this
<jta-data-source>java:/seamwebDatasource</jta-data-source
to this
<jta-data-source>java:comp/env/jdbc/seamweb</jta-data-source>
This is the standard way of declaring JNDI names, and Tomcat expects that. Also, change the “transaction-type” from “JTA” to “RESOURCE_LOCAL”.
Next thing to deal with is the components.xml file under WebContent/WEB-INF/. Remove the jndi-pattern = “@jndiPattern” attribute since we are not using EJBs here. Your file should now look like this.
<core:init debug="true"/>
<core:manager conversation-timeout="240000" concurrent-request-timeout="500" conversation-id-parameter="cid"/>
<transaction:entity-transaction entity-manager="#{entityManager}"/>
<persistence:entity-manager-factory name="seamweb"/>
<persistence:managed-persistence-context name="entityManager" auto-create="true" entity-manager-factory="#{seamweb}"/>
<security:identity authenticate-method="#{authenticator.authenticate}"/>
<event type="org.jboss.seam.notLoggedIn">
<action execute="#{redirect.captureCurrentView}"/>
</event>
<event type="org.jboss.seam.postAuthenticate">
<action execute="#{redirect.returnToCapturedView}"/>
</event>
Take note of “seamweb” declarations. Its the same as the persistence-unit name provided in the persitence.xml file.
Now delete the WebContent/WEB-INF/jboss-web.xml file. It’s definitely not necessary to tomcat.
The last but most important part of this exercise is making sure you have the right jar files in WEB/lib. After creating the project, JBoss Tools copies all the jar files from seam’s lib folder into your web application. The only way to know the jars needed for tomcat deployment only is to jpa example in seam distribution you have. Follow the instructions on my post about setting up NetBeans 6.0 for Tomcat 6 and you’ll see how i did it.
But to save you that trouble, this list of jars seem to work for me
-
antlr.jar
- asm.jar
-
cglib.jar
-
commons-beanutils.jar
-
common-collections.jar
-
commons-digester.jar
-
commons-lang.jar
-
commons-logging.jar
-
dom4j.jar
-
hibernate-annotations.jar
-
hibernate-commons-annotations.jar
-
hibernate-entitymanager.jar
-
hibernate.jar
-
hibernate-validator.jar
-
javassist.jar
-
jbos-archive-browsing.jar
-
jboss-el.jar
-
jboss-seam-debug.jar
-
jboss-seam.jar
-
jboss-seam-ui.jar
-
jsf-api.jar
-
jsf-facelets.jar
-
jsf-impl.jar
-
jstl.jar
-
jta.jar
-
persistence-api.jar
-
richfaces-api.jar
-
richfaces-impl.jar
-
richfaces-ui.jar
If everything went well, the application should run inside tomcat without a problem.

August 1, 2008 at 3:57 pm |
After such setup I have java.lang.ClassNotFoundException: org.jboss.embedded.tomcat.EmbeddedJBossBootstrapListener
It’s seems to me that it’s needed to install EmbeddedJBoss to tomcat
August 4, 2008 at 12:19 pm |
This post assumes Seam development with POJOs and JPA on Tomcat 6,0, without the use of EmbeddedJBoss. I believe you are using EmbeddedJBoss, which is causing your exception. Check the seam forums for help on this.
August 5, 2008 at 8:32 am |
Yes. you’re right. I had some parameters for jboss embedded in my server.xml without libs for it. Thank’s for answer
January 5, 2009 at 11:30 pm |
[...] – bookmarked by 2 members originally found by GardnerC on 2008-12-08 Tweaking JBoss Tools and Eclipse for Tomcat 6 http://edemmorny.wordpress.com/2008/07/08/tweaking-jboss-tools-and-eclipse-for-tomcat-6/ – [...]
March 27, 2009 at 9:44 am |
After such setup I have a
SEVERE: Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
org.jboss.seam.InstantiationException: Could not instantiate Seam component: LearningSEAMByExampleEntityManagerFactory
at org.jboss.seam.Component.newInstance(Component.java:2106)
at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:112)
at org.jboss.seam.init.Initialization.init(Initialization.java:735)
at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:35)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
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:525)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:627)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
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.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named LearningSEAMByExample
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:89)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
at org.jboss.seam.persistence.EntityManagerFactory.createEntityManagerFactory(EntityManagerFactory.java:81)
at org.jboss.seam.persistence.EntityManagerFactory.startup(EntityManagerFactory.java:50)
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.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
at org.jboss.seam.Component.callComponentMethod(Component.java:2219)
at org.jboss.seam.Component.callCreateMethod(Component.java:2134)
at org.jboss.seam.Component.newInstance(Component.java:2094)
… 29 more
I used Seam-gen to create my project and I add persistence.xml in MEAT-INF under source folder.
This is my components.xml file:
*.seam
/security.drl
And this is my persistence.xml file :
org.hibernate.ejb.HibernatePersistence
java:comp/env/jdbc/LearningSEAMByExample
Could you help me ?
May 13, 2009 at 6:38 pm |
Hello, I have done all the steps, but it still doesn’t work.
I use Eclipse 3.4, apache-tomcat-6.0.18 and jboss-seam-2.1.2.CR1.
Wen I start tomcat, I have this warning:
ADVERTENCIA: Unable to process deployment descriptor for context ‘/tomcatDemo’
then I have:
Estado HTTP 404 – /tomcatDemo/
could you help me?
Thanks
May 19, 2009 at 10:39 am |
Hello Edem
I followed your guide accurately but I’m getting the following exception during the tomcat startup:
SEVERE: Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
org.jboss.seam.InstantiationException: Could not instantiate Seam component: tpjtEntityManagerFactory
at org.jboss.seam.Component.newInstance(Component.java:2096)
at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:112)
at org.jboss.seam.init.Initialization.init(Initialization.java:727)
at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:34)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: javax.persistence.PersistenceException: org.hibernate.HibernateException: Could not locate TransactionManager
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:737)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:121)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
at org.jboss.seam.persistence.EntityManagerFactory.createEntityManagerFactory(EntityManagerFactory.java:81)
at org.jboss.seam.persistence.EntityManagerFactory.startup(EntityManagerFactory.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:138)
at org.jboss.seam.Component.callComponentMethod(Component.java:2209)
at org.jboss.seam.Component.callCreateMethod(Component.java:2124)
at org.jboss.seam.Component.newInstance(Component.java:2084)
… 20 more
Caused by: org.hibernate.HibernateException: Could not locate TransactionManager
at org.hibernate.transaction.JNDITransactionManagerLookup.getTransactionManager(JNDITransactionManagerLookup.java:26)
at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:325)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:730)
… 34 more
Caused by: javax.naming.NameNotFoundException: Name TransactionManager is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137)
at javax.naming.InitialContext.lookup(Unknown Source)
at org.hibernate.transaction.JNDITransactionManagerLookup.getTransactionManager(JNDITransactionManagerLookup.java:23)
… 38 more
Any ideas about what might be the reason?
I’m using eclipse 3.4, tomcat 6.0.18 and seam-2.1.0.SP1
Thanks in advance.
May 19, 2009 at 10:47 am |
@dmitry: Check out for two things in your persistence.xml
transaction-type=”RESOURCE_LOCAL” and not “JTA”
That you don’t have added any property specifying transaction manager etc. because that’s where ur bug is coming from
May 19, 2009 at 1:37 pm |
Thanks for your quick response Edem. Here is my persistence.xml file. It’s almost the same as it was after jboss-tools generated it.
org.hibernate.ejb.HibernatePersistence
java:comp/env/tomcatseampjtDatasource
May 19, 2009 at 1:39 pm |
<![CDATA[
org.hibernate.ejb.HibernatePersistence
java:comp/env/tomcatseampjtDatasource
]]>
May 19, 2009 at 1:54 pm |
persistence 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_1_0.xsd”
version=”1.0″
persistence-unit name=”tomcatseampjt” transaction-type=”RESOURCE_LOCAL”
provider org.hibernate.ejb.HibernatePersistence
jta-data-source java:comp/env/tomcatseampjtDatasource
properties
hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
hibernate.hbm2ddl.auto = update
hibernate.show_sql = true
hibernate.format_sql = true
hibernate.transaction.manager_lookup_class = org.hibernate.transaction.JBossTransactionManagerLookup
/properties
persistence-unit
persistence
May 19, 2009 at 2:27 pm |
Like I said before, you do have a transaction manager lookup configured in your file. This is automatically put in by jboss-tools even though u didn’t specify any such thing.
i.e.
hibernate.transaction.manager_lookup_class = org.hibernate.transaction.JBossTransactionManagerLookup
If you are not using the JBossTransactionManagerLookup, then remove this property declaration.
May 19, 2009 at 2:54 pm |
Thanks for your help. You were right.