jpa - java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName CarLocPU -
i'm beginning java ee netbeans 8.1, glassfish 4.1 , apache derby (included in glassfish).
for purpose i'm calling put , store car data attributes.
but simple facade returns "java.lang.illegalstateexception" whereas i'm seeing no mistakes in class files.
here simple entity of model.car basic getters , setters :
@entity @table(name = "car") public class car implements java.io.serializable { @id @generatedvalue(strategy = generationtype.sequence) private integer id; private string brand; private string model; private string year; private string energy; private string hp; private string tp; private byte[] picture;
here "facade" entity store data in apache derby :
@stateless public class carfacade extends abstractfacade<car> { @persistencecontext(unitname = "carlocpu") private entitymanager em; @override protected entitymanager getentitymanager() { return em; } public carfacade() { super(car.class); } }
i'm having lot of trouble debugging following exception since simple short part of code , should works fine. moreover, stacktrace doesn't show breaking point in java se.
here exception stacktrace :
caused by: java.lang.illegalstateexception: unable retrieve entitymanagerfactory unitname carlocpu @ com.sun.enterprise.container.common.impl.entitymanagerwrapper.init(entitymanagerwrapper.java:138) @ com.sun.enterprise.container.common.impl.entitymanagerwrapper.dotxrequiredcheck(entitymanagerwrapper.java:158) @ com.sun.enterprise.container.common.impl.entitymanagerwrapper.dotransactionscopedtxcheck(entitymanagerwrapper.java:151) @ com.sun.enterprise.container.common.impl.entitymanagerwrapper.persist(entitymanagerwrapper.java:281) @ facade.abstractfacade.create(abstractfacade.java:26) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:497) @ org.glassfish.ejb.security.application.ejbsecuritymanager.runmethod(ejbsecuritymanager.java:1081) @ org.glassfish.ejb.security.application.ejbsecuritymanager.invoke(ejbsecuritymanager.java:1153) @ com.sun.ejb.containers.basecontainer.invokebeanmethod(basecontainer.java:4786) @ com.sun.ejb.ejbinvocation.invokebeanmethod(ejbinvocation.java:656) @ com.sun.ejb.containers.interceptors.aroundinvokechainimpl.invokenext(interceptormanager.java:822) @ com.sun.ejb.ejbinvocation.proceed(ejbinvocation.java:608) @ org.jboss.weld.ejb.abstractejbrequestscopeactivationinterceptor.aroundinvoke(abstractejbrequestscopeactivationinterceptor.java:64) @ org.jboss.weld.ejb.sessionbeaninterceptor.aroundinvoke(sessionbeaninterceptor.java:52) @ sun.reflect.generatedmethodaccessor965.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:497) @ com.sun.ejb.containers.interceptors.aroundinvokeinterceptor.intercept(interceptormanager.java:883) @ com.sun.ejb.containers.interceptors.aroundinvokechainimpl.invokenext(interceptormanager.java:822) @ com.sun.ejb.ejbinvocation.proceed(ejbinvocation.java:608) @ com.sun.ejb.containers.interceptors.systeminterceptorproxy.docall(systeminterceptorproxy.java:163) @ com.sun.ejb.containers.interceptors.systeminterceptorproxy.aroundinvoke(systeminterceptorproxy.java:140) @ sun.reflect.generatedmethodaccessor994.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:497) @ com.sun.ejb.containers.interceptors.aroundinvokeinterceptor.intercept(interceptormanager.java:883) @ com.sun.ejb.containers.interceptors.aroundinvokechainimpl.invokenext(interceptormanager.java:822) @ com.sun.ejb.containers.interceptors.interceptormanager.intercept(interceptormanager.java:369) @ com.sun.ejb.containers.basecontainer.__intercept(basecontainer.java:4758) @ com.sun.ejb.containers.basecontainer.intercept(basecontainer.java:4746) @ com.sun.ejb.containers.ejblocalobjectinvocationhandler.invoke(ejblocalobjectinvocationhandler.java:212) ... 53 more
thank in advance help.
edit :
here structure of project.
and here persistence.xml content, application named "carloc".
<?xml version="1.0" encoding="utf-8"?> <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> <persistence-unit name="carlocpu" transaction-type="jta"> <jta-data-source>java:app/jdbc/carloc</jta-data-source> <exclude-unlisted-classes>false</exclude-unlisted-classes> <properties/> </persistence-unit> </persistence>
if using jpa outside of ejb container, need declare jpa <provider>
in persistence.xml.
by default glassfish uses eclipselink jpa provider. assuming don't want change this, want change persistence.xml declare eclipselink jpa provider:
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"> <persistence-unit name="carlocpu" transaction-type="jta"> <provider>org.eclipse.persistence.jpa.persistenceprovider</provider> <exclude-unlisted-classes>false</exclude-unlisted-classes> <properties> <property name="eclipselink.target-database" value="derby"/> <!-- jdbc connection properties --> <property name="eclipselink.jdbc.driver" value="org.apache.derby.jdbc.clientdriver"/> <property name="eclipselink.jdbc.url" value="jdbc:derby://localhost:1527/mydbname;create=true;"/> <property name="eclipselink.jdbc.user" value="app"/> <property name="eclipselink.jdbc.password" value="app"/> </properties> </persistence-unit> </persistence>
Comments
Post a Comment