tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Blevins (Closed) (JIRA)" <j...@apache.org>
Subject [jira] [Closed] (TOMEE-36) NullPointerException when Missing required persistence.xml for @PersistenceUnit
Date Mon, 23 Jan 2012 11:10:58 GMT

     [ https://issues.apache.org/jira/browse/TOMEE-36?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

David Blevins closed TOMEE-36.
------------------------------

    Resolution: Fixed
    
> NullPointerException when Missing required persistence.xml for @PersistenceUnit
> -------------------------------------------------------------------------------
>
>                 Key: TOMEE-36
>                 URL: https://issues.apache.org/jira/browse/TOMEE-36
>             Project: TomEE
>          Issue Type: Bug
>    Affects Versions: 1.0.0-beta-1
>            Reporter: Jacek Laskowski
>             Fix For: 1.0.0-beta-2
>
>
> Given the servlet:
> {code:title=PersistenceUnitServlet.java|borderStyle=solid}
> package pl.japila.tomee;
> import java.io.IOException;
> import java.io.PrintWriter;
> import javax.persistence.EntityManagerFactory;
> import javax.persistence.PersistenceUnit;
> import javax.servlet.ServletException;
> import javax.servlet.annotation.WebServlet;
> import javax.servlet.http.HttpServlet;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
> @WebServlet(name = "PersistenceUnitServlet", urlPatterns = {"/PersistenceUnitServlet"})
> public class PersistenceUnitServlet extends HttpServlet {
>     @PersistenceUnit(unitName="mysql")
>     private EntityManagerFactory emf;
>     protected void processRequest(HttpServletRequest request, HttpServletResponse response)
>             throws ServletException, IOException {
>         response.setContentType("text/html;charset=UTF-8");
>         PrintWriter out = response.getWriter();
>         try {
>             out.println("<h1>Witaj</h1>");
>         } finally {
>             out.close();
>         }
>     }
>     // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the
+ sign on the left to edit the code.">
>     /** 
>      * Handles the HTTP <code>GET</code> method.
>      * @param request servlet request
>      * @param response servlet response
>      * @throws ServletException if a servlet-specific error occurs
>      * @throws IOException if an I/O error occurs
>      */
>     @Override
>     protected void doGet(HttpServletRequest request, HttpServletResponse response)
>             throws ServletException, IOException {
>         processRequest(request, response);
>     }
>     /** 
>      * Handles the HTTP <code>POST</code> method.
>      * @param request servlet request
>      * @param response servlet response
>      * @throws ServletException if a servlet-specific error occurs
>      * @throws IOException if an I/O error occurs
>      */
>     @Override
>     protected void doPost(HttpServletRequest request, HttpServletResponse response)
>             throws ServletException, IOException {
>         processRequest(request, response);
>     }
>     /** 
>      * Returns a short description of the servlet.
>      * @return a String containing servlet description
>      */
>     @Override
>     public String getServletInfo() {
>         return "Short description";
>     }// </editor-fold>
> }
> {code}
> Upon executing it, Tomcat/TomEE reports NPE in catalina.2011-10-14.log:
> {noformat}
> Oct 14, 2011 8:10:44 PM org.apache.coyote.http11.Http11Processor process
> SEVERE: Error processing request
> java.lang.NullPointerException
>         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:133)
>         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:151)
>         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
>         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
>         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
>         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
>         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:269)
>         at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
>         at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
>         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:680)
> {noformat}
> which is because OpenEJB/TomEE reported ValidationFailedException in openejb.log:
> {noformat}
> 2011-10-14 20:10:43,500 - ERROR - faces config file is null
> 2011-10-14 20:10:43,746 - INFO  - Configuring enterprise application: /Users/jacek/NetBeansProjects/PersistenceUnitWebApp/build/web
> 2011-10-14 20:10:43,901 - ERROR - FAIL ... PersistenceUnitWebApp:	Missing required persistence.xml
for @PersistenceUnit ref "emf" to unit "mysql"
> 2011-10-14 20:10:43,901 - ERROR - Invalid WebModule(name=localhost/PersistenceUnitWebApp,
path=/Users/jacek/NetBeansProjects/PersistenceUnitWebApp/build/web)
> 2011-10-14 20:10:43,901 - INFO  - Set the 'openejb.validation.output.level' system property
to VERBOSE for increased validation details.
> 2011-10-14 20:10:43,902 - ERROR - Unable to deploy collapsed ear in war /PersistenceUnitWebApp:
Exception: Module failed validation. AppModule(name=web)
> org.apache.openejb.config.ValidationFailedException: Module failed validation. AppModule(name=web)
> 	at org.apache.openejb.config.ReportValidationResults.deploy(ReportValidationResults.java:82)
> 	at org.apache.openejb.config.AppInfoBuilder.build(AppInfoBuilder.java:266)
> 	at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:695)
> 	at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:437)
> 	at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:394)
> 	at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:117)
> 	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
> 	at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
> 	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5103)
> 	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
> 	at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3854)
> 	at org.apache.catalina.manager.ManagerServlet.reload(ManagerServlet.java:949)
> 	at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:360)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
> 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
> 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> 	at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
> 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
> 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
> 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:185)
> 	at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
> 	at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
> 	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581)
> 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:151)
> 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
> 	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
> 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
> 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
> 	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:269)
> 	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
> 	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
> 	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:680)
> {noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message