Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8751885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:07:49+00:00 2026-06-13T13:07:49+00:00

in an application I m using JPA + hibernate. However when I m trying

  • 0

in an application I m using JPA + hibernate. However when I m trying to access the db I m getting the following error :

 java.lang.NullPointerException: javax.faces.FacesException:
#{loginBean.authenticate}: java.lang.NullPointerException

the exception occurs when i execute the line: EntityManager em = emf.createEntityManager();

Below you see the full serverlog.

18:21:48,174 INFO  [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (http--0.0.0.0-8080-1) HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory

18:21:48,177 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (http--0.0.0.0-8080-1) HHH000397: Using ASTQueryTranslatorFactory

18:21:48,189 INFO  [org.hibernate.tool.hbm2ddl.SchemaUpdate] (http--0.0.0.0-8080-1) HHH000228: Running hbm2ddl schema update

18:21:48,191 INFO  [org.hibernate.tool.hbm2ddl.SchemaUpdate] (http--0.0.0.0-8080-1) HHH000102: Fetching database metadata

18:21:48,193 INFO  [org.hibernate.tool.hbm2ddl.SchemaUpdate] (http--0.0.0.0-8080-1) HHH000396: Updating schema

18:21:48,195 INFO  [org.hibernate.tool.hbm2ddl.SchemaUpdate] (http--0.0.0.0-8080-1) HHH000232: Schema update complete

18:22:08,153 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (http--0.0.0.0-8080-1) #{loginBean.authenticate}: java.lang.NullPointerException: javax.faces.FacesException: #{loginBean.authenticate}: java.lang.NullPointerException

    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118) [jsf-impl-2.1.7-jbossorg-2.jar:]

    at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [jsf-impl-2.1.7-jbossorg-2.jar:]

    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.7-jbossorg-2.jar:]

    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.7-jbossorg-2.jar:]

    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]

    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]

    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]

    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]

    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]

    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]

    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]

    at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_32]

Caused by: javax.faces.el.EvaluationException: java.lang.NullPointerException

    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) [jsf-impl-2.1.7-jbossorg-2.jar:]

    ... 21 more

Caused by: java.lang.NullPointerException

    at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.getStatus(JtaStatusHelper.java:73) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

    at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.isActive(JtaStatusHelper.java:115) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

    at org.hibernate.engine.transaction.internal.jta.CMTTransaction.join(CMTTransaction.java:149) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

    at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:1207) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

    at org.hibernate.ejb.AbstractEntityManagerImpl.postInit(AbstractEntityManagerImpl.java:176) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

    at org.hibernate.ejb.EntityManagerImpl.<init>(EntityManagerImpl.java:89) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

    at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:125) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

    at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:120) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

    at org.Handlers.UserHandler.getAllUsers(UserHandler.java:32) [classes:]

    at org.tutorial.LoginBean.authenticate(LoginBean.java:50) [classes:]

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_32]

    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.6.0_32]

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.6.0_32]

    at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.6.0_32]

    at org.apache.el.parser.AstValue.invoke(AstValue.java:262) [jbossweb-7.0.13.Final.jar:]

    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) [jbossweb-7.0.13.Final.jar:]

    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.1.7-jbossorg-2.jar:]

    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

    ... 22 more

My guess is that, for some reason , it has to do with the entity manager. I m really new to using hibernate and JPA . I also attach a class to show you how I access the db. Could someone figure out what I m doing wrong?

public class ProjectHandler {

    public void create(Project project) {
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("ResearchManagement.Data");

        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        em.persist(project);
        em.getTransaction().commit();
        em.close();
    }

    public List<Project> getAllProjects() {
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("ResearchManagement.Data");

        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();

        Query query = em.createQuery("SELECT p FROM Project p");
        List<Project> projects = query.getResultList();
        em.getTransaction().commit();
        em.close();
        return projects;
    }

    public int deleteByProjectName(String projectName) {
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("ResearchManagement.Data");

        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();

        Query q = em.createQuery("DELETE FROM Project p WHERE p.projectName = :u");
        q.setParameter("u", projectName );    
        int deleted = q.executeUpdate();
        em.getTransaction().commit();
        em.close();
        return deleted;
    }

}

Thnx for your answer and your tips about my code.
However I debug my app and I see that the emf is not null .
I still get the error at the line : EntityManager em = emf.createEntityManager();

So my guess is that the emf returns a null entityManager. Still doesnt understand why

What I noticed and looks strange the server log when I run the application. it reads the pesistence unit and connects to the db reading corerclty all the tables:

12:02:06,094 INFO [org.hibernate.validator.util.Version] (MSC service thread 1-3) Hibernate Validator 4.2.0.Final

12:02:06,328 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] (MSC service thread 1-3) HHH000228: Running hbm2ddl schema update

12:02:06,328 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] (MSC service thread 1-3) HHH000102: Fetching database metadata

12:02:06,328 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] (MSC service thread 1-3) HHH000396: Updating schema

12:02:06,343 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000261: Table found: researchprojects.departments

12:02:06,343 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000037: Columns: [phonenumber, departmentid, name, city]

12:02:06,343 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000108: Foreign keys: []

12:02:06,343 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000126: Indexes: [primary]

12:02:06,359 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000261: Table found: researchprojects.employees

12:02:06,359 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000037: Columns: [phonenumber, departmentid, employeeid, lastname, firstname]

12:02:06,359 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000108: Foreign keys: [fk9d39ef85d77ba982]

12:02:06,359 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000126: Indexes: [fk9d39ef85d77ba982, primary]

12:02:06,374 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000261: Table found: researchprojects.partners

12:02:06,374 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000037: Columns: [partnerid, name, contactmail, city]

12:02:06,374 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000108: Foreign keys: []

12:02:06,374 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000126: Indexes: [primary]

12:02:06,374 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000261: Table found: researchprojects.projects

12:02:06,390 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000037: Columns: [departmentid, duration, description, projectname, projectid]

12:02:06,390 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000108: Foreign keys: [fkc479187ad77ba982]

12:02:06,390 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000126: Indexes: [primary, fkc479187ad77ba982]

12:02:06,390 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000261: Table found: researchprojects.projects_has_employees

12:02:06,390 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000037: Columns: [projects_projectid, employees_employeeid]

12:02:06,390 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000108: Foreign keys: [fk294f111bcd3ec025, fk294f111b92772ef4]

12:02:06,390 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000126: Indexes: [fk294f111bcd3ec025, primary, fk294f111b92772ef4]

12:02:06,406 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000261: Table found: researchprojects.projects_has_partners

12:02:06,406 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000037: Columns: [partners_partnerid, projects_projectid]

12:02:06,406 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000108: Foreign keys: [fk8d741055cd3ec025, fk8d7410555290eb4]

12:02:06,406 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000126: Indexes: [fk8d741055cd3ec025, fk8d7410555290eb4, primary]

12:02:06,421 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000261: Table found: researchprojects.users

12:02:06,421 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000037: Columns: [username, userid, password]

12:02:06,421 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000108: Foreign keys: []

12:02:06,421 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000126: Indexes: [primary]

12:02:06,421 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000261: Table found: researchprojects.hibernate_sequence

12:02:06,437 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000037: Columns: [next_val]

12:02:06,437 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000108: Foreign keys: []

12:02:06,437 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-3) HHH000126: Indexes: []

12:02:06,437 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] (MSC service thread 1-3) HHH000232: Schema update complete

However when I m trying to read the user table (getallUsers() ) , it creates the emf and at the log i see:

12:03:53,346 INFO [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (http–0.0.0.0-8080-1) HHH000397: Using ASTQueryTranslatorFactory

12:03:53,347 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] (http–0.0.0.0-8080-1) HHH000228: Running hbm2ddl schema update

12:03:53,347 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] (http–0.0.0.0-8080-1) HHH000102: Fetching database metadata

12:03:53,347 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] (http–0.0.0.0-8080-1) HHH000396: Updating schema

12:03:53,347 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] (http–0.0.0.0-8080-1) HHH000232: Schema update complete

That means that it cannot read the tables anymore. Does this mean anything to you ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:07:50+00:00Added an answer on June 13, 2026 at 1:07 pm

    The error is caused by Hibernate internals,
    at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.getStatus(JtaStatusHelper.java:73)
    This likely means that you have an issue with JTA configuration or classes. Since you are attempting to start a user transaction later on, you might have incorrectly marked it as JTA instead of resource_local.

    This isn’t a full answer as I’m not familiar with the code, but hope it helps point in the right direction.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed demo application using spring struct and hibernate and getting following error
I'm creating a Java EE application that's using JPA for data access. Initially I
We are developing a Java EE application using Hibernate as a JPA provider. We
Our application is developed on Java over Play! 1.2.4. We're using JPA over Hibernate
I'm doing a Web application using Spring 3.1.0.RELEASE, JSF 2.x, JPA 2 with Hibernate
I'm doing a Web application using Spring 3.1.0.RELEASE, JSF 2.x, JPA 2 with Hibernate
I am using Spring 3, JPA + Hibernate for a CMS application. In that
Here's what I'm trying to do. I'm using JPA persistence in a web application,
I'm have a lot of time using hibernate (JPA) in java, but i recently
I'm doing a Web application using Spring 3.1.0.RELEASE, JSF 2.x, JPA 2 with Hibernate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.