You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by "John D. Ament" <jo...@apache.org> on 2017/12/18 02:47:53 UTC

Injecting Array types as fields

MP Config is adding arrays as a valid type for config properties.  In doing
so, without making any changes to Geronimo Config I get this failure (not
what I'm expecting, I'm expecting no valid beans at this point):

arquillianBeforeClass(org.eclipse.microprofile.config.tck.ClassConverterTest)
Time elapsed: 0.022 sec  <<< FAILURE!
org.apache.webbeans.exception.WebBeansConfigurationException:
java.lang.IllegalArgumentException: Can't determine the type for Class<?
extends Object>[]
at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:351)
at
org.apache.webbeans.lifecycle.AbstractLifeCycle.bootstrapApplication(AbstractLifeCycle.java:137)
at
org.apache.webbeans.lifecycle.AbstractLifeCycle.startApplication(AbstractLifeCycle.java:103)
at
org.apache.webbeans.arquillian.standalone.OwbStandaloneContainer.deploy(OwbStandaloneContainer.java:118)
at
org.jboss.arquillian.container.impl.client.container.ContainerDeployController$3.call(ContainerDeployController.java:161)
at
org.jboss.arquillian.container.impl.client.container.ContainerDeployController$3.call(ContainerDeployController.java:128)
at
org.jboss.arquillian.container.impl.client.container.ContainerDeployController.executeOperation(ContainerDeployController.java:271)
at
org.jboss.arquillian.container.impl.client.container.ContainerDeployController.deploy(ContainerDeployController.java:127)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)

It seems that OWB can't handle array types as fields for injection.  Is
this in fact expected?  This is even though for any given class T,
T[].class is a valid object.

Re: Injecting Array types as fields

Posted by Romain Manni-Bucau <rm...@gmail.com>.
if you call get() can be yes. Happy to help if you can sort out a test like
the one i sent.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau>

2017-12-18 15:18 GMT+01:00 John D. Ament <jo...@apache.org>:

> We register a single bean per injection point.  That bean handles the look
> up but only returns the type of the injection point.  But its still a bit
> odd.
>
> I added CDI.current().select(int[].class, new ConfigProperty...) to my
> test
> to see what happens.  In Weld, I see it call the producer but fail (because
> of missing annotations).  In OWB, it doesn't call the bean's create method
> at all.  Which makes me think its an OWB issue.  I'll see if I can come up
> with a local test case.
>
> John
>
> On Mon, Dec 18, 2017 at 8:50 AM Romain Manni-Bucau <rm...@gmail.com>
> wrote:
>
> > Isn't it cause we reuse a generic producer?
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <https://rmannibucau.metawerx.net/> | Old Blog
> > <http://rmannibucau.wordpress.com> | Github <
> > https://github.com/rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau>
> >
> > 2017-12-18 13:01 GMT+01:00 John D. Ament <jo...@apache.org>:
> >
> > > That's good that this works. However, I wonder if my issue is specific
> to
> > > 3rd Party Bean creation?  Same problem seems to be on both OWB and
> Weld,
> > > which makes me think it's an impl issue, but I can't think of anything
> > else
> > > required on the impl side.
> > >
> > > Bean.getTypes() correctly returns String[].class
> > > qualifiers are correct
> > >
> > > The create method on the bean is never invoked, the injection point is
> > > always null.
> > >
> > > John
> > >
> > > On Mon, Dec 18, 2017 at 3:59 AM Romain Manni-Bucau <
> > rmannibucau@gmail.com>
> > > wrote:
> > >
> > > > Works for me:
> > > >
> > > > public class ArrayProducerTest extends AbstractUnitTest
> > > > {
> > > >
> > > >     @Test
> > > >     public void test()
> > > >     {
> > > >         startContainer(StringProducer.class);
> > > >
> > > >         final String[] produced1 = getInstance(String[].class);
> > > >         final StringProducer[] produced2 =
> > > > getInstance(StringProducer[].class);
> > > >
> > > >         Assert.assertEquals(1, produced1.length);
> > > >         Assert.assertEquals("string", produced1[0]);
> > > >
> > > >         Assert.assertEquals(1, produced2.length);
> > > >         Assert.assertNotNull(produced2[0]);
> > > >
> > > >         shutDownContainer();
> > > >
> > > >     }
> > > >
> > > >     public static class StringProducer
> > > >     {
> > > >         @Produces
> > > >         public String[] produces()
> > > >         {
> > > >             return new String[] { "string" };
> > > >         }
> > > >
> > > >         @Produces
> > > >         public StringProducer[] produces2()
> > > >         {
> > > >             return new StringProducer[] { this };
> > > >         }
> > > >     }
> > > >
> > > > }
> > > >
> > > >
> > > >
> > > > Romain Manni-Bucau
> > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > <https://rmannibucau.metawerx.net/> | Old Blog
> > > > <http://rmannibucau.wordpress.com> | Github <
> > > > https://github.com/rmannibucau> |
> > > > LinkedIn <https://www.linkedin.com/in/rmannibucau>
> > > >
> > > > 2017-12-18 9:15 GMT+01:00 Mark Struberg <st...@yahoo.de.invalid>:
> > > >
> > > > > I think it should work.
> > > > >
> > > > > Could you please create a ticket?
> > > > >
> > > > > txs and LieGrue,
> > > > > strub
> > > > >
> > > > >
> > > > > > Am 18.12.2017 um 03:47 schrieb John D. Ament <
> > johndament@apache.org
> > > >:
> > > > > >
> > > > > > MP Config is adding arrays as a valid type for config properties.
> > In
> > > > > doing
> > > > > > so, without making any changes to Geronimo Config I get this
> > failure
> > > > (not
> > > > > > what I'm expecting, I'm expecting no valid beans at this point):
> > > > > >
> > > > > > arquillianBeforeClass(org.eclipse.microprofile.config.
> > > > > tck.ClassConverterTest)
> > > > > > Time elapsed: 0.022 sec  <<< FAILURE!
> > > > > > org.apache.webbeans.exception.WebBeansConfigurationException:
> > > > > > java.lang.IllegalArgumentException: Can't determine the type for
> > > > Class<?
> > > > > > extends Object>[]
> > > > > > at org.apache.webbeans.config.BeansDeployer.deploy(
> > > > > BeansDeployer.java:351)
> > > > > > at
> > > > > > org.apache.webbeans.lifecycle.AbstractLifeCycle.
> > > bootstrapApplication(
> > > > > AbstractLifeCycle.java:137)
> > > > > > at
> > > > > > org.apache.webbeans.lifecycle.AbstractLifeCycle.
> startApplication(
> > > > > AbstractLifeCycle.java:103)
> > > > > > at
> > > > > >
> > > >
> > org.apache.webbeans.arquillian.standalone.OwbStandaloneContainer.deploy(
> > > > > OwbStandaloneContainer.java:118)
> > > > > > at
> > > > > > org.jboss.arquillian.container.impl.client.container.
> > > > > ContainerDeployController$3.call(ContainerDeployController.
> java:161)
> > > > > > at
> > > > > > org.jboss.arquillian.container.impl.client.container.
> > > > > ContainerDeployController$3.call(ContainerDeployController.
> java:128)
> > > > > > at
> > > > > > org.jboss.arquillian.container.impl.client.container.
> > > > > ContainerDeployController.executeOperation(
> ContainerDeployController.
> > > > > java:271)
> > > > > > at
> > > > > > org.jboss.arquillian.container.impl.client.container.
> > > > > ContainerDeployController.deploy(ContainerDeployController.
> java:127)
> > > > > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > > > > > at
> > > > > > sun.reflect.NativeMethodAccessorImpl.invoke(
> > > > > NativeMethodAccessorImpl.java:62)
> > > > > > at
> > > > > > sun.reflect.DelegatingMethodAccessorImpl.invoke(
> > > > > DelegatingMethodAccessorImpl.java:43)
> > > > > > at java.lang.reflect.Method.invoke(Method.java:498)
> > > > > >
> > > > > > It seems that OWB can't handle array types as fields for
> injection.
> > > Is
> > > > > > this in fact expected?  This is even though for any given class
> T,
> > > > > > T[].class is a valid object.
> > > > >
> > > > >
> > > >
> > >
> >
>

Re: Injecting Array types as fields

Posted by "John D. Ament" <jo...@apache.org>.
We register a single bean per injection point.  That bean handles the look
up but only returns the type of the injection point.  But its still a bit
odd.

I added CDI.current().select(int[].class, new ConfigProperty...) to my test
to see what happens.  In Weld, I see it call the producer but fail (because
of missing annotations).  In OWB, it doesn't call the bean's create method
at all.  Which makes me think its an OWB issue.  I'll see if I can come up
with a local test case.

John

On Mon, Dec 18, 2017 at 8:50 AM Romain Manni-Bucau <rm...@gmail.com>
wrote:

> Isn't it cause we reuse a generic producer?
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <https://rmannibucau.metawerx.net/> | Old Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau>
>
> 2017-12-18 13:01 GMT+01:00 John D. Ament <jo...@apache.org>:
>
> > That's good that this works. However, I wonder if my issue is specific to
> > 3rd Party Bean creation?  Same problem seems to be on both OWB and Weld,
> > which makes me think it's an impl issue, but I can't think of anything
> else
> > required on the impl side.
> >
> > Bean.getTypes() correctly returns String[].class
> > qualifiers are correct
> >
> > The create method on the bean is never invoked, the injection point is
> > always null.
> >
> > John
> >
> > On Mon, Dec 18, 2017 at 3:59 AM Romain Manni-Bucau <
> rmannibucau@gmail.com>
> > wrote:
> >
> > > Works for me:
> > >
> > > public class ArrayProducerTest extends AbstractUnitTest
> > > {
> > >
> > >     @Test
> > >     public void test()
> > >     {
> > >         startContainer(StringProducer.class);
> > >
> > >         final String[] produced1 = getInstance(String[].class);
> > >         final StringProducer[] produced2 =
> > > getInstance(StringProducer[].class);
> > >
> > >         Assert.assertEquals(1, produced1.length);
> > >         Assert.assertEquals("string", produced1[0]);
> > >
> > >         Assert.assertEquals(1, produced2.length);
> > >         Assert.assertNotNull(produced2[0]);
> > >
> > >         shutDownContainer();
> > >
> > >     }
> > >
> > >     public static class StringProducer
> > >     {
> > >         @Produces
> > >         public String[] produces()
> > >         {
> > >             return new String[] { "string" };
> > >         }
> > >
> > >         @Produces
> > >         public StringProducer[] produces2()
> > >         {
> > >             return new StringProducer[] { this };
> > >         }
> > >     }
> > >
> > > }
> > >
> > >
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > <https://rmannibucau.metawerx.net/> | Old Blog
> > > <http://rmannibucau.wordpress.com> | Github <
> > > https://github.com/rmannibucau> |
> > > LinkedIn <https://www.linkedin.com/in/rmannibucau>
> > >
> > > 2017-12-18 9:15 GMT+01:00 Mark Struberg <st...@yahoo.de.invalid>:
> > >
> > > > I think it should work.
> > > >
> > > > Could you please create a ticket?
> > > >
> > > > txs and LieGrue,
> > > > strub
> > > >
> > > >
> > > > > Am 18.12.2017 um 03:47 schrieb John D. Ament <
> johndament@apache.org
> > >:
> > > > >
> > > > > MP Config is adding arrays as a valid type for config properties.
> In
> > > > doing
> > > > > so, without making any changes to Geronimo Config I get this
> failure
> > > (not
> > > > > what I'm expecting, I'm expecting no valid beans at this point):
> > > > >
> > > > > arquillianBeforeClass(org.eclipse.microprofile.config.
> > > > tck.ClassConverterTest)
> > > > > Time elapsed: 0.022 sec  <<< FAILURE!
> > > > > org.apache.webbeans.exception.WebBeansConfigurationException:
> > > > > java.lang.IllegalArgumentException: Can't determine the type for
> > > Class<?
> > > > > extends Object>[]
> > > > > at org.apache.webbeans.config.BeansDeployer.deploy(
> > > > BeansDeployer.java:351)
> > > > > at
> > > > > org.apache.webbeans.lifecycle.AbstractLifeCycle.
> > bootstrapApplication(
> > > > AbstractLifeCycle.java:137)
> > > > > at
> > > > > org.apache.webbeans.lifecycle.AbstractLifeCycle.startApplication(
> > > > AbstractLifeCycle.java:103)
> > > > > at
> > > > >
> > >
> org.apache.webbeans.arquillian.standalone.OwbStandaloneContainer.deploy(
> > > > OwbStandaloneContainer.java:118)
> > > > > at
> > > > > org.jboss.arquillian.container.impl.client.container.
> > > > ContainerDeployController$3.call(ContainerDeployController.java:161)
> > > > > at
> > > > > org.jboss.arquillian.container.impl.client.container.
> > > > ContainerDeployController$3.call(ContainerDeployController.java:128)
> > > > > at
> > > > > org.jboss.arquillian.container.impl.client.container.
> > > > ContainerDeployController.executeOperation(ContainerDeployController.
> > > > java:271)
> > > > > at
> > > > > org.jboss.arquillian.container.impl.client.container.
> > > > ContainerDeployController.deploy(ContainerDeployController.java:127)
> > > > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > > > > at
> > > > > sun.reflect.NativeMethodAccessorImpl.invoke(
> > > > NativeMethodAccessorImpl.java:62)
> > > > > at
> > > > > sun.reflect.DelegatingMethodAccessorImpl.invoke(
> > > > DelegatingMethodAccessorImpl.java:43)
> > > > > at java.lang.reflect.Method.invoke(Method.java:498)
> > > > >
> > > > > It seems that OWB can't handle array types as fields for injection.
> > Is
> > > > > this in fact expected?  This is even though for any given class T,
> > > > > T[].class is a valid object.
> > > >
> > > >
> > >
> >
>

Re: Injecting Array types as fields

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Isn't it cause we reuse a generic producer?


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau>

2017-12-18 13:01 GMT+01:00 John D. Ament <jo...@apache.org>:

> That's good that this works. However, I wonder if my issue is specific to
> 3rd Party Bean creation?  Same problem seems to be on both OWB and Weld,
> which makes me think it's an impl issue, but I can't think of anything else
> required on the impl side.
>
> Bean.getTypes() correctly returns String[].class
> qualifiers are correct
>
> The create method on the bean is never invoked, the injection point is
> always null.
>
> John
>
> On Mon, Dec 18, 2017 at 3:59 AM Romain Manni-Bucau <rm...@gmail.com>
> wrote:
>
> > Works for me:
> >
> > public class ArrayProducerTest extends AbstractUnitTest
> > {
> >
> >     @Test
> >     public void test()
> >     {
> >         startContainer(StringProducer.class);
> >
> >         final String[] produced1 = getInstance(String[].class);
> >         final StringProducer[] produced2 =
> > getInstance(StringProducer[].class);
> >
> >         Assert.assertEquals(1, produced1.length);
> >         Assert.assertEquals("string", produced1[0]);
> >
> >         Assert.assertEquals(1, produced2.length);
> >         Assert.assertNotNull(produced2[0]);
> >
> >         shutDownContainer();
> >
> >     }
> >
> >     public static class StringProducer
> >     {
> >         @Produces
> >         public String[] produces()
> >         {
> >             return new String[] { "string" };
> >         }
> >
> >         @Produces
> >         public StringProducer[] produces2()
> >         {
> >             return new StringProducer[] { this };
> >         }
> >     }
> >
> > }
> >
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <https://rmannibucau.metawerx.net/> | Old Blog
> > <http://rmannibucau.wordpress.com> | Github <
> > https://github.com/rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau>
> >
> > 2017-12-18 9:15 GMT+01:00 Mark Struberg <st...@yahoo.de.invalid>:
> >
> > > I think it should work.
> > >
> > > Could you please create a ticket?
> > >
> > > txs and LieGrue,
> > > strub
> > >
> > >
> > > > Am 18.12.2017 um 03:47 schrieb John D. Ament <johndament@apache.org
> >:
> > > >
> > > > MP Config is adding arrays as a valid type for config properties.  In
> > > doing
> > > > so, without making any changes to Geronimo Config I get this failure
> > (not
> > > > what I'm expecting, I'm expecting no valid beans at this point):
> > > >
> > > > arquillianBeforeClass(org.eclipse.microprofile.config.
> > > tck.ClassConverterTest)
> > > > Time elapsed: 0.022 sec  <<< FAILURE!
> > > > org.apache.webbeans.exception.WebBeansConfigurationException:
> > > > java.lang.IllegalArgumentException: Can't determine the type for
> > Class<?
> > > > extends Object>[]
> > > > at org.apache.webbeans.config.BeansDeployer.deploy(
> > > BeansDeployer.java:351)
> > > > at
> > > > org.apache.webbeans.lifecycle.AbstractLifeCycle.
> bootstrapApplication(
> > > AbstractLifeCycle.java:137)
> > > > at
> > > > org.apache.webbeans.lifecycle.AbstractLifeCycle.startApplication(
> > > AbstractLifeCycle.java:103)
> > > > at
> > > >
> > org.apache.webbeans.arquillian.standalone.OwbStandaloneContainer.deploy(
> > > OwbStandaloneContainer.java:118)
> > > > at
> > > > org.jboss.arquillian.container.impl.client.container.
> > > ContainerDeployController$3.call(ContainerDeployController.java:161)
> > > > at
> > > > org.jboss.arquillian.container.impl.client.container.
> > > ContainerDeployController$3.call(ContainerDeployController.java:128)
> > > > at
> > > > org.jboss.arquillian.container.impl.client.container.
> > > ContainerDeployController.executeOperation(ContainerDeployController.
> > > java:271)
> > > > at
> > > > org.jboss.arquillian.container.impl.client.container.
> > > ContainerDeployController.deploy(ContainerDeployController.java:127)
> > > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > > > at
> > > > sun.reflect.NativeMethodAccessorImpl.invoke(
> > > NativeMethodAccessorImpl.java:62)
> > > > at
> > > > sun.reflect.DelegatingMethodAccessorImpl.invoke(
> > > DelegatingMethodAccessorImpl.java:43)
> > > > at java.lang.reflect.Method.invoke(Method.java:498)
> > > >
> > > > It seems that OWB can't handle array types as fields for injection.
> Is
> > > > this in fact expected?  This is even though for any given class T,
> > > > T[].class is a valid object.
> > >
> > >
> >
>

Re: Injecting Array types as fields

Posted by "John D. Ament" <jo...@apache.org>.
That's good that this works. However, I wonder if my issue is specific to
3rd Party Bean creation?  Same problem seems to be on both OWB and Weld,
which makes me think it's an impl issue, but I can't think of anything else
required on the impl side.

Bean.getTypes() correctly returns String[].class
qualifiers are correct

The create method on the bean is never invoked, the injection point is
always null.

John

On Mon, Dec 18, 2017 at 3:59 AM Romain Manni-Bucau <rm...@gmail.com>
wrote:

> Works for me:
>
> public class ArrayProducerTest extends AbstractUnitTest
> {
>
>     @Test
>     public void test()
>     {
>         startContainer(StringProducer.class);
>
>         final String[] produced1 = getInstance(String[].class);
>         final StringProducer[] produced2 =
> getInstance(StringProducer[].class);
>
>         Assert.assertEquals(1, produced1.length);
>         Assert.assertEquals("string", produced1[0]);
>
>         Assert.assertEquals(1, produced2.length);
>         Assert.assertNotNull(produced2[0]);
>
>         shutDownContainer();
>
>     }
>
>     public static class StringProducer
>     {
>         @Produces
>         public String[] produces()
>         {
>             return new String[] { "string" };
>         }
>
>         @Produces
>         public StringProducer[] produces2()
>         {
>             return new StringProducer[] { this };
>         }
>     }
>
> }
>
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <https://rmannibucau.metawerx.net/> | Old Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau>
>
> 2017-12-18 9:15 GMT+01:00 Mark Struberg <st...@yahoo.de.invalid>:
>
> > I think it should work.
> >
> > Could you please create a ticket?
> >
> > txs and LieGrue,
> > strub
> >
> >
> > > Am 18.12.2017 um 03:47 schrieb John D. Ament <jo...@apache.org>:
> > >
> > > MP Config is adding arrays as a valid type for config properties.  In
> > doing
> > > so, without making any changes to Geronimo Config I get this failure
> (not
> > > what I'm expecting, I'm expecting no valid beans at this point):
> > >
> > > arquillianBeforeClass(org.eclipse.microprofile.config.
> > tck.ClassConverterTest)
> > > Time elapsed: 0.022 sec  <<< FAILURE!
> > > org.apache.webbeans.exception.WebBeansConfigurationException:
> > > java.lang.IllegalArgumentException: Can't determine the type for
> Class<?
> > > extends Object>[]
> > > at org.apache.webbeans.config.BeansDeployer.deploy(
> > BeansDeployer.java:351)
> > > at
> > > org.apache.webbeans.lifecycle.AbstractLifeCycle.bootstrapApplication(
> > AbstractLifeCycle.java:137)
> > > at
> > > org.apache.webbeans.lifecycle.AbstractLifeCycle.startApplication(
> > AbstractLifeCycle.java:103)
> > > at
> > >
> org.apache.webbeans.arquillian.standalone.OwbStandaloneContainer.deploy(
> > OwbStandaloneContainer.java:118)
> > > at
> > > org.jboss.arquillian.container.impl.client.container.
> > ContainerDeployController$3.call(ContainerDeployController.java:161)
> > > at
> > > org.jboss.arquillian.container.impl.client.container.
> > ContainerDeployController$3.call(ContainerDeployController.java:128)
> > > at
> > > org.jboss.arquillian.container.impl.client.container.
> > ContainerDeployController.executeOperation(ContainerDeployController.
> > java:271)
> > > at
> > > org.jboss.arquillian.container.impl.client.container.
> > ContainerDeployController.deploy(ContainerDeployController.java:127)
> > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > > at
> > > sun.reflect.NativeMethodAccessorImpl.invoke(
> > NativeMethodAccessorImpl.java:62)
> > > at
> > > sun.reflect.DelegatingMethodAccessorImpl.invoke(
> > DelegatingMethodAccessorImpl.java:43)
> > > at java.lang.reflect.Method.invoke(Method.java:498)
> > >
> > > It seems that OWB can't handle array types as fields for injection.  Is
> > > this in fact expected?  This is even though for any given class T,
> > > T[].class is a valid object.
> >
> >
>

Re: Injecting Array types as fields

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Works for me:

public class ArrayProducerTest extends AbstractUnitTest
{

    @Test
    public void test()
    {
        startContainer(StringProducer.class);

        final String[] produced1 = getInstance(String[].class);
        final StringProducer[] produced2 = getInstance(StringProducer[].class);

        Assert.assertEquals(1, produced1.length);
        Assert.assertEquals("string", produced1[0]);

        Assert.assertEquals(1, produced2.length);
        Assert.assertNotNull(produced2[0]);

        shutDownContainer();

    }

    public static class StringProducer
    {
        @Produces
        public String[] produces()
        {
            return new String[] { "string" };
        }

        @Produces
        public StringProducer[] produces2()
        {
            return new StringProducer[] { this };
        }
    }

}



Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau>

2017-12-18 9:15 GMT+01:00 Mark Struberg <st...@yahoo.de.invalid>:

> I think it should work.
>
> Could you please create a ticket?
>
> txs and LieGrue,
> strub
>
>
> > Am 18.12.2017 um 03:47 schrieb John D. Ament <jo...@apache.org>:
> >
> > MP Config is adding arrays as a valid type for config properties.  In
> doing
> > so, without making any changes to Geronimo Config I get this failure (not
> > what I'm expecting, I'm expecting no valid beans at this point):
> >
> > arquillianBeforeClass(org.eclipse.microprofile.config.
> tck.ClassConverterTest)
> > Time elapsed: 0.022 sec  <<< FAILURE!
> > org.apache.webbeans.exception.WebBeansConfigurationException:
> > java.lang.IllegalArgumentException: Can't determine the type for Class<?
> > extends Object>[]
> > at org.apache.webbeans.config.BeansDeployer.deploy(
> BeansDeployer.java:351)
> > at
> > org.apache.webbeans.lifecycle.AbstractLifeCycle.bootstrapApplication(
> AbstractLifeCycle.java:137)
> > at
> > org.apache.webbeans.lifecycle.AbstractLifeCycle.startApplication(
> AbstractLifeCycle.java:103)
> > at
> > org.apache.webbeans.arquillian.standalone.OwbStandaloneContainer.deploy(
> OwbStandaloneContainer.java:118)
> > at
> > org.jboss.arquillian.container.impl.client.container.
> ContainerDeployController$3.call(ContainerDeployController.java:161)
> > at
> > org.jboss.arquillian.container.impl.client.container.
> ContainerDeployController$3.call(ContainerDeployController.java:128)
> > at
> > org.jboss.arquillian.container.impl.client.container.
> ContainerDeployController.executeOperation(ContainerDeployController.
> java:271)
> > at
> > org.jboss.arquillian.container.impl.client.container.
> ContainerDeployController.deploy(ContainerDeployController.java:127)
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > at
> > sun.reflect.NativeMethodAccessorImpl.invoke(
> NativeMethodAccessorImpl.java:62)
> > at
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:43)
> > at java.lang.reflect.Method.invoke(Method.java:498)
> >
> > It seems that OWB can't handle array types as fields for injection.  Is
> > this in fact expected?  This is even though for any given class T,
> > T[].class is a valid object.
>
>

Re: Injecting Array types as fields

Posted by Mark Struberg <st...@yahoo.de.INVALID>.
I think it should work.

Could you please create a ticket?

txs and LieGrue,
strub


> Am 18.12.2017 um 03:47 schrieb John D. Ament <jo...@apache.org>:
> 
> MP Config is adding arrays as a valid type for config properties.  In doing
> so, without making any changes to Geronimo Config I get this failure (not
> what I'm expecting, I'm expecting no valid beans at this point):
> 
> arquillianBeforeClass(org.eclipse.microprofile.config.tck.ClassConverterTest)
> Time elapsed: 0.022 sec  <<< FAILURE!
> org.apache.webbeans.exception.WebBeansConfigurationException:
> java.lang.IllegalArgumentException: Can't determine the type for Class<?
> extends Object>[]
> at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:351)
> at
> org.apache.webbeans.lifecycle.AbstractLifeCycle.bootstrapApplication(AbstractLifeCycle.java:137)
> at
> org.apache.webbeans.lifecycle.AbstractLifeCycle.startApplication(AbstractLifeCycle.java:103)
> at
> org.apache.webbeans.arquillian.standalone.OwbStandaloneContainer.deploy(OwbStandaloneContainer.java:118)
> at
> org.jboss.arquillian.container.impl.client.container.ContainerDeployController$3.call(ContainerDeployController.java:161)
> at
> org.jboss.arquillian.container.impl.client.container.ContainerDeployController$3.call(ContainerDeployController.java:128)
> at
> org.jboss.arquillian.container.impl.client.container.ContainerDeployController.executeOperation(ContainerDeployController.java:271)
> at
> org.jboss.arquillian.container.impl.client.container.ContainerDeployController.deploy(ContainerDeployController.java:127)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> 
> It seems that OWB can't handle array types as fields for injection.  Is
> this in fact expected?  This is even though for any given class T,
> T[].class is a valid object.