Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By makpandian

Thread: Unable to fix java.lang.IllegalStateException: Unable to retrieve EntityManagerFactor

  1. #1
    double-whammy is offline Member
    Join Date
    Jul 2014
    Posts
    1
    Rep Power
    0

    Default Unable to fix java.lang.IllegalStateException: Unable to retrieve EntityManagerFactor

    I am trying to learn JSP and servlets by making a project. My goal is NOT to focus on JPA, ORM and persistence or even EJB for now. So, please do not tell me to read a tutorial or book on that. Unfortunately, I am not supposed to use SQL queries to interact with the database. Instead, I used pre-written JPA code to manage the persistence while I focus on jsp and servlets.

    When I run my project, I get the error - java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName AffableBeanPU. My project is located at - https://github.com/double-whammy/affablebean.git Download as zip button is on bottom right corner.

    Note - My persistence.xml file IS inside the META-INF folder. I checked and built my project again. So that reason can be ruled out.

    I googled and none of the solutions were of help. How do I fix this error ?

    MyProject
    |
    |__java (src folder)
    | |
    | |__controller (package)
    | | |__ControllerServlet.java
    | |
    | |__entity (entity classes here)
    | |__session (facade classes for each entity class)
    |
    |
    |__WebContent
    |
    |__WEB-INF
    |
    |__view
    | |__category.jsp
    | |
    | |etc...
    |
    |__index.jsp

    Exception:

    Time|Info: Redirecting to /index.jsf
    Time|Info: Admin Console: Initializing Session Attributes...
    Time|Warning: EJB5184:A system exception occurred during an invocation on EJB CategoryFacade,
    method: public java.util.List session.AbstractFacade.findAll()
    Time|Warning: javax.ejb.EJBException
    at com.sun.ejb.containers.EJBContainerTransactionMana ger.processSystemException(EJBContainerTransaction Manager.java:748)
    at com.sun.ejb.containers.EJBContainerTransactionMana ger.completeNewTx(EJBContainerTransactionManager.j ava:698)
    at com.sun.ejb.containers.EJBContainerTransactionMana ger.postInvokeTx(EJBContainerTransactionManager.ja va:503)
    at com.sun.ejb.containers.BaseContainer.postInvokeTx( BaseContainer.java:4475)
    at com.sun.ejb.containers.BaseContainer.postInvoke(Ba seContainer.java:2009)
    at com.sun.ejb.containers.BaseContainer.postInvoke(Ba seContainer.java:1979)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHan dler.invoke(EJBLocalObjectInvocationHandler.java:2 20)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHan dlerDelegate.invoke(EJBLocalObjectInvocationHandle rDelegate.java:88)
    at com.sun.proxy.$Proxy193.findAll(Unknown Source)
    at session.__EJB31_Generated__CategoryFacade__Intf___ _Bean__.findAll(Unknown Source)
    at controller.ControllerServlet.init(ControllerServle t.java:31)
    at javax.servlet.GenericServlet.init(GenericServlet.j ava:244)
    at org.apache.catalina.core.StandardWrapper.initServl et(StandardWrapper.java:1583)
    at org.apache.catalina.core.StandardWrapper.allocate( StandardWrapper.java:1212)
    etc .................................................. . etc...
    at java.lang.Thread.run(Thread.java:745)

    Caused by: java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName AffableBeanPU
    at com.sun.enterprise.container.common.impl.EntityMan agerWrapper.init(EntityManagerWrapper.java:138)
    at com.sun.enterprise.container.common.impl.EntityMan agerWrapper._getDelegate(EntityManagerWrapper.java :171)
    at com.sun.enterprise.container.common.impl.EntityMan agerWrapper.getCriteriaBuilder(EntityManagerWrappe r.java:834)
    at session.AbstractFacade.findAll(AbstractFacade.java :41)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
    etc .................................................. . etc...
    at com.sun.ejb.containers.EJBLocalObjectInvocationHan dler.invoke(EJBLocalObjectInvocationHandler.java:2 12)
    ... 33 more

    Time|Severe: WebModule[/AffableBean]StandardWrapper.Throwable
    javax.ejb.EJBException
    at com.sun.ejb.containers.EJBContainerTransactionMana ger.processSystemException(EJBContainerTransaction Manager.java:748)
    at com.sun.ejb.containers.EJBContainerTransactionMana ger.completeNewTx(EJBContainerTransactionManager.j ava:698)
    at com.sun.ejb.containers.EJBContainerTransactionMana ger.postInvokeTx(EJBContainerTransactionManager.ja va:503)
    etc .................................................. . etc...
    at session.__EJB31_Generated__CategoryFacade__Intf___ _Bean__.findAll(Unknown Source)
    at controller.ControllerServlet.init(ControllerServle t.java:31)
    at javax.servlet.GenericServlet.init(GenericServlet.j ava:244)
    at org.apache.catalina.core.StandardWrapper.initServl et(StandardWrapper.java:1583)
    at org.apache.catalina.core.StandardWrapper.allocate( StandardWrapper.java:1212)
    etc .................................................. . etc...
    at java.lang.Thread.run(Thread.java:745)

    Caused by: java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName AffableBeanPU
    at com.sun.enterprise.container.common.impl.EntityMan agerWrapper.init(EntityManagerWrapper.java:138)
    at com.sun.enterprise.container.common.impl.EntityMan agerWrapper._getDelegate(EntityManagerWrapper.java :171)
    at com.sun.enterprise.container.common.impl.EntityMan agerWrapper.getCriteriaBuilder(EntityManagerWrappe r.java:834)
    at session.AbstractFacade.findAll(AbstractFacade.java :41)
    etc .................................................. . etc...
    at com.sun.ejb.containers.EJBLocalObjectInvocationHan dler.invoke(EJBLocalObjectInvocationHandler.java:2 12)
    ... 33 more

    Time|Warning: StandardWrapperValve[ControllerServlet]: Allocate exception for servlet ControllerServlet
    java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName AffableBeanPU
    at com.sun.enterprise.container.common.impl.EntityMan agerWrapper.init(EntityManagerWrapper.java:138)
    at com.sun.enterprise.container.common.impl.EntityMan agerWrapper._getDelegate(EntityManagerWrapper.java :171)
    at com.sun.enterprise.container.common.impl.EntityMan agerWrapper.getCriteriaBuilder(EntityManagerWrappe r.java:834)
    at session.AbstractFacade.findAll(AbstractFacade.java :41)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    etc .................................................. . etc...

    Persistence.xml :

    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="2.0"
    xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    <persistence-unit name="AffableBeanPU"
    transaction-type="JTA">
    <jta-data-source>jdbc/affablebean</jta-data-source>
    <properties>
    <property name="eclipselink.logging.level" value="FINEST" />
    </properties>
    </persistence-unit>
    </persistence>

  2. #2
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,010
    Rep Power
    6

    Default Re: Unable to fix java.lang.IllegalStateException: Unable to retrieve EntityManagerFa

    The persistence.xml file may be in a META-INF folder in your project, but that is entirely irrelevant. What matters is: is it in a folder WEB-INF/classes/META-INF when deployed to the server?

    Strange that you think you can rule things out by the way. You really from the get-go build gigantic walls of help-resistance around yourself, I wonder why I still even bother to reply to be honest. I guess I have hope you will correct yourself.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    448
    Rep Power
    6

    Default Re: Unable to fix java.lang.IllegalStateException: Unable to retrieve EntityManagerFa

    See, Your goal is to learn JSP and servlets but you struck on JPA and DB releated stuff. I wonder why you need JPA, EJP or legacy JDBC to learn JSP.

    You do not need even DB to learn JSP. Try yourself with JSP and Servlets alone with out thinking about anything else. There are many concepts to learn in JSP and Servlet.

    You can use static data by storing on Java collections, and use the same in your JSP. That will help you to learn what you want.
    milovan likes this.
    Mak
    (Living @ Virtual World)

Similar Threads

  1. Binary Search / Sort - Unable To Retrieve Index
    By sequential in forum New To Java
    Replies: 4
    Last Post: 08-18-2013, 08:52 PM
  2. Unable to download maven repository - Unable to load the mojo
    By tejkiransharma in forum Apache Maven
    Replies: 0
    Last Post: 12-31-2012, 03:44 PM
  3. Unable to retrieve stock quotes from yahoo
    By the reporter in forum AWT / Swing
    Replies: 4
    Last Post: 06-03-2010, 04:10 PM
  4. Replies: 0
    Last Post: 04-11-2010, 11:14 PM
  5. Replies: 11
    Last Post: 09-01-2008, 10:56 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •