Techieexchange’s Techblog

RAD: Seam development with Eclipse and Tomcat Step-by-Step-Tutorial Screencast

Posted on: November 11, 2007


Jboss Seam
, one of the most innovative full-stack web application framework in Java EE era.

Letz dive in to the tutorial directly without explaining more about Seam.

In order to develop an enterprise application, one must have
an application server installed locally, which is a big pain
when considering system resource and performance. During the
development period developer always perfer to have his
code-hotdeploy time as short as possible, which rapidly
increases his development and production. But this is not
easily achieved when application servers are used during
development. An alternative is to use web servers which are
very light when compared to Application servers. Seam has a
good support for Tomcat webserver.

This tutorial focuses Seam development under Tomcat webserver without support for EJB, that means Seam with POJO and JPA+Hibernate as Persistence provider.

Main goal of this tutorial is to achieve RAD-Rapid Application Development with Seam, Tomcat and Eclipse.

Requirements for Seam development envirnoment:

Download latest Seam release

Download Tomcat 5.5
 or Tomcat 6
Download latest Eclipse

Download Eclipse-Tomcat-Sysdeo plugin

This is a screencast (static) showing all the screenshots without explanation.

[splashcast LRUS5101RC]

Here we go….

Extract Seam 2 GA distribution on local hard disk (see Figure 1)


Download JBoss Seam and extract

JPA example from Seam 2 GA distribution (see Figure 2)


2-seam-jpa-example.png

Build JPA example for Tomcat 5.5 by using ant (make sure that ANT already installed) command:ant tomcat55

Building JPA WAR file (see Figure 3)


3-build-jpa-example-tomcat.png

Once build successfull, then you can find the war file inside dist-tomcat55 folder (see Figure 4)


4-build-jar-jpa-example.png

Now import WAR file to Eclipse to make an Eclipse project (see Figure 5)


5-eclipse-import-example.png

In order to import WAR file select Web -> WAR file from Eclipse import console (see Figure 6)


6-eclipse-import-war.png

Choose absolute path of jboss-seam-jpa.war file and press next (see Figure 7)


9-eclipse-import-jpa-war.png

Import all libs from WEB-INF/lib (don’t select any libs) (see Figure 8)


10-eclipse-import-war-default-lib.png

Here’s new project created in Eclipse workspace (see Figure 9)


11-eclipse-project-hierarchy.png

Create classes inside WEB-INF to build src files (see Figure 10)


12-eclipse-create-classes-folder.png

Configure the build path so that src folder takes correct classes folder (see Figure 11)


13-project-class-folder.png

Choose classes folder as default output folder (see Figure 12)


14-select-class-folder.png

Copy src from Seam-JPA example (see Figure 13)


15-copy-src-from-example.png

Paste into the src folder in Eclipse (see Figure 14)


16-paste-src-from-example.png

Now src are shown in the hierarchy but with errors (see Figure 15)


17-project-jpa-src.png

Delete ImportedClasses folder in root of Project workspace (see Figure 16)


18-delete-importedclasses-folder.png

In order to remove src errors in the project import TestNG lib to WEB-INF/lib (see Figure 17)


19-import-testng-jar.png

Now Project src has been done without any errors (see Figure 18)


20-project-no-errors.png

Configure Tomcat Sysdeo plugin to installed home directory of Tomcat (see Figure 19)


7-eclipse-sysdeo-tomcat-configuration.png

See Eclipse toolbar for Sysdeo-Tomcat shortcuts – Start, Shutdown, Restart (see Figure 20)


8-eclipse-sysdeo-tomcat-installed.png

Tell the created Project (jboss-seam-jpa) that it is a web project to Sysdeo plugin (Project ->rightclick-Properties-> Tomcat) (see Figure 21)


21-project-as-tomcat-web-project.png

Now update/define about project’s context in Tomcat (server.xml will be updated) (see Figure 22)


22-update-context-tomcat.png

Open context.xml (inside Webcontent/META-INF) and copy Resource tag (see Figure 23)


23-copy-context-defn.png

Goto server.xml (Tomcat_Home/conf) and see whether project context is defined (see Figure 24)


24-server-xml-context-before.png

Paste Resource tag (make sure that Resource is closed properly) copied from context.xml as child tage to Context tag in server.xml (see Figure 25)


25-server-xml-context-after.png

In order to work with HSQL DB, copy hsql.jar from Seam distribution to Tomcat-Home/common/lib folder (see Figure 26)


26-paste-hsql-lib-in-tomcat.png

Now all configuration things are over, so Start Tomcat inside Eclipse by pressing Start icon on Eclipse-Sysdeo toolbar (see Figure 27)


27-start-tomcat-sysdeo.png

You can see the console output of Tomcat saying server started (see Figure 28)


28-tomcat-started.png

Test whether the application started without any errors by opeing a browser and navigating
http://localhost:tomcatport/jboss-seam-jpa

Note that the footer of the front page. We’re going to change that in the next step. (see Figure 29)


29-test-example-browser1.png

Open home.xhtml (front page of the application) located inside WebContent and check the footer (see Figure 30)


30-home-xhtml-src-before.png

Edit footer note and save the page (see Figure 31)


31-edit-home-xhtml-page.png

Now goto opened browser where application is already running, and press Refresh or F5 to reload the page.
That’s it.. without starting the server your code got hot deployed and web page was reloaded. (see Figure 32)


32-refresh-web-page.png

Please note that Tomcat should be used only during development phase in order to increase the development productivity, use some application server to deploy production applications.

I hope this tutorial gives a kick-off project template for Seam with POJO+JPA+Hibernate based application.

Share your thoughts.

47 Responses to "RAD: Seam development with Eclipse and Tomcat Step-by-Step-Tutorial Screencast"

thx for the documentation!

We are planning to use Seam as in combination with EJB3.0 to create an “webbased” enterprise application!

This means we will not have the chance to skip AS and use Tomcat instead 😦

Hi necrite,
My next tutorial would be Seam+EJB3 on Tomcat (with JBoss embedded) for development envirnoment, but for production you need to go with some application server.
That means without changing the code that you developed on Tomcat should be deployable (with change in some configuration files) using build script on your favourite application server.

Moreover you should deeply think about your usage of EJBs in web application. Try to find out the need to use for EJBs and think whether its possible to replace it without EJBs (POJO). Eventhough EJB3 is lightweight when compared to its previous versions, but you can achieve all the features of EJB with POJO and Seam. One of the biggest advantage with Seam+POJO+JPA is, you can run it on all servers (J2EE, JEE5, Webserver) and application-stack would be easy to maintain.

“One of the biggest advantage with Seam+POJO+JPA is, you can run it on all servers (J2EE, JEE5, Webserver) and application-stack would be easy to maintain”

One of the biggest disadvantage with Seam+POJO+JPA is, you can not generate the staff with the seam-gen, can you?

How can I make it, if I have just about 10 or 20 tables in MySQL? 😦

Hi !
This is a very good tutorial.
Thanks for the link !

[…] RAD – Rapid Application Development with Eclipse and Tomcat, focusing on developer productivity. RAD: Seam development with Eclipse and Tomcat Step-by-Step-Tutorial Screencast Techieexchanges Te… I hope this tutorial will be useful for J2EE/JEE […]

[…] Development mit Eclipse und Tomcat, konzentriert auf entwickler Produktivitt geschrieben. https://techieexchange.wordpress.com/…al-screencast/ Ich hoffe, dass dieses Tutorial ntzlich sein wird fr die J2EE/JEE Entwickler. Sorry for my bad […]

Thanks for the link.. I definitely plan to use Tomcat +
JPA..
I think its better to avoid EJB as far as possible(in
some projects),
even though EJB3 is like POJO , as I really dont need the
“EJB3 features”, and dont want to use any AS in comparison with the “fast light-weight” Tomcat..

Nice tutorial…one suggestion combine all these images..make a ppt ans share it on slideshare..also instead of using sysdeo plugin you could have used eclipse europa JEE version which supports most of the app servers/servlet containers..no additional plugins needed….

For ome of the comments above
Yes you can generate simple CRUD apps using seam..when tables are in place..just look for the documentation on
seam generate-entities (after seam setup)

Do you really find running JBoss to be that resource intensive? JBoss starts up on my laptop in about 15 seconds, and I can hot deploy my ear without issue, so I just use JBoss for my development.

Hi, Prem
We post the translation in JBossSeam.com today, this is the link: http://www.jbossseam.com/2007/11/16/seam-development-with-eclipse-and-tomcat/
Thanks for your support!

I tried to use above steps with MyEclipse 6.0. I was
not able to use “Apache Tomcat 5.5” as runtime.. Hence
change the runtime to “No RunTime”.
a) Since i am using Myeclipse 6.0 , i had to add
webcapability to deploy it..
But it failed, and hence i manually deployed it.
I did not need to copy the context.xml in server.xml , but
had to copy the hsqldb.jar in to common/lib.

b) I went to TestNg.jar and downloaded latest version, which
had missing jar file for 1.5.. Hence i dowlonad older version
which had it.

c) I was getting weird errors at startup. .And added below to
remove it.

com.sun.faces.config.ConfigureListener

Hi Zahid Shaikh,
I have no experience with MyEclipse, so try to use plain Eclipse 3.3 / 3.2 and repeat all the steps as posted on this blog.

Also you could set your log level to DEBUG to see exactly what kind of error happened to throw
com.sun.faces.config.ConfigureListener

If possible send me the complete stack trace.

Post your comment, if still not working.

Regards,
TechieExchange

Thanks.. it worked in Myeclipse 6.0 after i did
the mentioned steps..
But it included lots of other unrelated projects – jboss-el, jboss-seam-ui, which i am ignoring..

Thanks for this tutorial. I’m running into a problem, and I’d appreciate any help. I’m using Tomcat 6 and have followed all the instructions. When I start the server, I get the following error:

SEVERE: Could not find datasource: java:comp/env/jdbc/TestDB
javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:29)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:730)
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(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:21)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
at org.jboss.seam.Component.callComponentMethod(Component.java:2082)
at org.jboss.seam.Component.callCreateMethod(Component.java:1997)
at org.jboss.seam.Component.newInstance(Component.java:1968)
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:95)
at org.jboss.seam.init.Initialization.init(Initialization.java:555)
at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:34)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3830)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4337)
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:626)
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:1138)
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:566)
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)
Dec 5, 2007 1:30:24 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
javax.persistence.PersistenceException: org.hibernate.HibernateException: Could not find datasource
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(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:21)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
at org.jboss.seam.Component.callComponentMethod(Component.java:2082)
at org.jboss.seam.Component.callCreateMethod(Component.java:1997)
at org.jboss.seam.Component.newInstance(Component.java:1968)
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:95)
at org.jboss.seam.init.Initialization.init(Initialization.java:555)
at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:34)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3830)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4337)
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:626)
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:1138)
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:566)
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: org.hibernate.HibernateException: Could not find datasource
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:56)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:29)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:730)
… 43 more
Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
… 50 more
Dec 5, 2007 1:30:24 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Dec 5, 2007 1:30:24 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/jboss-seam-jpa] startup failed due to previous errors

Please disregard the previous comment; I figured out what I was doing wrong.

Two remarks regarding the tutorial:
“Paste Resource tag … in server.xml (see Figure 25)” – for Tomcat 6 this should be changed to “… in conf/Catalina/localhost/jboss-seam-jpa.xml” (this is the problem that Bruce reported).

“In order to work with HSQL … Tomcat-Home/common/lib folder (see Figure 26)” – for Tomcat 6 this should be changed to “… Tomcat-Home/lib”

Hey Bruce, how did you solve your problem?
Im running into the same…

Thanks for your help!

Arthur, please see my two remarks.

description The requested resource (/jboss-seam-jpa/) is not available.

Please ignore my previous message Worked after Added webContent in docBase line.

Arthur, I had made a mistake in my server.xml. That file should contain something like:

Previous post didn’t show my server.xml excerpt. Second attempt:

I am able to run the application after importing it in eclipse and doing the configuration changes. But when I try to run the test cases i get this exception .

FAILED CONFIGURATION: @BeforeClass init
javax.servlet.ServletException: ServletContext not allow to getResourceAsStream for /WEB-INF/web.xml
at org.ajax4jsf.webapp.WebXml.init(WebXml.java:113)
at org.ajax4jsf.resource.InternetResourceService.init(InternetResourceService.java:133)
at org.ajax4jsf.webapp.BaseFilter.init(BaseFilter.java:148)
at org.jboss.seam.web.Ajax4jsfFilter.init(Ajax4jsfFilter.java:86)
at org.jboss.seam.servlet.SeamFilter.init(SeamFilter.java:97)
at org.jboss.seam.mock.BaseSeamTest.createSeamFilter(BaseSeamTest.java:961)
at org.jboss.seam.mock.BaseSeamTest.init(BaseSeamTest.java:942)
at org.jboss.seam.mock.SeamTest.init(SeamTest.java:42)
… Removed 22 stack frames
SKIPPED CONFIGURATION: @BeforeMethod begin
SKIPPED CONFIGURATION: @AfterMethod end
SKIPPED CONFIGURATION: @BeforeMethod begin
SKIPPED CONFIGURATION: @AfterMethod end
SKIPPED CONFIGURATION: @AfterClass cleanup
SKIPPED: testLogin
SKIPPED: testLoginComponent

Hi Alok Kumar,
Actually there are some conflicts with SeamTest cases. We already discussed about this in Seam forum.
Please search for posts related to this or post a new one.

Seam old forum:
http://www.jboss.com/index.html?module=bb&op=viewforum&f=231

Seam new Forum:
http://www.seamframework.org/Community/Forums

Hope this helps.

Regards,
Techieexchange

Did anyone add a WebService functionality to this jpa example? Basic Idea is to have tomcat+seam+webservices.

can anyone tell me any site where i can find information about using quartz in seam

Great tutorial. Thanks a lot.

Just some feedback to help other new comers like myself.

The steps above didn’t work for me exactly. Have to do some tweaks to make it work.

I am using MyEclipse 6.0.1 and
jboss-seam-2.0.1GA, tomcat6

– after running ‘clean’ then build project in MyEclipse,
persistence.xml from /WebContent/WEB-INF/classes/META-INF will be deleted,
what I did to get around was copy everything from
/WebContent/WEB-INF/classes except for /WebContent/WEB-INF/classes/org/* to /src

– also I need to copy asm.jar from \lib to
/WebContent/WEB-INF/lib to avoid this problem
http://www.seamframework.org/Community/AreTheTomcatInstructionsIncomplete

– I modify \conf\Catalina\localhost\jboss-seam-jpa.xml instead of server.xml as in tutorial, but change in jboss-seam-jpa.xml will be lost after each update of context definition as in Fig 23.

Other than that, everything work.

Thanks again

Thanks so much for the screen cast.

Got it working once I realized that my “default output folder” wasn’t set correctly. It was originally pointing to ‘jboss-seam-jpa/build/classes’ and had to be changed to ‘jboss-seam-jpa/WebContent/WEB-INF/classes’

Hi Bruce,i have exactly the same errors that you posted,could please tell me what as wrong with you

This tutorial is nice. Everything worked perfect, but it can be improved little bit:

Instead of “…Paste Resource tag … copied from context.xml as child tag to Context tag in server.xml (see Figure 25)” it is better to past it in Sysdeo Tomcat Project Configuration (see Figure 21) to “Extra information” Text Area. In this case it will go automatically to server.xml, so no need to edit it by hand.

Hi I have configured this JPA seam project with eclipse 3.3 and tomcat 6.0.I followed all the above mentioned steps.But i am getting the error……see the satck trace

Sep 15, 2008 3:10:34 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener
java.lang.LinkageError: loader constraints violated when linking javax/el/ExpressionFactory class
at com.sun.faces.config.ConfigureListener.registerELResolverAndListenerWithJsp(ConfigureListener.java:1570)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:403)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1247)
at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:604)
at org.apache.catalina.manager.HTMLManagerServlet.doGet(HTMLManagerServlet.java:129)
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:525)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
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:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)

suggestion regarding this will be very helpful

great post.
Helped me a lot. Very didactic.
Congratulations.

[…] one or two good ones for tomcat but nothing that works out of the box. One special tutorial is a screencast with lots of good screenshots but it’s kinda redundant now because JBoss tools have evolved over […]

Hi !! Thanks for your share, it’s very useful. But, i have a question for you. This tutorial guide me how to run an project with Tomcat, but how can i create new projects use JBossSeam ?

Hi, I´ve run the app in tomcat 6 successfully, but when I try to run the test-examples, I got this kind of exception:

java.lang.NullPointerException
at java.lang.String.startsWith(String.java:1252)
at java.lang.String.startsWith(String.java:1281)
at org.ajax4jsf.webapp.WebXml.getFacesResourceKey(WebXml.java:189)
at org.ajax4jsf.webapp.WebXml.getFacesResourceKey(WebXml.java:222)
at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:139)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:500)
at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
at org.jboss.seam.mock.AbstractSeamTest$Request.run(AbstractSeamTest.java:491)
at org.jboss.seam.example.jpa.test.LoginTest.testLogin(LoginTest.java:52)

Note that link

http://www.seamframework.org/Community/TestNGOfSeamEmailFails

I´m not the only one… Something I missed? I didn´t any modifications… (sorry about my english)

Very interesting and informatic tutorial. I was able to run it in tomcat as well as in jboss. I went for further step instead using Hypersonic DB (it is default set) i pointed to Oracle 10g XE. It works fine. On next step I created two tables Countries and regions Countries table having country_id(PK),Country_name and region_id(FK) column and Regions table is having region_id(PK) and region_name column. I created Country.java for Entity and CountryAction.java on the same fashion as it is in Hotel.java and HotelSearchAction.java.
I wrote my query as below in my CountryAction.queryCountries() as below
countries = em.createQuery(“select c from Countries c where lower(c.countryname) like #{cpattern} or lower(c.regionId) like #{cpattern} “)
.setMaxResults(pageSize)
.setFirstResult( page * pageSize )
.getResultList();

I had List countries;
I used cpattern instead pattern as it is used in HotelSearchAction. And i had a jsp page for listing the country list in a table. But I got Illegal Argument queryException error which is telling my entity is not mapped.

But I did all as it is followed for Hotel and HotelSearchAction. What is wrong going here. Thanks in advance.

[…] Run Seam projects in eclipse on Tomcat December 10, 2009 Ehsan Leave a comment Go to comments Hi I found one of the best solution for creating and running seam projects in eclipse on Tomcat so quickly : https://techieexchange.wordpress.com/2007/11/11/rad-seam-development-with-eclipse-and-tomcat-step-by-… […]

Hi

This URL is very useful. Thanks for that.
I followed all these steps and done successfully but while came on start tomcat i got following errors:

Listening for transport dt_socket at address: 6677
log4j:WARN No appenders could be found for logger (org.apache.catalina.startup.E
mbedded).
log4j:WARN Please initialize the log4j system properly.
Aug 27, 2010 7:30:41 PM com.sun.faces.config.ConfigureListener contextInitialize
d
INFO: Initializing Mojarra (1.2_12-b01-FCS) for context ‘null’
Aug 27, 2010 7:30:43 PM com.sun.faces.spi.InjectionProviderFactory createInstanc
e
INFO: JSF1048: PostConstruct/PreDestroy annotations present. ManagedBeans metho
ds marked with these annotations will have said annotations processed.
log4j:WARN No appenders could be found for logger (org.apache.commons.digester.D
igester.sax).
log4j:WARN Please initialize the log4j system properly.

i am using tomcat 5.5 and jboss-seam-2.2.0.GA
so please help for this.
Thanks in advance.

Hi This example is really very good. It’s working in both tomcat 5.5 and tomcat 6.
You have to just copy only two file before deploy.
hsqldb.jar and el-api.jar in $TOMCAT_HOME/common/lib (Tomcat 5.5) or $TOMCAT_HOME/lib (Tomcat 6)

Thanks Again
Deepak Kumar Sharma

For the new seam-gen project this URL is very good. it’s working for me:

Tweaking JBoss Tools and Eclipse for Tomcat 6

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.

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

java:/seamwebDatasource</jta-data-source

to this

java:comp/env/jdbc/seamweb

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.

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

1.

antlr.jar
2. asm.jar
3.

cglib.jar
4.

commons-beanutils.jar
5.

common-collections.jar
6.

commons-digester.jar
7.

commons-lang.jar
8.

commons-logging.jar
9.

dom4j.jar
10.

hibernate-annotations.jar
11.

hibernate-commons-annotations.jar
12.

hibernate-entitymanager.jar
13.

hibernate.jar
14.

hibernate-validator.jar
15.

javassist.jar
16.

jbos-archive-browsing.jar
17.

jboss-el.jar
18.

jboss-seam-debug.jar
19.

jboss-seam.jar
20.

jboss-seam-ui.jar
21.

jsf-api.jar
22.

jsf-facelets.jar
23.

jsf-impl.jar
24.

jstl.jar
25.

jta.jar
26.

persistence-api.jar
27.

richfaces-api.jar
28.

richfaces-impl.jar
29.

richfaces-ui.jar

If everything went well, the application should run inside tomcat without a problem.

Thanks

I am glad I landed on this link, was struggling for 3 days to get a simple Seam project working on eclipse..
I have created a sample project based on this document..
you can find it at
https://github.com/markatharvest/jboss-seam-jpa

Leave a comment