tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Touzery <emmanuel.touz...@lecip-its.com>
Subject Re: org.apache.webbeans.component.ProducerMethodBean is not applicable for the bean instance : String
Date Thu, 19 May 2016 07:46:26 GMT
Hello,

     yes I didn't expect a TomEE bug, but I'm wondering what could cause 
this behaviour. This is TomEE 1.7.2 but we're also doing this in another 
1.7.2 project, so it's not about the version I think. Maybe some stray 
dependency? The beans.xml, the dependencies look OK. Anywhere else I 
should look?

     Regards,

Emmanuel

On 18/05/16 15:21, Romain Manni-Bucau wrote:
> Hi Emmanuel,
>
> either you use an old version or something else is making it failing, this
> test passes:
> https://gist.github.com/rmannibucau/1d026806a6bb9b89a957c6fba50e4d46
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau>
|
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com> | JavaEE Factory
> <https://javaeefactory-rmannibucau.rhcloud.com>
>
> 2016-05-18 13:42 GMT+02:00 Emmanuel Touzery <emmanuel.touzery@lecip-its.com>
> :
>
>> Hello,
>>
>>      I'm porting a Glassfish application to TomEE and I don't understand
>> this error that I'm getting:
>>
>> org.apache.openejb.core.transaction.EjbTransactionUtil
>> handleSystemException
>> SEVERE: EjbTransactionUtil.handleSystemException: Given bean type : class
>> org.apache.webbeans.component.ProducerMethodBean is not applicable for the
>> bean instance : String, Name:loggedInAppUserUsername, WebBeans
>> Type:PRODUCERMETHOD, API
>> Types:[java.lang.Comparable<String>,java.lang.Object,java.lang.CharSequence,java.lang.String,java.io.Serializable],
>> Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any,javax.inject.Named]
>> java.lang.IllegalArgumentException: Given bean type : class
>> org.apache.webbeans.component.ProducerMethodBean is not applicable for the
>> bean instance : String, Name:loggedInAppUserUsername, WebBeans
>> Type:PRODUCERMETHOD, API
>> Types:[java.lang.Comparable<String>,java.lang.Object,java.lang.CharSequence,java.lang.String,java.io.Serializable],
>> Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any,javax.inject.Named]
>>      at
>> org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:703)
>>      at
>> com.lecip.tms.tms_core.application.BeanHelper.getBeanByName(BeanHelper.java:40)
>>
>> I'm having this pretty trivial bean:
>>
>>
>> public class AppUserUsernameProvider {
>>
>>      public static final String LOGGED_IN_USERNAME =
>> "loggedInAppUserUsername";
>>      @Inject
>>      CurrentAppUserContext mAppUserContext;
>>
>>      @Produces
>>      //this bean will be looked up by this id
>>      @Named(LOGGED_IN_USERNAME)
>>      public String getUsername() {
>>          return mAppUserContext.getUsername();
>>      }
>> }
>>
>> And then I'm trying to use it like that:
>>
>>          String username =
>> BeanHelper.getBeanByName(AppUserUsernameProvider.LOGGED_IN_USERNAME,
>> String.class);
>>
>> And it fails on the getBeanByName() call with the stack I pasted. Not sure
>> what's going on?
>>
>> Thank you!
>>
>> Emmanuel
>>
>>


Mime
View raw message