Re: Tomcat - Injection: No such property

2008-04-02 Thread ebaxt

Thank you Kenneth!

I have tried to set the properties you talked about, but I don't really know
how to configure it to lookup Tomcat's JNDI context.

I have tried this with no luck:

Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");
p.put(Context.URL_PKG_PREFIXES, "org.apache.naming.factory.XXX");

Do you know how to configure this correctly?

Erik


klewelling wrote:
> 
> FYI I got the injection to work. When I was putting together a
> demonstration the injection started working. The problem has to do with
> dependencies in the pom.xml. I am not sure if there was something extra
> causing the problem or perhaps the order of the jars in the classpath. I
> am uploading an example
> 
>  http://www.nabble.com/file/p16421933/injection-example.zip
> injection-example.zip 
> 
> By the way this example demonstrations embedding openEJB in Jetty. The
> important piece of the puzzle is in the WAR/pom.xml:
> 
> 
> org.mortbay.jetty
>   maven-jetty-plugin
>   
>   5
>   /example
>   
>   
>   java.naming.factory.initial
>   
> org.apache.openejb.client.LocalInitialContextFactory
>   
>   
>   java.naming.factory.url.pkgs
>   org.mortbay.naming
>   
>   
>   
>   
>   
> 
> 
> 
> The system property "java.naming.factory.url.pkgs" is the key. From what I
> can tell openEJB's IvmContext will attempt to do JNDI lookups and if it
> fails will look for additional ObjectFactories and delegate to them. By
> adding the "org.morbay.naming" system property IvmContext finds the Jetty
> JNDI context. Without this setting the jetty plugin will fail with the
> error: "javax.naming.NameNotFoundException: Name "java:comp" not found."
> 
> It took me a while to figure this out so it may be useful to add to the
> openEJB docs. 
> 
> Hope this helps,
> Kenneth
> 

-- 
View this message in context: 
http://www.nabble.com/Tomcat---Injection%3A-No-such-property-tp16374013p16452163.html
Sent from the OpenEJB User mailing list archive at Nabble.com.



Tomcat - Injection: No such property

2008-03-29 Thread ebaxt

I'm trying to run my application with Tomcat+openEJB, but I can't figure out
why the EntityManager isn't injected correctly into the EAO sessionbean.
My war file is packed with the ejb.jar in \WEB-INF\lib. 

The client is able to lookup the facade, but when the facade delegates the
EntityManager actions to the EAO a null pointer exception is thrown. 

Here's the log.

INFO  - PersistenceUnit(name=sp2k,
provider=org.apache.openjpa.persistence.PersistenceProviderImpl)
INFO  - Jndi(name=TaxaEAOBeanLocal) --> Ejb(deployment-id=TaxaEAOBean)
INFO  - Jndi(name=Sp2kServiceBeanRemote) -->
Ejb(deployment-id=Sp2kServiceBean)
INFO  - Created Ejb(deployment-id=TaxaEAOBean, ejb-name=TaxaEAOBean,
container=My Stateless Container)
INFO  - Created Ejb(deployment-id=Sp2kServiceBean, ejb-name=Sp2kServiceBean,
container=My Stateless Container)
INFO  - Deployed
Application(path=F:\tomcat\apache-tomcat-6.0.16\webapps\fddb-war-1.0-SNAPSHOT)
WARN  - Injection: No such property
'no.uib.gyro.domain.classification.TaxaEAOBean/em' in class
no.uib.gyro.domain.classification.TaxaEAOBean
WARN  - Injection: No such property
'no.uib.gyro.domain.classification.TaxaEAOBean/em' in class
no.uib.gyro.domain.classification.TaxaEAOBean

The @PersistenceContext annotation is inside the TaxaEAOBean, so it's not
past to the EAO from the facade.

The strange thing is that when I put the EJB's in the war archive, it all
works fine. Is there a difference to openEJB between adding ejb.jar in
WEB-INF\lib or to put the beans directly in the WEB-INF\classes?

Thanks.

-Erik
-- 
View this message in context: 
http://www.nabble.com/Tomcat---Injection%3A-No-such-property-tp16374013p16374013.html
Sent from the OpenEJB User mailing list archive at Nabble.com.



Re: Transaction when testing CRUD on facade

2008-03-29 Thread ebaxt

Thank you David. I changed the transaction-type to TRANSACTION and it all
works fine.

-Erik


David Blevins wrote:
> 
> I'd recommend transaction-type="TRANSACTION" which will allow your  
> EntityManager to be enrolled in the container managed transactions  
> that are created automatically around calls to your session bean.
> 
> As a side note, if you run into any exceptions that complain of an  
> object being "detached", check out this doc for some techniques:
>- http://openejb.apache.org/3.0/jpa-usage.html#JPAUsage-Bedetachaware
> 
> -David
> 
> 
> On Mar 28, 2008, at 8:24 AM, ebaxt wrote:
>>
>> Hi.
>>
>> I'm new to openEJB and EJB3 so please forgive me if this is a stupid
>> question.
>>
>> Say I want to write a unitTest to test some CRUD methods on a  
>> facade. I have
>> a Session Bean with a method:
>>
>> public X createNewX(String name) {
>> ... creates newX
>> xxEAO.create(newX);
>> return newX;
>> }
>>
>> The xxEAO is another Session Bean (the EAO pattern as explained in  
>> "EJB3 in
>> Action").
>>
>> @PersistenceContext
>> EntityManager em;
>> ..
>> public void create(X newX) {
>>  em.persist(newX)
>>  em.flush();
>> }
>>
>> So the Facade creates a new X and delegates the EnitityManager  
>> actions to
>> the xxEAO.
>>
>> In my unitTest(using embedded openEJB) I call the createNewX on the  
>> facade.
>> Now, my question is, do the facade create a transaction, and is the  
>> xxEAO
>> create() method invoked within this transaction? Or do I have to  
>> start a
>> transaction in the unitTest?
>>
>> The reason I'm asking is that the test succeeds, but the data isn't
>> committed to the database.
>>
>> Thanks
>>
>> Erik
>>
>>
>>
>> -- 
>> View this message in context:
>> http://www.nabble.com/Transaction-when-testing-CRUD-on-facade-tp16351025p16351025.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>>
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Transaction-when-testing-CRUD-on-facade-tp16351025p16368576.html
Sent from the OpenEJB User mailing list archive at Nabble.com.



Transaction when testing CRUD on facade

2008-03-28 Thread ebaxt

Hi.

I'm new to openEJB and EJB3 so please forgive me if this is a stupid
question.

Say I want to write a unitTest to test some CRUD methods on a facade. I have
a Session Bean with a method:

public X createNewX(String name) {
... creates newX
xxEAO.create(newX);
return newX;
}

The xxEAO is another Session Bean (the EAO pattern as explained in "EJB3 in
Action").

@PersistenceContext
EntityManager em;
..
public void create(X newX) {
  em.persist(newX)
  em.flush();
}

So the Facade creates a new X and delegates the EnitityManager actions to
the xxEAO.

In my unitTest(using embedded openEJB) I call the createNewX on the facade.
Now, my question is, do the facade create a transaction, and is the xxEAO
create() method invoked within this transaction? Or do I have to start a
transaction in the unitTest? 

The reason I'm asking is that the test succeeds, but the data isn't
committed to the database.

Thanks

Erik



-- 
View this message in context: 
http://www.nabble.com/Transaction-when-testing-CRUD-on-facade-tp16351025p16351025.html
Sent from the OpenEJB User mailing list archive at Nabble.com.