[JBoss Seam] - seam-gen, EJBs and different databases
by laessig
i searched the forums and the docs but could not find the answer to my question. setup is jboss as 4.0.5 GA, seam 1.2.1GA, mysql 5.1, mysql connector 5.0.6, eclipse europa.
i have a seam-gen genereted app with EJBs reverse engineered through hibernate. the EJBs all use annotations and are connected to the db via a jndi datasource (as far as i understand). the datasource is defined in app-dev-ds.xml, then the jndi is referenced in persistence-dev.xml to get an EntityManagerFactory which is finally used in componments.xml:
| <core:managed-persistence-context name="entityManager"
| auto-create="true"
| persistence-unit-jndi-name="java:/appEntityManagerFactory"/>
|
this setup is autogenerated and works nicely. the EJBs are all bound to the corresponding database tables.
now i'd like to bring in a new EJB to access a different table in another database. so i duplicated the configuration: added a second datasource in persistence-dev.xml, a second entry in persistence-dev.xml and created a second managed-persistence-context in components.xml. that works fine and i see in the log output that the new managed-persistence-context is created. after that my problem occurs.
after succesfully binding the EJBs to entityManager1 the JPA tries to (re)bind all EJBs to entityManager2 which is of course not possible since it ties into another database table. so i guess i have to exlicitly configure every EJB for a specific entityManager (1 or 2)? but where should i do that? i tried to use @PersistenceContext(unitName="entityManager1") in the EJBs but that did not work.
i have some experience with spring and hibernate but i feel that i need better knowhow on the jboss-seam ejb hibernate integration to work that question out. so thx in advance for any advice.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4061841#4061841
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4061841
18Â years, 10Â months
[JBossCache] - PojoCache with Compile Time Weaving on JBoss 4.2.0 ?
by mbroons
I'm facing some trouble trying to use PojoCache with Compile Time Weaving on JBoss 4.2.0.
I have a DemoService exposing a DemoServiceRemote interface. The interface allows a client application to subscribe/unsubscribe to the service (subscribe, unSubscribe methods) and to invoke a method on the service (invoke method)
The service stores the client sessions into Arralist attribute where ClientSession is defined as follow:
@PojoCacheable
public class ClientSession {
String sessionId = null;
...
The DemoService works fine as long as i use Load Time Weaving on JBoss AS, although Load Time Weaving seems to really slow down the application server start up.
I did not manage to make it work using Compile Time Weaving.
I followed the procedure described here:
http://wiki.jboss.org/wiki/Wiki.jsp?page=PojoCacheAS405
I "aopc" compiled My ClientSession class to create the instrumented version of the class.
I packaged all class files (original classes + generated classes) in a
single DemoService.jar file. (My service is built using the EJB 3.0 @Service but the same behavior was experimented when building my service as a mbean service)
When the service.subscribe() method is called from the client the following exception is raised:
javax.ejb.EJBException: java.lang.ClassCastException: pojo.ClientSession
at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:63)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.service.ServiceContainer.dynamicInvoke(ServiceContainer.java:353)
at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:734)
at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:560)
at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:369)
at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:165)
Caused by: java.lang.ClassCastException: pojo.ClientSession
at org.jboss.aspects.patterns.observable.SubjectInterceptor.invoke(SubjectInterceptor.java:50)
at pojo.ClientSession$sessionId_Set.invokeNext(ClientSession$sessionId_Set.java)
at pojo.ClientSession.sessionId_w_$aop(ClientSession.java)
at pojo.ClientSession.(ClientSession.java:11)
at ejbservice.DemoService.subscribe(DemoService.java:67)
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.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.service.ServiceContainer.dynamicInvoke(ServiceContainer.java:353)
at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:734)
at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:560)
at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:369)
at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:165)
at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:163)
at org.jboss.remoting.Client.invoke(Client.java:1550)
at org.jboss.remoting.Client.invoke(Client.java:530)
at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:62)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:53)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:72)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.service.ServiceRemoteProxy.invoke(ServiceRemoteProxy.java:94)
at $Proxy7.subscribe(Unknown Source)
at client.DemoServiceDelegate.subscribe(DemoServiceDelegate.java:33)
at client.DemoServiceDelegateTest.testSubscribe(DemoServiceDelegateTest.java:30)
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.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71)
at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:32)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:74)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:53)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:72)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.service.ServiceRemoteProxy.invoke(ServiceRemoteProxy.java:94)
at $Proxy7.subscribe(Unknown Source)
at client.DemoServiceDelegate.subscribe(DemoServiceDelegate.java:33)
at client.DemoServiceDelegateTest.testSubscribe(DemoServiceDelegateTest.java:30)
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.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71)
at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:32)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Is the problem due to the way i package my service ?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4061839#4061839
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4061839
18Â years, 10Â months
[JBoss Seam] - how can login automatically after register?
by chibi
i try to use the code like below, but failed
| @PersistenceContext
| private EntityManager em;
|
| @In Identity identity;
| .....
|
| public String register(){
| .....
| em.persist(user);
| identity.setUsername(user.getUsername);
| identity.setPassword(user.getPassword);
| identity.login();
| return "/home.seam";
| }
|
|
the same question is i try to recieve username and password from a SSO system, but failed again when i use identity.login()
| @RequestParameter private String ssoString;
|
| @Create
| public sso(){
| User user = SSO.parser(ssoString);
| if(user.isValid()){
| identity.setUsername(user.getUsername);
| identity.setPassword(user.getPassword);
| identity.login();
| }
| Redirect redirect = Redirect.instance();
| redirect.setViewId("/home.xhtml");
| redirect.execute();
| }
|
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4061838#4061838
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4061838
18Â years, 10Â months