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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:16:06+00:00 2026-06-14T07:16:06+00:00

In Eclipse I made a project with DAO and it was working fine. I

  • 0

In Eclipse I made a project with DAO and it was working fine. I then I made a new JPA project and added it in the Deployment Assembly of the initial project. I than converted one DAO to work with JPA and put it in the JPA project. When i tested the application it gave an Java error NoClassDefFoundError (see bottom). I have no idea why. I have checked everywhere but i can’t find the error. The JPA is called in the servlet:

package eshop;
....
import model.ProductModelDAO;
import model.ProductModelDAOImpl;


ProductModelDAO dao4 = new ProductModelDAOImpl("Product");
ArrayList products = dao4.getProductsByCategory(categoryId);

Then in the JPA project I have Product.java which is generated from the “products” table. I have the persistence.xml. And i have the two original DAO’s:

package model;

import java.util.*;

public interface ProductModelDAO {  
public ArrayList searchProducts(String keyword);
public ArrayList getProductsByCategory(String categoryId);
public Product getProductById(String productID);
}

and:

package model;

import java.util.ArrayList;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.PersistenceContext;


public class ProductModelDAOImpl implements ProductModelDAO {

@PersistenceContext
private EntityManager em;

// this is the default constructor
public ProductModelDAOImpl()
{
this("Product");
}

  public ProductModelDAOImpl(String unitName)
  {
    EntityManagerFactory emf = Persistence.createEntityManagerFactory(unitName);
    em = emf.createEntityManager();
  }

  // this is the special constructor to set the entity manager.
  // this is used when we run with EJB3
  public ProductModelDAOImpl(EntityManager em)
  {
    this.em = em;
  }

  public void setEntityManager(EntityManager em)
  {
    this.em = em;
  }


@Override
public ArrayList<Product> searchProducts(String keyword) {
    @SuppressWarnings("unchecked")
    ArrayList<Product> results = (ArrayList<Product>)
      em.createQuery("select A from products A where (A.product_name = ?1 or A.descr = ?1)")
          .setParameter(1, keyword)
          .getResultList();
    return results; 
}

@Override
public ArrayList <Product> getProductsByCategory(String categoryId) {
    @SuppressWarnings("unchecked")
    ArrayList<Product> results = (ArrayList<Product>)
            em.createQuery("select A from products A where A.category_id = ?1")
              .setParameter(1, categoryId)
              .getResultList();
        return results; 
}

@Override
public Product getProductById(String productID) {
    Product results = 
    (Product) em.createQuery("select A from products A where A.product_id = ?1")
      .setParameter(1, productID)
      .getResultList();
    return results; 

}

}

The persistence xml is the following:

<?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="abook">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<class>model.Product</class>
<properties>
<property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver" />
<property name="openjpa.ConnectionURL" value="jdbc:mysql://localhost:3306/shop" />
<property name="openjpa.ConnectionUserName" value="root" />
<property name="openjpa.ConnectionPassword" value="" />
<property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO" />
</properties>
</persistence-unit>
</persistence>

The error is the following

java.lang.NoClassDefFoundError: model/ProductModelDAOImpl
at eshop.Servlet.doPost(Servlet.java:112)
at eshop.Servlet.doGet(Servlet.java:57)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:183)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.doIt(WebAppServletContext.java:3686)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3650)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2268)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2174)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1446)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
  • 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-14T07:16:07+00:00Added an answer on June 14, 2026 at 7:16 am

    NoClassDefFoundError in Java comes when Java Virtual Machine is not able to find a particular class at runtime which was available during compile time. See if ProductModelDAOImpl is available in the web-app classpath.

    Read more here

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

Sidebar

Related Questions

Yesterday I made a project in eclipse, and it was working, compiling. I used
I just downloaded eclipse and made a new c project. This is my code:
I made a new project using Eclipse (API level 14, BlankActivity, Tabs+Swipe.) The entire
I have made a new project in a clean eclipse installation and imported a
I made an android project using eclipse. It looks like: src/ ActivityMain.java lib/ Square.java
Eclipse was working fine just a day ago. But today, when I click the
here I uploaded my Android project made in Eclipse. The idea is that i
I made Android project on Windows 7 using Android SDK and Eclipse. After moving
I have just started learning CXF. I made a maven archetype project through eclipse.
I made simple maven project and I opened it with Eclipse. I have installed

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.