On 9/4/07, Xh <[EMAIL PROTECTED]> 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(); > } > ... > }
have you tried @PersistenceContext(unitName="WebModulePU") EntityManager em = null; I think that should inject the WebModulePU into em. 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 Also, just in case, is your persistence.xml named 'persistence.xml' and not 'persistance.xml'? --Viet ___________________________________________________________ > Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with > voicemail http://uk.messenger.yahoo.com >
