Yes you are right. 3.3.7 actually only talks about 'producer methods'

> 3.3.7. Disposer method resolution
> A disposer method is bound to a producer method if:
> •     the producer method is declared by the same bean class as the 
> disposer method, and
> •     the producer method is assignable to the disposed parameter, 
> according to the rules of typesafe resolution defined in Section 5.2, 
> “Typesafe resolution” (using Section 5.2.3, “Assignability of raw and 
> parameterized types”).

I've created https://issues.jboss.org/browse/CDI-145 in the spec issue tracker.

Gerhard, I also think that it works in OWB, but it's not really spec conform 
and might have rough edges ;)  So we should also move our example to using 
producer methods.

Thanks for the report, Gernot!

txs and LieGrue,
strub

--- On Tue, 8/2/11, Gernot <[email protected]> wrote:

> From: Gernot <[email protected]>
> Subject: Re: CODI: Wiki "JPA Usage"
> To: "MyFaces Discussion" <[email protected]>
> Date: Tuesday, August 2, 2011, 10:01 AM
> Thanks for answering!
> 
> I did some investigations:
> (1) It's the JBosstools which reports the error (not core
> Eclipse WTP).
> (2) I deinstalled JBosstools - in Eclipse now everything is
> OK - I
> deployed it on Tomcat 7 (OWB 1.1, Hibernate 3.6) - and got
> following
> error:
> SCHWERWIEGEND:
> javax.enterprise.inject.UnsatisfiedResolutionException:
> Producer
> method component of the disposal method : disposeis not
> found in
> class: mytest.cdi.PersistenceProducer
> Qualifiers: [@javax.enterprise.inject.Default()]
>     at
> org.apache.webbeans.util.InjectionExceptionUtils.throwUnsatisfiedResolutionException(InjectionExceptionUtils.java:71)
>     at
> org.apache.webbeans.config.DefinitionUtil.createDisposalMethods(DefinitionUtil.java:896)
>     at
> org.apache.webbeans.config.DefinitionUtil.defineDisposalMethods(DefinitionUtil.java:874)
>     at
> org.apache.webbeans.component.creation.AbstractInjectedTargetBeanCreator.defineDisposalMethods(AbstractInjectedTargetBeanCreator.java:60)
>     at
> org.apache.webbeans.util.WebBeansUtil.defineManagedBean(WebBeansUtil.java:2692)
>     at
> org.apache.webbeans.config.BeansDeployer.defineManagedBean(BeansDeployer.java:857)
>     at
> org.apache.webbeans.config.BeansDeployer.deploySingleAnnotatedType(BeansDeployer.java:538)
>     at
> org.apache.webbeans.config.BeansDeployer.deployFromClassPath(BeansDeployer.java:483)
>     at
> org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:164)
>     at
> org.apache.webbeans.lifecycle.AbstractLifeCycle.startApplication(AbstractLifeCycle.java:124)
>     at
> org.apache.webbeans.web.lifecycle.WebContainerLifecycle.startApplication(WebContainerLifecycle.java:77)
>     at
> org.apache.webbeans.servlet.WebBeansConfigurationListener.contextInitialized(WebBeansConfigurationListener.java:81)
>     at
> org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
>     at
> org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
>     at
> org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
>     at
> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>     at
> java.util.concurrent.FutureTask.run(FutureTask.java:138)
>     at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>     at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>     at
> java.lang.Thread.run(Thread.java:662)
> 02.08.2011 11:52:45
> org.apache.webbeans.servlet.WebBeansConfigurationListener
> contextInitialized
> 
> (3) I also did a look into CDI spec:
> Disposer Methods are only specified in the producer methods
> section
> (chapter 3.3). And at 3.3.7 disposer methods are only bound
> to
> producer methods (and not to producer fields)
> In chapter 3.4 "producer fields" there are no references to
> disposer methods.
> ==> in my opinion the spec isn't clear?!
> 
> Why do I get the above stack trace?
> If I change my code to use a producer method (not field)
> everything works:
> @RequestScoped
> public class PersistenceProducer
> {
>     @PersistenceContext(unitName =
> "default")
>     @Default
>     private EntityManager   
> entityManager;
> 
>     @Produces
>     public EntityManager getEntityManager()
>     {
>         return
> entityManager;
>     }
> 
>     public void dispose(@Disposes @Default
> EntityManager entityManager)
>     {
>         if
> (entityManager.isOpen())
>         {
>            
> entityManager.close();
>         }
>     }
> }
> 
> thx, gernot
> 
> 2011/8/1 Gerhard Petracek <[email protected]>:
> > hi gernot,
> >
> > i would say: don't rely on the eclipse-plugin. at
> least some months ago it
> > showed a lot of wrong findings in a demo which works
> pretty fine (with owb
> > as well as weld).
> > you can find a working example e.g. at [1]
> >
> > regards,
> > gerhard
> >
> > [1]
> > http://code.google.com/a/apache-extras.org/p/myfaces-codi-examples/source/browse/community/
> >
> > http://www.irian.at
> >
> > Your JSF powerhouse -
> > JSF Consulting, Development and
> > Courses in English and German
> >
> > Professional Support for Apache MyFaces
> >
> >
> >
> > 2011/8/1 Gernot <[email protected]>
> >
> >> I tried "Using one (default) Entity Manager"
> >> (https://cwiki.apache.org/confluence/display/EXTCDI/JPA+Usage):
> >> public class DataBaseProducer
> >> {
> >>    @Produces
> >>    @PersistenceContext(unitName="default")
> >>    @Default
> >>    private EntityManager entityManager;
> >>
> >>    public void dispose(@Disposes @Default
> EntityManager entityManager)
> >>    {
> >>        if(entityManager.isOpen())
> >>        {
> >>            entityManager.close();
> >>        }
> >>    }
> >> }
> >>
> >> This does not work - I get following error at
> "@Disposes" in eclipse:
> >> "There is no producer method declared by the
> (same) bean class that is
> >> assignable to the disposed parameter of a disposer
> method [JSR-299
> >> §3.3.7]"
> >>
> >> Whats wrong?
> >>
> >> thx, gernot
> >>
> >
>

Reply via email to