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 6253713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:03:06+00:00 2026-05-24T14:03:06+00:00

I am trying to deploy a web app I found on net,which is supposed

  • 0

I am trying to deploy a web app I found on net,which is supposed to act as a jpql shell webapp demo.
Trying to deploy and run it in tomcat,I created a persistence.xml (in the src directory) as below

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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_1_0.xsd">
  <persistence-unit name="pu" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <class>jpql.Employee</class>
    <class>jpql.Job</class>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
      <property name="hibernate.connection.url" value="jdbc:postgresql://localhost/jpqldemodb"/>
      <property name="hibernate.connection.username" value="damon"/>
      <property name="hibernate.connection.password" value="damon"/>
      <property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
      <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
    </properties>
  </persistence-unit>
</persistence>

and the EntityManager util is (borrowed from another site)

package jpql.utils;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.apache.log4j.Logger;

public class EntityManagerUtil {
    static Logger logger = Logger.getLogger(EntityManagerUtil.class);
    private static EntityManager em=null;

    public static EntityManager getInstance() {
      if ( em == null) {
        EntityManagerFactory emf;
        emf = Persistence.createEntityManagerFactory("pu");
        if(emf == null){
            logger.info("emf is null");
        }else{
            logger.info("emf is created"+emf);
        }
        em = emf.createEntityManager();
        logger.info("em is created="+em);
        return em;
      }
      else
        return em;
    }
}

The war file structure is

META-INF
WEB-INF----------classes
                 lib-----------hibernate3.jar
                 web.xml     |-hibernate-jpa-2.0-1.00.Final.jar
                              --hibernate-tools.jar etc..

query.jsp

It deploys successfully ,and the query.jsp comes up as welcome page.(In the jsp ,calls like EntityManager em = jpql.utils.EntityManagerUtil.getInstance(); happen inside a scriptlet).However,when I click on the submit button,I am getting this error

org.apache.jasper.JasperException: An exception occurred processing JSP page /query.jsp at line 25

22:           if ( query == null || query.length() ==  0)
23:               return;
24: 
25:           EntityManager em = jpql.utils.EntityManagerUtil.getInstance();
26:           List lst = null;
27:           try {
28:             Query  qry = em.createQuery(query);


Stacktrace:
        org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

javax.persistence.PersistenceException: No Persistence provider for EntityManager named pu
    javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
    javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
    jpql.utils.EntityManagerUtil.getInstance(Unknown Source)
    org.apache.jsp.query_jsp._jspService(query_jsp.java:82)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

The persistence provider mentioned in persistence.xml is org.hibernate.ejb.HibernatePersistence, which is there in hibernate3.jar.Is it some error because of tomcat?I am using tomcat 6.0.29

If someone can help me solve this,it would be nice

regards

damon

update:
the build file updated to build the war file correctly ,as Bozho advised

    ...
    <target name="makedirs">    
        <mkdir dir="${dir.build}"/>
        <mkdir dir="${dir.build}/META-INF"/>            
    </target>

    <target name="compile" depends="makedirs" description="Compile all source code">    
        <javac srcdir="${dir.src}" destdir="${dir.build}" includeAntRuntime="false" verbose="yes">    
            <classpath refid="compileclasspath"/>    
        </javac>                
        <copy file="${dir.src}/persistence.xml" todir="${dir.build}/META-INF"/>    
    ...    
</target>

    <target name="war" depends="compile">
        <war destfile="${dir.build}/${webapp.context.name}.war" webxml="${dir.resources}/web.xml">
        <classes dir="${dir.build}">                

        </classes>      
        ...
    </target>
  • 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-05-24T14:03:09+00:00Added an answer on May 24, 2026 at 2:03 pm

    The proper path is WEB-INF/classes/META-INF/persistence.xml – make sure it is there.

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

Sidebar

Related Questions

I am trying to deploy my web app remotely using the tomcat plugin from
I'm trying to deploy a java web app which uses FreeTTS to generate mp3s.
I'm trying to deploy an application on tomcat 7.0.23 (the web app is all
I am trying to deploy my little Catalyst web app using Plack/Starman. All the
I'm trying to deploy an ASP.NET MVC 2 app using MsDeploy. I use VS2010
I am trying to deploy the Bugtracker.NET tool ( http://ifdefined.com/bugtrackernet.html ), which is a
I'm trying to deploy my web app to Azure using this method , but
I'm trying to deploy a node.js app to dotcloud. The instructions are found on
I'm trying to deploy a web service onto WebSphere using a WAR file, which
I have a grails app that I am trying to deploy onto Tomcat. I

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.