One of the most wanted feature requests for our tooling is Maven integration/support for our projects, such as Seam.
Unfortunately we won't be able to add 'automatic' maven support in the upcoming JBoss Tools 3 release, but we have though started on doing the preparations to do so in a following release.
The biggest part of supporting Maven is that actual runtimes (i.e. Seam, Hibernate, the various specs involved etc.) is now fully mavenized
and the other part is that m2eclipse have matured greatly the last few months so it is now possible to combine Eclipse WTP projects with Maven without having your head explode too often.
To illustrate how well these things work together today without any additional features from JBoss Tools Snjezana Peco made a few screencasts of how to use the examples she made available through JBoss Tools 'Project Example' functionality which are Seam projects that work with the Maven support m2eclipse offers.
Requirements:
- Eclipse 3.4 with JBoss Tools 3 or Developer Studio 2 (CR2 or latest release works with this)
- JBoss AS 4.2, EAP 4.3 or AS 5 GA (the example work with either)
- Seam 2.1.1 GA
- A recent m2eclipse, from Sonatype's updatesite
The following two screencasts Snjezana recorded shows how it works:
Screencast #1: Installing m2eclipse and get the Seam/Maven project example
- Snjezana starts of with showing JBoss Developer Studio 2 (you can use JBoss Tools too, just requires a bit more typing/manual configuration)
- Shows where Seam and AS is configured
- Goes to Help > Software Updates to install m2eclipse from their update site
- Selects Maven Integration, Doxia editor and Maven Integration for WTP under Maven Project Configurators (you can choose them all, but these are just the important ones)
- Wait's for the download and the install etc.
- When m2eclipse is installed she goes to
Project Examples
, types inmaven
and selects theSeam Booking Example - EAR mavenized - seam 2.1.21.GA
- Wait for the download and Maven getting all its dependencies
- Uses quick fix to configure the proper runtimes (i.e. jboss-seam-2.1.1.GA and JBoss 5.0 Runtime), if you had those configured from the start this step would not be needed.
- Wait for the project to compile
- Done!
Screencast #2: Using the Project Example and how to deploy/use the application.
- Shows again how to get the Seam booking example via
Project examples
- Show's that the project is really a Maven project and have all the Maven features enabled
- Find and marks the datasource file (-ds.xml) as Deployable so the datasource will be known to JBoss
- Add the project to server which will deploy it
- Starts the server and goes to http://localhost:8080/booking/home.seam and see the Seam project runs
There you have it - nothing more to it. A mavenized Seam project where all the features of JBoss Tools is available next to all the Maven features m2eclipse brings to the plate.
Snjezana manually adjusted the pom.xml and Seam settings in tools to get this, in upcoming versions of JBoss Tools we will make sure that you can enable this automatically on new Maven/Seam projects.
Hope you like it!
Have fun! /max
Max,
Are Project Examples only available for RHDS? I do not have them on JBoss Tools.
Project Examples are also available in JBoss Tools, just need to install it from a JBoss Tools update site or zip.
p.s. JBDS was only called RHDS in its very first alpha/beta release.
--max
m2clipse-integration, sweet!
Max, if I recall correctly, there wasn't much recent changes in m2eclipse related to the WTP support and functionality been working solid in the dev builds since October or something like that, so your statement is confusing, unless you count few months back to October. :)
When I tried m2eclipse back in October it caused (or rather the collective dependencies) causes crashes and we had issues with WTP EAR projects.
That was fixed recently or at least we couldn't get it to work until December/January and finally in February we got things working. That is in my world view - in the last few months.
--max
I posted this last month, sample project attached. I think the greatest benefit is having all of the source code (that exists in maven repositories) linked automatically by the eclipse plug-in.
http://www.seamframework.org/Community/SeamMaven2GanymedeJBossToolsWTPSampleProject
Cool - sounds like you did the same or similar thing we did.
And yes automatic source linking is the nice part of this :)
I wish I could somehow isolate the automatic dependency lib and source management and provide that on all projects including those that are not Maven projects.
--max
Just wanted to give everyone a heads up - In screencast one, the Seam Booking Example - EAR mavenized - Seam 2.1.1.GA is used - In screencast two, the Seam Booking Example - EAR mavenized is used (this is chosen at time 0:11)
The Booking Example used in screencast two is based on Seam 2.0.2.SP1 and I got it to work fine. When I tried to get the Booking Example Seam 2.1.1.GA by following the instructions above, I get an error message
Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener java.lang.RuntimeException: error while reading /WEB-INF/components.xml at org.jboss.seam.init.Initialization.initComponentsFromXmlDocument(Initialization.java:231) at org.jboss.seam.init.Initialization.create(Initialization.java:134) at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:35) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3856) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4361) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:790) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:770) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553) 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:296) at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.apache.catalina.core.StandardContext.init(StandardContext.java:5312) 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:296) at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:301) at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:104) at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375) at org.jboss.web.WebModule.startModule(WebModule.java:83) at org.jboss.web.WebModule.startService(WebModule.java:61) at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289) at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245) at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) at org.jboss.mx.server.Invocation.invoke(Invocation.java:86) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978) at $Proxy0.start(Unknown Source) at org.jboss.system.ServiceController.start(ServiceController.java:417) at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) at org.jboss.mx.server.Invocation.invoke(Invocation.java:86) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210) at $Proxy44.start(Unknown Source) at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:466) 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.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133) at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142) at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97) at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238) at org.jboss.wsf.container.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:87) at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188) at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95) at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210) at $Proxy45.start(Unknown Source) at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025) at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1015) at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819) at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782) at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133) at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142) at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210) at $Proxy9.deploy(Unknown Source) at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421) at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634) at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263) at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274) at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225) Caused by: java.lang.RuntimeException: Error loading element Init with component name null and component class null at org.jboss.seam.init.Initialization.installComponentsFromXmlElements(Initialization.java:352) at org.jboss.seam.init.Initialization.initComponentsFromXmlDocument(Initialization.java:227) ... 92 more
This issue happens if there is the jboss-seam.jar in WEB-INF/lib of a war project. Since this file already exists in an ear project, seam 2.1.1 isn't started correctly. The maven goal install adds this jar to the WEB-INF/lib directory. A workaround is to remove all the libraries from WEB-INF/lib. This can be done in the Project Explorer or in Navigator view. I will try to fix the issue.
Fixed. You should create new projects.
I'm facing another problem with this tutorial. I'm running "Maven install" over the "booking-ear" project and this error shows up...
(...)
[INFO] ------------------------------------------------------------------------
[INFO] Building JBoss Seam Booking - EAR
[INFO]
[INFO] Id: org.jboss.seam.examples:booking-ear:ear:1.0.0
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [ear:generate-application-xml]
[INFO] Generating application.xml
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [ear:ear]
[INFO] Copying artifact[ejb:org.jboss.seam.examples:booking-ejb:1.0.0] to[booking-ejb-1.0.0.jar]
[INFO]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] ------------------------------------------------------------------------
[INFO] Seam-based Booking Application ........................ SUCCESS [1.813s]
[INFO] JBoos Seam Booking - EJB .............................. SUCCESS [1.497s]
[INFO] JBoss Seam Booking - WAR .............................. SUCCESS [2.653s]
[INFO] JBoss Seam Booking - EAR .............................. FAILED [0.641s]
[INFO] ------------------------------------------------------------------------
[ERROR]
The following mojo encountered an error while executing:
Group-Id: org.apache.maven.plugins
Artifact-Id: maven-ear-plugin
Version: 2.3.1
Mojo: ear
brought in via: packaging: ear
While building project:
Group-Id: org.jboss.seam.examples
Artifact-Id: booking-ear
Version: 1.0.0
From file: /home/dev/workspace/booking-ear/pom.xml
Reason: Cannot copy a directory: /home/dev/workspace/booking/WebContent/WEB-INF/classes; Did you package/install active project artifact:
artifact = org.jboss.seam.examples:booking:war:1.0.0:compile;
project: MavenProject: org.jboss.seam.examples:booking:1.0.0 @ /home/dev/workspace/booking/pom.xml?
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run with the -e flag
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILED
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7 seconds
[INFO] Finished at: Tue Mar 31 00:12:04 UYT 2009
[INFO] Final Memory: 3M/16M
[INFO] ------------------------------------------------------------------------
BTW, I'm using Maven 2.1.0!
Thank you in advance.
I am facing the same problem of yours, using Maven 2.1.0 too.
Thank's god it's not me :)
You can find more details on:
https://issues.sonatype.org/browse/MNGECLIPSE-1173
http://docs.codehaus.org/display/M2ECLIPSE/Project+FAQ#ProjectFAQ-cli
http://docs.codehaus.org/display/M2ECLIPSE/Project+FAQ#ProjectFAQ-WhatMavenversionisusedbyplugin
You can add External Tools Configuration that will call command line maven.
That does not solve problem. I'm using maven 2.1.0 as external tool from eclipse 3.4.2 and still have same problem.
Maven 2.1.0 isn't compatible with 2.0.x. Could you try Maven 2.0.9?
Nop, still the same - I've tried with both 2.0.9 and 2.0.10
You can execute "Maven install" over the booking-ear or booking-parent project using the command line or External Tools (maven 2.0.9).
Now this example contains the booking-test project. The test project can be executed using "Run As>TestNG Suite". "Maven install" doesn't work for now.
I downloaded the current version (as of 5/12/09) of Seam Booking Example - EAR mavenized - Seam 2.1.1.GA, and followed the instructions above. The project builds and deploys and runs correctly. But I can't get the TestNG tests to run. I'm getting the following error:
[Parser] Running: /Workspaces/booking-clean/booking-test/testng.xml FAILED CONFIGURATION: @BeforeSuite startSeam java.lang.RuntimeException: Unable to create a KernelInitializer based on the specified KernelConfig at org.jboss.kernel.KernelFactory.createKernelInitializer(KernelFactory.java:156) at org.jboss.kernel.KernelFactory.assembleNewKernel(KernelFactory.java:99) at org.jboss.kernel.KernelFactory.newInstance(KernelFactory.java:67) at org.jboss.kernel.plugins.bootstrap.AbstractBootstrap.bootstrap(AbstractBootstrap.java:120) at org.jboss.kernel.plugins.bootstrap.AbstractBootstrap.run(AbstractBootstrap.java:89) at org.jboss.embedded.Bootstrap.createKernel(Bootstrap.java:123) at org.jboss.embedded.Bootstrap.getInstance(Bootstrap.java:70) at org.jboss.seam.mock.EmbeddedBootstrap.startAndDeployResources(EmbeddedBootstrap.java:10) at org.jboss.seam.mock.AbstractSeamTest.startJbossEmbeddedIfNecessary(AbstractSeamTest.java:1024) at org.jboss.seam.mock.AbstractSeamTest.startSeam(AbstractSeamTest.java:915) at org.jboss.seam.mock.SeamTest.startSeam(SeamTest.java:58) Caused by: java.lang.NoSuchMethodError: org.jboss.aop.proxy.container.ContainerCache.initialise(Lorg/jboss/aop/AspectManager;Ljava/lang/Class;Lorg/jboss/metadata/spi/MetaData;Z)Lorg/jboss/aop/proxy/container/ContainerCache; at org.jboss.aop.microcontainer.integration.AOPConstructorJoinpoint.dispatch(AOPConstructorJoinpoint.java:78) at org.jboss.kernel.plugins.config.Configurator.instantiate(Configurator.java:92) at org.jboss.kernel.plugins.config.Configurator.instantiateAndConfigure(Configurator.java:67) at org.jboss.kernel.plugins.config.property.PropertyKernelConfig.getImplementation(PropertyKernelConfig.java:159) at org.jboss.kernel.plugins.config.property.PropertyKernelConfig.createKernelInitializer(PropertyKernelConfig.java:118) at org.jboss.kernel.KernelFactory.createKernelInitializer(KernelFactory.java:150) ... 25 more ... Removed 15 stack framesI cannot reproduce the issue. What version of JBDS/JBoss Tools and Seam are you using?
I have the same error here. I have:
maven 2.0.0 eclipse 3.4.2 m2eclipse dev seam 2.1.1ga jboss tools 3.0.1.ga Stable release
Thank you and I wait for any answer!
Maven is 2.0.9 above
You can try to remove your jboss-embedded jars from your local maven repository (i.e., remove the M2_REPO/org/jboss/seam/embedded directory) and call Maven>Update Dependencies for the booking-test project. After that, try to run TestNG Suite again.
Please let me know if this helps.
Actually, no, that was an issue requesting a reversion to the correct version which someone had overwritten by mistake. Changing jars without changing the version number in maven is a big no-no.
Thanks for the reply, I removed the org/jboss/seam/embedded folder from my local repository, updated, received new jars, and still the same error...
In my opinion this issue happens when a Seam test project contains an invalid classpath. It is possible that some plugin within your Eclipse distribution changes the classpath after importing project. I have created https://jira.jboss.org/jira/browse/JBIDE-4413 Could you export your booking-test project and attach it to this jira?
Thanks! How do you want me to export it? Archive file, jar...?
Ahh! I found the error! I was using Jboss 4.2.2 insteadn of 5.0... is there something I can change to use Jboss 4.2.2?
I'm facing now another issue... I'm trying this example in a mac (my laptop). Everything goes fine, but when I deploy the ear in the server, it deploys:
When I run the the server, I get an error because it can't find the jsf libraries, that are into that WEB-INF folder, that should be into the war folder, not in the root...
Someone more faced that issue?
-