post: createEntityManagerFactory throwing NullPointerException when used with SQL Server
hibernate version: 3.2.2
database: SQL Server 2005
web server: Apache Tomcat/6.0.13
IDE: netbeans
I'm working on an internal web-app that connects to a SQL Server 2005 back-end. Everything was basically moving along smoothly until I got an error trying to create an EntityManagerFactory with the following line:
Code:
emf = Persistence.createEntityManagerFactory("foo");
Originally this line was working fine; I don't believe I changed anything related to my persistence, and suddenly i'm getting the error
shown at the bottom of this post.The crazy part: when I converted everything back to the original working code, I STILL get the error... HOWEVER sometimes after I stop and restart the webserver it will work, but only until I redeploy or stop/start my webserver - then I start getting the error again.
Another crazy part: I am using the exact same logic for another internal web-app that has an Oracle back-end, and never have a problem (so I feel I have a handle on creating my entities properly and believe I have the persistence.xml file setup properly).
My assumption is that there is some known issue with the persistence layer and SQL Server, and I'm hoping that it's an issue others have come across and overcome. Please let me know if I can provide any more information or you need to see any of the related files/code.
Any help is appericiated as I've been batteling this problem for the last 3 days. I'll keep looking, but if you have any help it is really appericiated.
thank you so much for your time,
Russell
here's the actual error i get:Code:
exception
javax.servlet.ServletException: Cant instantiate class: com.amgen.dcm.model.VendorController.. null
javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
root cause
javax.faces.FacesException: Cant instantiate class: com.amgen.dcm.model.VendorController.. null
com.sun.faces.config.ManagedBeanFactoryImpl.newInstance(ManagedBeanFactoryImpl.java:282)
com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:531)
com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:82)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:45)
org.apache.el.parser.AstValue.getValue(AstValue.java:86)
org.apache.el.parser.AstPlus.getValue(AstPlus.java:22)
org.apache.el.parser.AstDeferredExpression.getValue(AstDeferredExpression.java:26)
org.apache.el.parser.AstCompositeExpression.getValue(AstCompositeExpression.java:31)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:101)
javax.faces.component.UIOutput.getValue(UIOutput.java:173)
com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:189)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:320)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:200)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:833)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:896)
javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:244)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:175)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
root cause
java.lang.NullPointerException
oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createEntityManagerFactory(EntityManagerFactoryProvider.java:120)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
com.amgen.dcm.model.VendorController.<init>(VendorController.java:31)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance(Constructor.java:494)
java.lang.Class.newInstance0(Class.java:350)
java.lang.Class.newInstance(Class.java:303)
com.sun.faces.config.ManagedBeanFactoryImpl.newInstance(ManagedBeanFactoryImpl.java:277)
com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:531)
com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:82)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:45)
org.apache.el.parser.AstValue.getValue(AstValue.java:86)
org.apache.el.parser.AstPlus.getValue(AstPlus.java:22)
org.apache.el.parser.AstDeferredExpression.getValue(AstDeferredExpression.java:26)
org.apache.el.parser.AstCompositeExpression.getValue(AstCompositeExpression.java:31)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:101)
javax.faces.component.UIOutput.getValue(UIOutput.java:173)
com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:189)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:320)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:200)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:833)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:896)
javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:244)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:175)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)