Paul Sandoz wrote:
> On Apr 13, 2010, at 9:01 PM, John Lister wrote:
>
> If you did not get by default any JCDI related output for classes it
> means it was not enabled for those classes.
>
> In your logs you should see stuff like:
>
> INFO: Adapting InjectionTarget for
> com.sun.jersey.samples.jcdibeans.resources.JCDIBeanPerRequestResource
> in the scope interface javax.enterprise.context.RequestScoped
> ...
> INFO: Binding the JCDI managed class
> com.sun.jersey.samples.jcdibeans.resources.JCDIBeanPerRequestResource
> in the scope javax.enterprise.context.RequestScoped to
> JCDIComponentProviderFactory in the scope PerRequest
I was getting those log entries, but misread your post and assumed you
wanted more detailed info...
>> Firstly I seemed to have been using the wrong ManagedBean annotation
>> javax.faces.jsf instead of javax.annotation - I'm sure I had tried
>> the latter originally with no luck hence the switch.
> A few things are going on.
>
> Ug! i agree that is confusing.
Annoyingly I'd also been using the faces versions of @SessionScoped and
@ApplicationScoped at different points in my code. I think I picked up
this bad habit after reading some examples on the web, switching to the
correct versions has solved lots of issues - such as application scoped
beans being instantiated on each use, etc
>> Also did 1.1.5 change anything as I recently updated the jersey libs
>> on my glassfish box.
>>
>
> AFAIK there are no regressions related to this area between 1.1.4.1
> and 1.1.5. We did fix an issue in 1.1.5:
>
> https://jersey.dev.java.net/issues/show_bug.cgi?id=423
I wrote that before realising the use of the wrong annotations which
appears to have been the problem. Frustrating there are so many that
seem valid especially as I'm using JSF and they were the highlighted
ones in the netbeans...
> Weld should log a warning. The bean is not getting instantiated by CDI
> but by Jersey. The issue is you have not annotated the constructor
> with @Inject and if you do you should get a deployment error. For
> example, i get the following:
>
> SEVERE: Exception while loading the app
> org.glassfish.deployment.common.DeploymentException: Injection point
> has unstatisfied dependencies. Injection point: parameter 0 of
> constructor public
> com.sun.jersey.samples.jcdibeans.resources.Foo(javax.ws.rs.core.UriInfo);
> Qualifiers: [@javax.enterprise.inject.Default()]
I was getting a similar error for ManagedBean but not for
ApplicationScoped (any version :)
> I forgot to point out there is a sample that exercises a number of
> areas of this functionality:
>
> http://download.java.net/maven/2/com/sun/jersey/samples/jcdi-beans-webapp/1.1.5/jcdi-beans-webapp-1.1.5-gf-project.zip
>
>
Cheers I'll give them the once over, although fixing the annotations
seems to have sorted things.
Thanks
John