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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:04:07+00:00 2026-05-27T14:04:07+00:00

I have a web application that uses spring and hibernate for JPA support, but

  • 0

I have a web application that uses spring and hibernate for JPA support, but when I open my Index page this exception happens:

http://pastebin.com/0X1GG9GQ

But I think my applicationContext.xml is well configured, but I’m posting it anyways just to be sure:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.0.xsd
           http://www.springframework.org/schema/tx
           http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
           http://www.springframework.org/schema/aop
           http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
            ">

    <!-- properties file for jdbc database access details / -->
    <context:property-placeholder location="classpath:jdbc.properties" />

    <!-- enabling annotation driven configuration / -->
    <context:annotation-config />

    <context:component-scan base-package="com.maegul" />

    <tx:annotation-driven transaction-manager="transactionManager" />
    <bean
        class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />

    <bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource"
        p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}"
        p:username="${jdbc.username}" p:password="${jdbc.password}" />


    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
        p:entityManagerFactory-ref="entityManagerFactory" />

    <bean id="entityManagerFactory"
        class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
        p:dataSource-ref="dataSource" p:jpaVendorAdapter-ref="jpaAdapter">
        <property name="loadTimeWeaver">
            <bean
                class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
        </property>
        <property name="persistenceUnitName" value="maegul"></property>
    </bean>

    <bean id="jpaAdapter"
        class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
        p:database="${jpa.database}" p:showSql="${jpa.showSql}" />

</beans>

I really don’t know what’s wrong, I’ve been changing little things to no avail, any help would be greatly appreciated.

EDIT (Long Stack in pastebin for easier reading…)

Changed some things in the ApplicationContext.xml and now I get a different stack trace:

INFO  - Server                     - jetty-7.5.0.v20110901
INFO  - tandardDescriptorProcessor - NO JSP Support for {}, did not find {}
INFO  - /                          - Initializing Spring root WebApplicationContext
INFO  - ContextLoader              - Root WebApplicationContext: initialization started
INFO  - XmlWebApplicationContext   - Refreshing Root WebApplicationContext: startup date [Sun Nov 06 13:22:53 COT 2011]; root of context hierarchy
INFO  - XmlBeanDefinitionReader    - Loading XML bean definitions from ServletContext resource [/WEB-INF/ApplicationContext.xml]
INFO  - DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@40871449: defining beans [maegulApplication,itemService,userService,cartItemDao,mediaItemDao,mediaSourceDao,passwordDao,userDao,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor]; root of factory hierarchy
INFO  - DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@40871449: defining beans [maegulApplication,itemService,userService,cartItemDao,mediaItemDao,mediaSourceDao,passwordDao,userDao,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor]; root of factory hierarchy
ERROR - ContextLoader              - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'itemService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.maegul.data.dao.impl.MediaItemDao com.maegul.service.implementation.ItemFindService.mediaItemDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mediaItemDao': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but found 0

Rest of stack here: http://pastebin.com/u82n3C5n

I see that the Annotations I made are getting recognized, but it looks like it can’t still find an entityManagerFactory. One thing I’ve seen is that maybe instead of using @PersistenceContext should I use @PersistenceUnit in my EntityManager fields, but I dont know…

EDIT 2

All my DAO implementations look like this:

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.springframework.stereotype.Repository;

import com.maegul.data.dao.AbstractDAO;
import com.maegul.data.entities.MediaItem;

@Repository(value = "mediaItemDao")
public class MediaItemDaoImpl extends AbstractDAO<MediaItem> implements
        MediaItemDao {

    @PersistenceContext
    private EntityManager em;

    /*
     * (non-Javadoc)
     * 
     * @see com.maegul.data.dao.DAO#getEntityManager()
     */
    public EntityManager getEntityManager() {
        return em;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.maegul.data.dao.DAO#getClazz()
     */
    public Class<MediaItem> getClazz() {
        return MediaItem.class;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.maegul.data.dao.impl.MediaItemDao#findByName(java.lang.String)
     */
    public MediaItem findByName(String name) {
        Query q = getEntityManager().createQuery(
                "select u from " + getClazz() + " where u.name = :name");
        q.setParameter("name", name);

        return (MediaItem) q.getSingleResult();
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.maegul.data.dao.impl.MediaItemDao#findByType(java.lang.String)
     */
    @SuppressWarnings("unchecked")
    public List<MediaItem> findByType(String type) {
        Query q = getEntityManager().createQuery("select u from " + getClazz() + " where u.type = :type");
        q.setParameter("type", type);

        return q.getResultList();
    }
}

EDIT 3

This is the AbstractDAO class: http://pastebin.com/f2BQG9RE

And this is the DAO interface, which is implemented by AbstractDAO: http://pastebin.com/h7dAHTTC

and this is the Interface MEdiaItemDao:

import java.util.List;

import com.maegul.data.dao.DAO;
import com.maegul.data.entities.MediaItem;

public interface MediaItemDao extends DAO<MediaItem>{

    MediaItem findByName(String name);

    List<MediaItem> findByType(String type);
}
  • 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-27T14:04:10+00:00Added an answer on May 27, 2026 at 2:04 pm

    It only needed a project clean, so I did and it fixed it.

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

Sidebar

Related Questions

We have a Java web application that uses Spring and Hibernate and has a
My colleague and I have a web application that uses Spring 3.0.0 and JPA
I have a web application that uses a library which resides in TOMCAT_HOME/common/lib. This
I have a Spring application that uses JAX-WS to consume another web service. Everything
We have a web application which uses Struts 2, Spring and Hibernate. Currently a
I have an application built on Spring MVC that uses Hibernate for all of
I have a web application that uses Struts2 + Spring for the resource injection,
I'm building a new web application that uses Linux, Apache, Tomcat, Wicket, JPA/Hibernate, and
I have a web application written in JSF2 that uses Spring. I need to
I have an application which uses Spring 2.5 and Hibernate 3. There's a web

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.