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