[EJB 3.0] - Intercepting EntityManagerFactory creation
by davesb
I'm using JPA (Hibernate)/Seam/JBoss AS and I have an unusual (perhaps) problem to solve.
The application consists of a bunch of normal JPA mapped entities PLUS a number of "unknown-at-compile-time" dynamic entities. These are defined in a separate configuration and can change at runtime. I'm looking at using Hibernate's Map-based session for the dynamic entities, and this seems to work really well.
If I use Hibernate directly and create my own HibernateSessionFactory (like in a Java SE environment) I can easily intercept the factory creation and add in the dynamic entities (using the configuration.addResource() or similar). However, I'd like to keep the convenience of standard EJB annotations and inject the EntityManager into my EJBs using @PersistenceContext.
Is there a neat way of intercepting the EntityManagerFactory creation? Can I get into the Hibernate configuration (to change it) through the container provided EntityManagerFactory? Is there a better way of doing this?!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4109822#4109822
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4109822
17 years, 1 month
[Microcontainer] - How to get the latest microcontainer document
by crystal70
I check the MicroContainer 2.0.0Beta7, and change the directory to docs,then type the command like this:
mvn generate-sources
the result is :
[INFO] Scanning for projects...
[INFO] Reactor build order:
[INFO] JBossMC Getting Started Guide (en_US)
[INFO] JBossMC Getting Started Guide (aggregator)
[INFO] JBossMC Reference Guide (en_US)
[INFO] JBossMC Reference Guide (aggregator)
[INFO] JBoss Microcontainer Docs
Downloading: http://repo1.maven.org/maven2/org/jboss/maven/plugins/maven-jdocboo
k-plugin/2.0.0/maven-jdocbook-plugin-2.0.0.pom
Downloading: http://repo1.maven.org/maven2/org/jboss/maven/plugins/maven-jdocboo
k-plugin/2.0.0/maven-jdocbook-plugin-2.0.0.pom
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
GroupId: org.jboss.maven.plugins
ArtifactId: maven-jdocbook-plugin
Version: 2.0.0
Reason: Unable to download the artifact from any repository
org.jboss.maven.plugins:maven-jdocbook-plugin:pom:2.0.0
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Mon Dec 03 20:35:11 CST 2007
[INFO] Final Memory: 1M/3M
[INFO] ------------------------------------------------------------------------
How should I do to get the latest document of mircocontainer?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4109821#4109821
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4109821
17 years, 1 month
[JBoss Seam] - Backing and session bean communication error
by vas_opel
I have implemented a session bean to keep parameter values that will be used by the entire application.This is the simplest form of my session bean:
| @Stateful
| @Name("cart")
| @Scope(SESSION)
| public class Brtest implements BrtestI,Serializable{
|
| static final long serialVersionUID = 8722576722482084467L;
|
| @PersistenceContext(type=PersistenceContextType.EXTENDED)
| EntityManager em;
|
| public String getCart() {
| return "hello";
| }
|
| @Destroy
| @Remove
| public void destroy() {}
|
| }
|
I have to inject an instance of the previous session bean in one of my backing beam following the dvd store example of the seam examples and this is my code:
| @Stateful
| @Name("testSession")
| public class TestSessionManager extends TestSessionManager implements serialisable{
|
| @In(create=true) Brtest cart;
|
| @PersistenceContext(type=PersistenceContextType.EXTENDED)
| private EntityManager em;
|
| static final long serialVersionUID = -6536629890251170098L;
|
| @In
| protected FacesContext facesContext;
|
| protected void getValueFromSession(){
| cart.getCart();
| }
|
|
The exception thrown is this:
anonymous wrote :
|
| Caused by: javax.ejb.EJBTransactionRolledbackException: java.lang.IllegalArgumentException: could not set field value: testSession.cart
| at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:93)
| at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
| at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
| 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.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)
| 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:102)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
| 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.stateful.StatefulContainer.localInvoke(StatefulContainer.java:203)
| at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:98)
| at $Proxy341.getUsername(Unknown Source)
| 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.seam.util.Reflections.invoke(Reflections.java:20)
| at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
| at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:72)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
| at org.jboss.seam.interceptors.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:40)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
| at org.jboss.seam.interceptors.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:31)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
| at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
| at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:50)
| at org.javassist.tmp.java.lang.Object_$$_javassist_290.getUsername(Object_$$_javassist_290.java)
| ... 73 more
| Caused by: java.lang.IllegalArgumentException: could not set field value: testSession.cart
| at org.jboss.seam.Component.setFieldValue(Component.java:1559)
| at org.jboss.seam.Component.access$500(Component.java:135)
| at org.jboss.seam.Component$BijectedField.set(Component.java:2285)
| at org.jboss.seam.Component.injectAttributes(Component.java:1368)
| at org.jboss.seam.Component.inject(Component.java:1195)
| at org.jboss.seam.interceptors.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
| at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
| at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
| at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
| at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:53)
| 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.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
| 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.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:71)
| 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:46)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
| ... 104 more
| Caused by: java.lang.IllegalArgumentException: Could not set field value by reflection: TestSessionManager.cart on: twp.session.TestSessionManager with value: class org.javassist.tmp.java.lang.Object_$$_javassist_291
| at org.jboss.seam.util.Reflections.set(Reflections.java:77)
| at org.jboss.seam.Component.setFieldValue(Component.java:1555)
| ... 128 more
| Caused by: java.lang.IllegalArgumentException
| at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
| at java.lang.reflect.Field.set(Field.java:656)
| at org.jboss.seam.util.Reflections.set(Reflections.java:63)
| ... 129 more
|
|
Does anyone know what may cause this exception? Is there any additional configuration to be made (such as property files) in order a backing bean to communicate with the session bean?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4109820#4109820
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4109820
17 years, 1 month