geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <david_jen...@yahoo.com>
Subject Re: Geronimo 2.0.1 and entity bean problem
Date Wed, 05 Sep 2007 06:13:48 GMT
There's a really simple jpa sample in the testsuite.  If you check  
out the geronimo source it will be under

testsuite/enterprise-testsuite/jpa-tests/

Hope this helps
david jencks

On Sep 4, 2007, at 5:08 PM, Xh wrote:

> Hi All!
>
> I'm trying to create my first ejb3 entity bean in Geronimo 2.0.1.
>
> I base on this wiki:
> http://cwiki.apache.org/GMOxDOC20/very-simple-entity-ejb-example.html
>
> I've created simple WebModule and annoted it, just like this:
>
> @Entity
> @Table(name="dw_module",schema="dw")
> public class WebModule implements Serializable {
> ...
> }
>
> Acording to the above wiki openejb-jar.xml is only to define module  
> and artifactId, so do mine.
> In addition, I have META-INF/persistance.xml that looks like this:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
> version="1.0"
>     xsi:schemaLocation="http://java.sun.com/xml/ns/persistence  
> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
>     <persistence-unit name="WebModulePU">
>         <provider>
>             org.apache.openjpa.persistence.PersistenceProviderImpl
>         </provider>
>         <class>org.xh.dataweaver2.web.entity.WebModule</class>
>         <properties>
>             <property name="openjpa.ConnectionURL"
>                 value="jdbc:derby:target/dataweaver" />
>             <property name="openjpa.ConnectionUserName" value="dw" />
>             <property name="openjpa.ConnectionPassword"
>                 value="admin123" />
>             <property name="openjpa.ConnectionDriverName"
>                 value="org.apache.derby.jdbc.EmbeddedDriver" />
>         </properties>
>     </persistence-unit>
> </persistence>
>
>
> Later on, in my Servlet I have:
>
> // thread-safe, class level context
> @PersistenceContext(unitName = "WebModulePU", name = "persistence/em")
> public class DispatcherServlet extends HttpServlet implements  
> Servlet {
> ...
> EntityManager em = null;
>         try {
>             em = (EntityManager) (new InitialContext())
>                     .lookup("java:comp/env/persistence/em");
>         } catch (NamingException e) {
>             e.printStackTrace();
>         }
> ...
> }
>
>
> The thing is that my application deploys and starts without any  
> errors.
> But I cannot see my entity bean in the JNDI Viewer;
> as a result, when I access my Servlet I keep getting:
> javax.naming.NotContextException: persistence/em
>
> Can some one provide an example of working entity bean and its  
> persistance.xml?
>
> thanks and best regards
> Ɓukasz
>
>
>
>
> 	
> 	
> 		
> ___________________________________________________________
> Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide  
> with voicemail http://uk.messenger.yahoo.com


Mime
View raw message