Discussion:
@Produces inside jar
Matthew Broadhead
2017-11-27 09:00:26 UTC
Permalink
If I include a jar in several webapps and the jar contains some
@ApplicationScoped beans it seems to work fine.  i.e. those
@ApplicationScoped beans can be injected into the beans in the webapps
without conflict.

However if I use @Produces, e.g
@Produces
@MyQualifier
@RequestScoped
public MyCustomObject token() {
  return createMyCutomObject();
}

Then i get  org.apache.openejb.cdi.OpenEJBLifecycle.startApplication CDI
Beans module deployment failed
 org.apache.webbeans.exception.WebBeansDeploymentException:
javax.enterprise.inject.AmbiguousResolutionException: There is more than
one Bean with type com.example.MyCustomObject

Is there a conflict between the various webapps?
Romain Manni-Bucau
2017-11-27 09:17:16 UTC
Permalink
No but likely MyCustomObject is scanned and has a default constructor

Romain Manni-Bucau
@rmannibucau | Blog | Old Blog | Github | LinkedIn
Post by Matthew Broadhead
If I include a jar in several webapps and the jar contains some
@ApplicationScoped beans it seems to work fine. i.e. those
@ApplicationScoped beans can be injected into the beans in the webapps
without conflict.
@Produces
@MyQualifier
@RequestScoped
public MyCustomObject token() {
return createMyCutomObject();
}
Then i get org.apache.openejb.cdi.OpenEJBLifecycle.startApplication CDI
Beans module deployment failed
javax.enterprise.inject.AmbiguousResolutionException: There is more than one
Bean with type com.example.MyCustomObject
Is there a conflict between the various webapps?
Matthew Broadhead
2017-11-27 09:24:04 UTC
Permalink
should not be serializable?
Post by Romain Manni-Bucau
No but likely MyCustomObject is scanned and has a default constructor
Romain Manni-Bucau
@rmannibucau | Blog | Old Blog | Github | LinkedIn
Post by Matthew Broadhead
If I include a jar in several webapps and the jar contains some
@ApplicationScoped beans it seems to work fine. i.e. those
@ApplicationScoped beans can be injected into the beans in the webapps
without conflict.
@Produces
@MyQualifier
@RequestScoped
public MyCustomObject token() {
return createMyCutomObject();
}
Then i get org.apache.openejb.cdi.OpenEJBLifecycle.startApplication CDI
Beans module deployment failed
javax.enterprise.inject.AmbiguousResolutionException: There is more than one
Bean with type com.example.MyCustomObject
Is there a conflict between the various webapps?
Romain Manni-Bucau
2017-11-27 09:25:31 UTC
Permalink
hmm there is not link with serializable but if it is a cdi bean then
producing it will make it ambiguous

add @vetoed on the class maybe?

Romain Manni-Bucau
@rmannibucau | Blog | Old Blog | Github | LinkedIn
Post by Matthew Broadhead
should not be serializable?
Post by Romain Manni-Bucau
No but likely MyCustomObject is scanned and has a default constructor
Romain Manni-Bucau
@rmannibucau | Blog | Old Blog | Github | LinkedIn
2017-11-27 10:00 GMT+01:00 Matthew Broadhead
Post by Matthew Broadhead
If I include a jar in several webapps and the jar contains some
@ApplicationScoped beans it seems to work fine. i.e. those
@ApplicationScoped beans can be injected into the beans in the webapps
without conflict.
@Produces
@MyQualifier
@RequestScoped
public MyCustomObject token() {
return createMyCutomObject();
}
Then i get org.apache.openejb.cdi.OpenEJBLifecycle.startApplication CDI
Beans module deployment failed
javax.enterprise.inject.AmbiguousResolutionException: There is more than one
Bean with type com.example.MyCustomObject
Is there a conflict between the various webapps?
Matthew Broadhead
2017-11-27 09:31:11 UTC
Permalink
yes that works.  does that mean all classes are being added as cdi for
some reason?  or only ones that are being produced?
Post by Romain Manni-Bucau
hmm there is not link with serializable but if it is a cdi bean then
producing it will make it ambiguous
Romain Manni-Bucau
@rmannibucau | Blog | Old Blog | Github | LinkedIn
Post by Matthew Broadhead
should not be serializable?
Post by Romain Manni-Bucau
No but likely MyCustomObject is scanned and has a default constructor
Romain Manni-Bucau
@rmannibucau | Blog | Old Blog | Github | LinkedIn
2017-11-27 10:00 GMT+01:00 Matthew Broadhead
Post by Matthew Broadhead
If I include a jar in several webapps and the jar contains some
@ApplicationScoped beans it seems to work fine. i.e. those
@ApplicationScoped beans can be injected into the beans in the webapps
without conflict.
@Produces
@MyQualifier
@RequestScoped
public MyCustomObject token() {
return createMyCutomObject();
}
Then i get org.apache.openejb.cdi.OpenEJBLifecycle.startApplication CDI
Beans module deployment failed
javax.enterprise.inject.AmbiguousResolutionException: There is more than one
Bean with type com.example.MyCustomObject
Is there a conflict between the various webapps?
Romain Manni-Bucau
2017-11-27 09:48:35 UTC
Permalink
all i guess,

System.out.println(beanManager.getBeans(Object.class)) should list them

Romain Manni-Bucau
@rmannibucau | Blog | Old Blog | Github | LinkedIn
yes that works. does that mean all classes are being added as cdi for some
reason? or only ones that are being produced?
Post by Romain Manni-Bucau
hmm there is not link with serializable but if it is a cdi bean then
producing it will make it ambiguous
Romain Manni-Bucau
@rmannibucau | Blog | Old Blog | Github | LinkedIn
2017-11-27 10:24 GMT+01:00 Matthew Broadhead
Post by Matthew Broadhead
should not be serializable?
Post by Romain Manni-Bucau
No but likely MyCustomObject is scanned and has a default constructor
Romain Manni-Bucau
@rmannibucau | Blog | Old Blog | Github | LinkedIn
2017-11-27 10:00 GMT+01:00 Matthew Broadhead
Post by Matthew Broadhead
If I include a jar in several webapps and the jar contains some
@ApplicationScoped beans it seems to work fine. i.e. those
@ApplicationScoped beans can be injected into the beans in the webapps
without conflict.
@Produces
@MyQualifier
@RequestScoped
public MyCustomObject token() {
return createMyCutomObject();
}
Then i get org.apache.openejb.cdi.OpenEJBLifecycle.startApplication CDI
Beans module deployment failed
javax.enterprise.inject.AmbiguousResolutionException: There is more than
one
Bean with type com.example.MyCustomObject
Is there a conflict between the various webapps?
Matthew Broadhead
2017-11-27 09:57:26 UTC
Permalink
should i somehow be manually defining which beans are cdi managed?
Post by Romain Manni-Bucau
all i guess,
System.out.println(beanManager.getBeans(Object.class)) should list them
Romain Manni-Bucau
@rmannibucau | Blog | Old Blog | Github | LinkedIn
yes that works. does that mean all classes are being added as cdi for some
reason? or only ones that are being produced?
Post by Romain Manni-Bucau
hmm there is not link with serializable but if it is a cdi bean then
producing it will make it ambiguous
Romain Manni-Bucau
@rmannibucau | Blog | Old Blog | Github | LinkedIn
2017-11-27 10:24 GMT+01:00 Matthew Broadhead
Post by Matthew Broadhead
should not be serializable?
Post by Romain Manni-Bucau
No but likely MyCustomObject is scanned and has a default constructor
Romain Manni-Bucau
@rmannibucau | Blog | Old Blog | Github | LinkedIn
2017-11-27 10:00 GMT+01:00 Matthew Broadhead
Post by Matthew Broadhead
If I include a jar in several webapps and the jar contains some
@ApplicationScoped beans it seems to work fine. i.e. those
@ApplicationScoped beans can be injected into the beans in the webapps
without conflict.
@Produces
@MyQualifier
@RequestScoped
public MyCustomObject token() {
return createMyCutomObject();
}
Then i get org.apache.openejb.cdi.OpenEJBLifecycle.startApplication CDI
Beans module deployment failed
javax.enterprise.inject.AmbiguousResolutionException: There is more than
one
Bean with type com.example.MyCustomObject
Is there a conflict between the various webapps?
Romain Manni-Bucau
2017-11-27 10:07:29 UTC
Permalink
No but you can tune it with beans.xml (excludes, scanning mode, etc...)

Romain Manni-Bucau
@rmannibucau | Blog | Old Blog | Github | LinkedIn
Post by Matthew Broadhead
should i somehow be manually defining which beans are cdi managed?
Post by Romain Manni-Bucau
all i guess,
System.out.println(beanManager.getBeans(Object.class)) should list them
Romain Manni-Bucau
@rmannibucau | Blog | Old Blog | Github | LinkedIn
2017-11-27 10:31 GMT+01:00 Matthew Broadhead
yes that works. does that mean all classes are being added as cdi for some
reason? or only ones that are being produced?
Post by Romain Manni-Bucau
hmm there is not link with serializable but if it is a cdi bean then
producing it will make it ambiguous
Romain Manni-Bucau
@rmannibucau | Blog | Old Blog | Github | LinkedIn
2017-11-27 10:24 GMT+01:00 Matthew Broadhead
Post by Matthew Broadhead
should not be serializable?
Post by Romain Manni-Bucau
No but likely MyCustomObject is scanned and has a default constructor
Romain Manni-Bucau
@rmannibucau | Blog | Old Blog | Github | LinkedIn
2017-11-27 10:00 GMT+01:00 Matthew Broadhead
Post by Matthew Broadhead
If I include a jar in several webapps and the jar contains some
@ApplicationScoped beans it seems to work fine. i.e. those
@ApplicationScoped beans can be injected into the beans in the webapps
without conflict.
@Produces
@MyQualifier
@RequestScoped
public MyCustomObject token() {
return createMyCutomObject();
}
Then i get org.apache.openejb.cdi.OpenEJBLifecycle.startApplication CDI
Beans module deployment failed
javax.enterprise.inject.AmbiguousResolutionException: There is more than
one
Bean with type com.example.MyCustomObject
Is there a conflict between the various webapps?
Loading...