You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by "Baker, Trevor" <cr...@mail.ubc.ca> on 2012/11/08 02:33:33 UTC

cdi-basic-arquillian

Hi,

I was trying to convert the cdi-basic example to use Arquillian. I ran into a problem because Faculty cannot be injected into Course unless Faculty is a @ManagedBean (or @Stateless). However, in the original cdi-basic example Faculty isn't a @ManagedBean and the test runs green.

Wondering if I'm missing some config or something else.

I've attached the cdi-basic-arquillian example.

Thanks,
Trev

Re: cdi-basic-arquillian

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi,

about 1 it should work, not sure what you have as issue. We have some test
checking we can use classes defined only in the war (using shrinkwrap maven)

about 2 the root url should be target/classes since the archive is not
dumped on the disk we can't use the 'standard' url. TomEE embedded adapter
is faster than tomee remote one but dump the archive on the disk so it
should maybe match your need if you rely on it.

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*




2012/11/10 Baker, Trevor <cr...@mail.ubc.ca>

> Thanks! That worked.
>
> I've hooked up Arquillian Persistence + DbUnit and have it deployed to a
> JBoss 7. I'd like to do the same with OpenEJB because deploying to a server
> is slow. I know I have an uphill battle:
> 1. Finding classes for the persistence unit
> 2. Getting the persistence unit to work with Hibernate
> 3. Hooking up Arquillian Persistence config to OpenEJB UserTransaction.
> 4. Seeing if Arquillian Persistence can be run outside of JBoss server.
>
> I came across a couple of other issues. I have a
> src/test/resources/test/dbUnit-persistence.xml which gets packaged properly
> to a JavaArchive META-INF/persistence.xml. I notice that the
> PersistenceUnitInfo's root url is
> file:/..../target/test-classes/test/persistence.xml. Two things here:
> 1. all my code is coming from the underlying file:/.../target/classes ...
> but in theory the classes could be found on a mixture of class loaders
> 2. the persistence unit root url shouldn't point to the persistence.xml.
> It should be the root of the persistence unit (JavaArchive: / ; WebArchive:
> /WEB-INF/classes).
>
> Let me know if you want a simple example. The code I'm working with is
> specific to my company, so I'll need to spend time creating a sample.
>
> Much appreciated,
> Trev
>
> -----Original Message-----
> From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
> Sent: Friday, November 09, 2012 7:52 AM
> To: OpenEJB Users
> Subject: Re: cdi-basic-arquillian
>
> right should be fixed on trunk (just fixed)
>
> *Romain Manni-Bucau*
> *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> *Blog: **http://rmannibucau.wordpress.com/*<
> http://rmannibucau.wordpress.com/>
> *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> *Github: https://github.com/rmannibucau*
>
>
>
>
> 2012/11/9 Baker, Trevor <cr...@mail.ubc.ca>
>
> > Ah. Yes. Thanks. I knew I was missing something.
> >
> > I did change it up from a JavaArchive to a WebArchive. The CDI
> > injection works when the beans.xml exists as WEB-INF/beans.xml but
> > does not as WEB-INF/classes/META-INF/beans.xml.
> >
> > Trev
> >
> > -----Original Message-----
> > From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
> > Sent: Wednesday, November 07, 2012 11:18 PM
> > To: OpenEJB Users
> > Subject: Re: cdi-basic-arquillian
> >
> > Hi,
> >
> > yeah, you forgot the little "active me cdi please" detail:
> > META-INF/beans.xml. That's why you don't get any managed bean.
> >
> > Not sure you are familiar with arquillian so saying it: it is done
> > using addAsManifestResource(EmptyAsset.INSTANCE,
> > ArchivePaths.create("beans.xml"))
> >
> > *Romain Manni-Bucau*
> > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > *Blog: **http://rmannibucau.wordpress.com/*<
> > http://rmannibucau.wordpress.com/>
> > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > *Github: https://github.com/rmannibucau*
> >
> >
> >
> >
> > 2012/11/8 Baker, Trevor <cr...@mail.ubc.ca>
> >
> > >  Hi,****
> > >
> > > ** **
> > >
> > > I was trying to convert the cdi-basic example to use Arquillian. I
> > > ran into a problem because Faculty cannot be injected into Course
> > > unless Faculty is a @ManagedBean (or @Stateless). However, in the
> > > original cdi-basic example Faculty isn't a @ManagedBean and the test
> > > runs
> > > green.***
> > > *
> > >
> > > ** **
> > >
> > > Wondering if I'm missing some config or something else.****
> > >
> > > ** **
> > >
> > > I've attached the cdi-basic-arquillian example.****
> > >
> > > ** **
> > >
> > > Thanks,****
> > >
> > > Trev****
> > >
> >
>

RE: cdi-basic-arquillian

Posted by "Baker, Trevor" <cr...@mail.ubc.ca>.
Thanks! That worked.

I've hooked up Arquillian Persistence + DbUnit and have it deployed to a JBoss 7. I'd like to do the same with OpenEJB because deploying to a server is slow. I know I have an uphill battle:
1. Finding classes for the persistence unit
2. Getting the persistence unit to work with Hibernate
3. Hooking up Arquillian Persistence config to OpenEJB UserTransaction.
4. Seeing if Arquillian Persistence can be run outside of JBoss server.

I came across a couple of other issues. I have a src/test/resources/test/dbUnit-persistence.xml which gets packaged properly to a JavaArchive META-INF/persistence.xml. I notice that the PersistenceUnitInfo's root url is file:/..../target/test-classes/test/persistence.xml. Two things here:
1. all my code is coming from the underlying file:/.../target/classes ... but in theory the classes could be found on a mixture of class loaders
2. the persistence unit root url shouldn't point to the persistence.xml. It should be the root of the persistence unit (JavaArchive: / ; WebArchive: /WEB-INF/classes).

Let me know if you want a simple example. The code I'm working with is specific to my company, so I'll need to spend time creating a sample.

Much appreciated,
Trev

-----Original Message-----
From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com] 
Sent: Friday, November 09, 2012 7:52 AM
To: OpenEJB Users
Subject: Re: cdi-basic-arquillian

right should be fixed on trunk (just fixed)

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*




2012/11/9 Baker, Trevor <cr...@mail.ubc.ca>

> Ah. Yes. Thanks. I knew I was missing something.
>
> I did change it up from a JavaArchive to a WebArchive. The CDI 
> injection works when the beans.xml exists as WEB-INF/beans.xml but 
> does not as WEB-INF/classes/META-INF/beans.xml.
>
> Trev
>
> -----Original Message-----
> From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
> Sent: Wednesday, November 07, 2012 11:18 PM
> To: OpenEJB Users
> Subject: Re: cdi-basic-arquillian
>
> Hi,
>
> yeah, you forgot the little "active me cdi please" detail:
> META-INF/beans.xml. That's why you don't get any managed bean.
>
> Not sure you are familiar with arquillian so saying it: it is done 
> using addAsManifestResource(EmptyAsset.INSTANCE, 
> ArchivePaths.create("beans.xml"))
>
> *Romain Manni-Bucau*
> *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> *Blog: **http://rmannibucau.wordpress.com/*<
> http://rmannibucau.wordpress.com/>
> *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> *Github: https://github.com/rmannibucau*
>
>
>
>
> 2012/11/8 Baker, Trevor <cr...@mail.ubc.ca>
>
> >  Hi,****
> >
> > ** **
> >
> > I was trying to convert the cdi-basic example to use Arquillian. I 
> > ran into a problem because Faculty cannot be injected into Course 
> > unless Faculty is a @ManagedBean (or @Stateless). However, in the 
> > original cdi-basic example Faculty isn't a @ManagedBean and the test 
> > runs
> > green.***
> > *
> >
> > ** **
> >
> > Wondering if I'm missing some config or something else.****
> >
> > ** **
> >
> > I've attached the cdi-basic-arquillian example.****
> >
> > ** **
> >
> > Thanks,****
> >
> > Trev****
> >
>

Re: cdi-basic-arquillian

Posted by Romain Manni-Bucau <rm...@gmail.com>.
right should be fixed on trunk (just fixed)

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*




2012/11/9 Baker, Trevor <cr...@mail.ubc.ca>

> Ah. Yes. Thanks. I knew I was missing something.
>
> I did change it up from a JavaArchive to a WebArchive. The CDI injection
> works when the beans.xml exists as WEB-INF/beans.xml but does not as
> WEB-INF/classes/META-INF/beans.xml.
>
> Trev
>
> -----Original Message-----
> From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
> Sent: Wednesday, November 07, 2012 11:18 PM
> To: OpenEJB Users
> Subject: Re: cdi-basic-arquillian
>
> Hi,
>
> yeah, you forgot the little "active me cdi please" detail:
> META-INF/beans.xml. That's why you don't get any managed bean.
>
> Not sure you are familiar with arquillian so saying it: it is done using
> addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
>
> *Romain Manni-Bucau*
> *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> *Blog: **http://rmannibucau.wordpress.com/*<
> http://rmannibucau.wordpress.com/>
> *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> *Github: https://github.com/rmannibucau*
>
>
>
>
> 2012/11/8 Baker, Trevor <cr...@mail.ubc.ca>
>
> >  Hi,****
> >
> > ** **
> >
> > I was trying to convert the cdi-basic example to use Arquillian. I ran
> > into a problem because Faculty cannot be injected into Course unless
> > Faculty is a @ManagedBean (or @Stateless). However, in the original
> > cdi-basic example Faculty isn't a @ManagedBean and the test runs
> > green.***
> > *
> >
> > ** **
> >
> > Wondering if I'm missing some config or something else.****
> >
> > ** **
> >
> > I've attached the cdi-basic-arquillian example.****
> >
> > ** **
> >
> > Thanks,****
> >
> > Trev****
> >
>

RE: cdi-basic-arquillian

Posted by "Baker, Trevor" <cr...@mail.ubc.ca>.
Ah. Yes. Thanks. I knew I was missing something.

I did change it up from a JavaArchive to a WebArchive. The CDI injection works when the beans.xml exists as WEB-INF/beans.xml but does not as WEB-INF/classes/META-INF/beans.xml. 

Trev

-----Original Message-----
From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com] 
Sent: Wednesday, November 07, 2012 11:18 PM
To: OpenEJB Users
Subject: Re: cdi-basic-arquillian

Hi,

yeah, you forgot the little "active me cdi please" detail:
META-INF/beans.xml. That's why you don't get any managed bean.

Not sure you are familiar with arquillian so saying it: it is done using addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*




2012/11/8 Baker, Trevor <cr...@mail.ubc.ca>

>  Hi,****
>
> ** **
>
> I was trying to convert the cdi-basic example to use Arquillian. I ran 
> into a problem because Faculty cannot be injected into Course unless 
> Faculty is a @ManagedBean (or @Stateless). However, in the original 
> cdi-basic example Faculty isn't a @ManagedBean and the test runs 
> green.***
> *
>
> ** **
>
> Wondering if I'm missing some config or something else.****
>
> ** **
>
> I've attached the cdi-basic-arquillian example.****
>
> ** **
>
> Thanks,****
>
> Trev****
>

Re: cdi-basic-arquillian

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi,

yeah, you forgot the little "active me cdi please" detail:
META-INF/beans.xml. That's why you don't get any managed bean.

Not sure you are familiar with arquillian so saying it: it is done using
addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*




2012/11/8 Baker, Trevor <cr...@mail.ubc.ca>

>  Hi,****
>
> ** **
>
> I was trying to convert the cdi-basic example to use Arquillian. I ran
> into a problem because Faculty cannot be injected into Course unless
> Faculty is a @ManagedBean (or @Stateless). However, in the original
> cdi-basic example Faculty isn’t a @ManagedBean and the test runs green.***
> *
>
> ** **
>
> Wondering if I’m missing some config or something else.****
>
> ** **
>
> I’ve attached the cdi-basic-arquillian example.****
>
> ** **
>
> Thanks,****
>
> Trev****
>