-
1. Re: possible to inject entitymanager with @current
gavin.king Jun 2, 2009 8:32 PM (in response to cremersstijn)According to the spec yes, but I'm not sure if that's available yet in the RI.
-
2. Re: possible to inject entitymanager with @current
cremersstijn Jun 4, 2009 8:08 PM (in response to cremersstijn)It doens't work yet...
I get the following error:
2009-06-04 19:56:14,630 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (main) Error installing to Start: name=vfszip:/C:/Projects/MyThings/programs/jboss-5.1.0.CR1/server/default/deploy/mythings-ear-1.0.0-SNAPSHOT.ear/_WebBeansBootstrapBean state=Create javax.inject.UnsatisfiedDependencyException: The injection point Field @Current private entityManager on Annotated class Class @Named @Stateful ExtraWageTypeActionBean Constructor public ExtraWageTypeActionBean(); Method void @PostConstruct public init(); Method void public remove(@Entity @Named @Table @NamedQueries ExtraWageType); Method void @Remove public destroy(); Method void public save(@Entity @Named @Table @NamedQueries ExtraWageType); Method List public getExtraWageTypeList(); Method void public final wait(); Method void public final wait(long, int); Method void public final native wait(long); Method int public native hashCode(); Method Class public final native getClass(); Method boolean public equals(Object); Method String public toString(); Method void public final native notify(); Method void public final native notifyAll(); with binding types [@Current] in unnamed enterprise bean [be.cremers.mythings.money.domain.action.ExtraWageTypeActionBean] API types [class java.lang.Object, interface be.cremers.mythings.money.domain.action.ExtraWageTypeAction], binding types [@javax.inject.New()] has unsatisfied dependencies with binding types
Let say it works... what will be the type of the persistenceContext? always extended or should it be defined somewhere?
-
3. Re: possible to inject entitymanager with @current
gonorrhea Jun 5, 2009 7:08 AM (in response to cremersstijn)In 299, I did not see any examples with attribute for @PersistenceContext other than unitName, but apparently that is referring to the JPA annotation as there is no @PersistenceContext here: http://docs.jboss.org/webbeans/apidocs/1.0.0.ALPHA2/
So I'm assuming the examples in 299 are the default (tx-scoped) as per:
http://java.sun.com/javaee/5/docs/api/javax/persistence/PersistenceContext.html
So what is the advantage/disadvantage of using @Current rather than @PersistenceContext to inject the EntityManager?
-
4. Re: possible to inject entitymanager with @current
gavin.king Jun 5, 2009 8:00 AM (in response to cremersstijn)
Arbi Sookazian wrote on Jun 05, 2009 07:08:
So what is the advantage/disadvantage of using @Current rather than @PersistenceContext to inject the EntityManager?The same advantage as with any 299 injection, of course! You identify the EntityManager you are interested in using a typesafe binding, instead of a string-based unitName.
-
5. Re: possible to inject entitymanager with @current
gavin.king Jun 5, 2009 8:04 AM (in response to cremersstijn)
Stijn Cremers wrote on Jun 04, 2009 20:08:
It doens't work yet...Did you actually declare it first?
i.e. using:
@Produces @PersistenceContext(unitName="xxx") EntityManager entityManager;
Like I said, this is probably not implemented. But even once it is implemented, you will need to declare a persistence context before you can inject it.
-
6. Re: possible to inject entitymanager with @current
gonorrhea Jun 5, 2009 8:45 AM (in response to cremersstijn)sounds right!
break: Rob Zombie - brick house
they didn't have any bands @ JavaOne in 2003... well, maybe at night at the sausage fest vendor parties!
-
7. Re: possible to inject entitymanager with @current
cremersstijn Jun 5, 2009 8:25 PM (in response to cremersstijn)I've tried with this:
@Produces @PersistenceContext(unitName="xxx") EntityManager entityManager;
But, now i get the following error:
2009-06-05 20:20:52,239 ERROR [STDERR] (http-127.0.0.1-8080-1) java.lang.RuntimeException: javax.inject.ExecutionException: Error getting field entityManager on class be.cremers.mythings.money.domain.action.ExtraWageTypeActionBean 2009-06-05 20:20:52,270 ERROR [STDERR] (http-127.0.0.1-8080-1) at org.jboss.ejb3.EJBContainer.invokeCallback(EJBContainer.java:1123) ... 2009-06-05 20:20:52,286 ERROR [STDERR] (http-127.0.0.1-8080-1) ... 81 more 2009-06-05 20:20:52,286 ERROR [STDERR] (http-127.0.0.1-8080-1) Caused by: java.lang.IllegalArgumentException: Can not set javax.persistence.EntityManager field be.cremers.mythings.money.domain.action.ExtraWageTypeActionBean.entityManager to be.cremers.mythings.money.domain.action.ExtraWageTypeAction_$$_javassist_14 2009-06-05 20:20:52,286 ERROR [STDERR] (http-127.0.0.1-8080-1) at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146) 2009-06-05 20:20:52,286 ERROR [STDERR] (http-127.0.0.1-8080-1) at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150) 2009-06-05 20:20:52,286 ERROR [STDERR] (http-127.0.0.1-8080-1) at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:37) 2009-06-05 20:20:52,286 ERROR [STDERR] (http-127.0.0.1-8080-1) at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:18) 2009-06-05 20:20:52,286 ERROR [STDERR] (http-127.0.0.1-8080-1) at java.lang.reflect.Field.get(Field.java:358) 2009-06-05 20:20:52,286 ERROR [STDERR] (http-127.0.0.1-8080-1) at org.jboss.webbeans.util.Reflections.getAndWrap(Reflections.java:456)
Like you're saying it is probably not implemented so i'll stop trying...
-
8. Re: possible to inject entitymanager with @current
pmuir Jun 6, 2009 11:54 PM (in response to cremersstijn)Right, this syntax isn't implemented, the RI is still using the XML declarations for persistence contexts (and other Java EE resources)