geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Forrest Xia <forres...@gmail.com>
Subject about daytrader-web-jpa
Date Wed, 20 Jan 2010 07:10:48 GMT
Hi Donald,

I tried the new assembly of daytrader -- daytrader-web-jpa, and did not get
it work. The console log an error:

2010-01-20 14:08:24,774 ERROR [Log] Error: TradeJPADirect:createQuote --
exception creating Quote
    java.lang.NullPointerException
java.lang.NullPointerException
    at
org.apache.geronimo.samples.daytrader.core.direct.TradeJPADirect.createQuote(TradeJPADirect.java:418)
    at
org.apache.geronimo.samples.daytrader.core.TradeAction.createQuote(TradeAction.java:373)
    at
org.apache.geronimo.samples.daytrader.web.TradeBuildDB.<init>(TradeBuildDB.java:196)
    at
org.apache.geronimo.samples.daytrader.web.TradeConfigServlet.service(TradeConfigServlet.java:411)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
    at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at
org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.invoke(GeronimoStandardContext.java:420)
    at
org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(GeronimoBeforeAfterValve.java:47)
    at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:567)
    at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:361)
    at org.apache.geronimo.pool.ThreadPool$1.run(ThreadPool.java:214)
    at
org.apache.geronimo.pool.ThreadPool$ContextClassLoaderRunnable.run(ThreadPool.java:344)
    at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)

Then I had a peek at the code, and think this NPE might be caused by
PersistenceContext not injected in TradeJPADirect. Since TradeJPADirect is
not a web container managed object(not servlet or context listener), so the
annotation @PersistenceContext does not work.

I guess daytrader-web-jpa assembly is to demo jpa usage in web module
without session EJB involvement. If we want to demo container-managed entity
manager via this assembly, we shall use @PersistenceContext on servlet or
any web container managed object, then use JNDI lookup to get the entity
manager from container. If we want to demo application-managed entity
manager, we can use @PersistenceUnit to inject an EntityManagerFactory
object in any web container managed object, then use
EntityManagerFactory.createEntityManager() to get entity manager.

Please kindly let me know your thoughts.

Thanks!
Forrest

Mime
View raw message