[jboss-user] [JBoss Seam] - multi portlet setup

mzeijen do-not-reply at jboss.com
Fri Sep 8 08:41:43 EDT 2006


This is probably not a reall seam question, but I am going to ask it here anyway ;).

At my company we are relaunching our website and we will be using portlets (together with a CMS) to implement the dynamic parts). I am searching for a way to get a reall flexible deployment. I mean by this that I want to seperate the three layers, db-layer (entities), business layer (ejbs) and the view layer (multiple portlets implemented with Seam). 

It would look something like this:


  | dblayer.ear
  |   entities.jar
  | 
  | businesslayer.ear
  |   businesslayer.jar
  | 
  | portlet1.ear
  |   seamComponents.jar
  |   portlet1.war
  | 
  | portlet2.ear
  |   seamComponents.jar
  |   portlet2.war
  | 
  | 

The portlets all use the same business layer and the same entity layer.
That is also wy want this to be as flexible as possible. I don't want to deploy all my portlets again if I change something in my businesslayer. 

It is possible to put an EntityManager in the JNDI by setting some properties in the persistence.xml. I wanted to see if this really worked so I made a little test setup (without the seperate businesslayer):


  | TestEnt.ear
  |  TestEntEJB.jar    < contains the entities and the persistence.xml 
  | 
  | Test.ear
  |   TestEJB.jar        < contains the seam component HelloWorld (HelloWorldAction.class)
  | 

HelloWorldAction class:


  | @Stateful
  | @Name("HelloWorld")
  | @Scope(ScopeType.CONVERSATION)
  | public class HelloWorldAction implements HelloWorld {
  | 	
  | 	@PersistenceContext(unitName="userDatabase", type=EXTENDED)
  | 	private EntityManager em;
  | 	
  | 	@SuppressWarnings("unchecked")
  | 	public String someAction() {
  | 
  | 		List<User> users = em.createQuery("from User u order by u.username").getResultList();
  |  
  | 		return  null;
  | 	}
  | 	
  | 	@Remove @Destroy
  | 	public void destroy() {}
  | }
  | 

The first time I manually deployed the testEnt.ear first and then I deployed the test.ear. To my joy everything worked. The entityManager got injected into the HelloWorldAction class and I could retrieve the users using the query.

But then I stumpled upon some problems:

1. If I redeploy the testEnt.ear the following exception gets thrown:


  | [ServiceController] Problem starting service jboss.j2ee:ear=Test.ear,jar=TestEJB.jar,name=HelloWorldAction,service=EJB3
  | javax.naming.NamingException: Could not bind user transaction for ejb name HelloWorldAction into JNDI under jndiName: /UserTransaction [Root exception is javax.naming.NameAlreadyBoundException]
  | 	at org.jboss.ejb3.EJBContainer.resolveInjectors(EJBContainer.java:631)
  | 	at org.jboss.ejb3.EJBContainer.initializePool(EJBContainer.java:576)
  | 	at org.jboss.ejb3.EJBContainer.start(EJBContainer.java:507)
  | 	at org.jboss.ejb3.SessionContainer.start(SessionContainer.java:82)
  | 	at org.jboss.ejb3.stateful.StatefulContainer.start(StatefulContainer.java:73)
  | 	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.ejb3.ServiceDelegateWrapper.startService(ServiceDelegateWrapper.java:99)
  | 	at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
  | 	at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
  | 	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.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 org.jboss.system.ServiceController.start(ServiceController.java:435)
  | 	at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
  | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  | 	at java.lang.reflect.Method.invoke(Method.java:585)
  | 	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 $Proxy182.start(Unknown Source)
  | 	at org.jboss.ejb3.JmxKernelAbstraction.install(JmxKernelAbstraction.java:82)
  | 	at org.jboss.ejb3.Ejb3Deployment.startPersistenceUnits(Ejb3Deployment.java:626)
  | 	at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:475)
  | 	at org.jboss.ejb3.Ejb3Module.startService(Ejb3Module.java:139)
  | 	at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
  | 	at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
  | 	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.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.GeneratedMethodAccessor7.invoke(Unknown Source)
  | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  | 	at java.lang.reflect.Method.invoke(Method.java:585)
  | 	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 $Proxy90.start(Unknown Source)
  | 	at org.jboss.ejb3.EJB3Deployer.start(EJB3Deployer.java:449)
  | 	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.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.ws.server.WebServiceDeployer.start(WebServiceDeployer.java:117)
  | 	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 $Proxy91.start(Unknown Source)
  | 	at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1007)
  | 	at org.jboss.deployment.MainDeployer.start(MainDeployer.java:997)
  | 	at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:808)
  | 	at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:771)
  | 	at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source)
  | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  | 	at java.lang.reflect.Method.invoke(Method.java:585)
  | 	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 $Proxy6.deploy(Unknown Source)
  | 	at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
  | 	at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:610)
  | 	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: javax.naming.NameAlreadyBoundException
  | 	at org.jnp.server.NamingServer.bind(NamingServer.java:144)
  | 	at org.jnp.interfaces.NamingContext.bind(NamingContext.java:566)
  | 	at org.jnp.interfaces.NamingContext.bind(NamingContext.java:531)
  | 	at org.jboss.util.naming.Util.bind(Util.java:102)
  | 	at org.jboss.util.naming.Util.bind(Util.java:89)
  | 	at org.jboss.ejb3.EJBContainer.resolveInjectors(EJBContainer.java:628)
  | 	... 104 more
  | 

The second problem that I have is when I restart the server. The 
test.ejb gets initialized before the testEnt.ear and then the EntityManager isn't in the JNDI yet. This results in trouble offcourse:


  | 14:24:56,919 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
  | 
  | --- MBeans waiting for other MBeans ---
  | ObjectName: jboss.j2ee:ear=Test.ear,jar=TestEJB.jar,name=HelloWorldAction,service=EJB3
  |   State: NOTYETINSTALLED
  |   I Depend On:
  |     persistence.units:unitName=userDatabase
  | 
  | --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
  | ObjectName: persistence.units:unitName=userDatabase
  |   State: NOTYETINSTALLED
  |   Depends On Me:
  |     jboss.j2ee:ear=Test.ear,jar=TestEJB.jar,name=HelloWorldAction,service=EJB3
  | 

Does someone know a way to solve both problems?

I am also questioning myself if my approach is the right one. Does some one have any idea how I can handle this deployment schema the best way?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3970336#3970336

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3970336



More information about the jboss-user mailing list