You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by ericp56 <er...@twcable.com> on 2008/07/08 16:58:39 UTC
Configuring OpenJPA, need help
Hello,
I have OpenJPA working on Tomcat 6 using
Persistence.createEntityManagerFactory, which is unmanaged.
Now I'd like to use the managed environment, but I am having a problem with
the JNDI resource.
I am not deploying a WAR, but individual files, so I can't use
META-INF/context.xml (I'm led to believe).
I have placed the resource in CATALINA's context.xml:
<Resource name="bean/OpenJPAEMF" auth="Container"
type="org.apache.openjpa.persistence.OpenJPAEntityManagerFactory"
factory="org.apache.naming.factory.BeanFactory"/>
In my code, I have:
Context initCtx = new InitialContext();
emf = (OpenJPAEntityManagerFactory)
initCtx.lookup("java:comp/env/bean/OpenJPAEMF");
which raises:
java.lang.InstantiationException:
org.apache.openjpa.persistence.OpenJPAEntityManagerFactory
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at
org.apache.naming.factory.BeanFactory.getObjectInstance(BeanFactory.java:143)
I am relatively "green" at this. Can someone point me in the right
direction?
If that direction is through a 300 page manual, can you provide an example
instead?:blush:
Thanks,
Eric
--
View this message in context: http://www.nabble.com/Configuring-OpenJPA%2C-need-help-tp18341039p18341039.html
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Configuring OpenJPA, need help
Posted by ericp56 <er...@twcable.com>.
It looks like java:comp/env/OpenJPAEMF should have worked, although the extra
slash didn't work either.
>From reading some articles, it looks like the following should work:
I'm no longer using the initial context, or web.xml.
context.xml:
<Resource name="bean/OpenJPAEMF" auth="Container"
factory="org.apache.openjpa.persistence.OpenJPAEntityManagerFactory"
type="org.apache.openjpa.persistence.OpenJPAEntityManagerFactory.class" />
my class using JPA:
@PersistenceUnit(unitName = "CallScheduler")
private @Resource(name="bean/OpenJPAEMF")OpenJPAEntityManagerFactory emf;
private OpenJPAEntityManager em;
In my functions, emf is still null.
--
View this message in context: http://www.nabble.com/Configuring-OpenJPA%2C-need-help-tp18341039p18347525.html
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Configuring OpenJPA, need help
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: ericp56 [mailto:eric.phetteplace@twcable.com]
> Subject: RE: Configuring OpenJPA, need help
>
> initCtx.lookup("java:comp/env/OpenJPAEMF");
Try "java:/comp/env/OpenJPAEMF". Note the additional slash.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Configuring OpenJPA, need help
Posted by ericp56 <er...@twcable.com>.
How true,
I was creating a JDBC JNDI for an example, and didn't have it configured
properly. That misled me.
Thanks!
I now have in my META-INF/context.xml file:
<Resource
name="OpenJPAEMF"
auth="Container"
factory="org.apache.openjpa.persistence.OpenJPAEntityManagerFactory"
type="org.apache.openjpa.persistence.OpenJPAEntityManager"
/>
Now, this code:
Context initCtx = new InitialContext();
emf = (OpenJPAEntityManagerFactory)
initCtx.lookup("java:comp/env/OpenJPAEMF");
Causes:
javax.naming.NameNotFoundException: Name OpenJPAEMF is not bound in this
Context
What am I doing wrong now?
--
View this message in context: http://www.nabble.com/Configuring-OpenJPA%2C-need-help-tp18341039p18343113.html
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Configuring OpenJPA, need help
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: ericp56 [mailto:eric.phetteplace@twcable.com]
> Subject: Configuring OpenJPA, need help
>
> I am not deploying a WAR, but individual files, so I can't use
> META-INF/context.xml (I'm led to believe).
Not true. Simply create the META-INF directory under your webapp deployment directory and place the <Context> element in context.xml. Exactly the same structure as an expanded .war file.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org