1
votes

I am creating a web application (MVC) using Spring, Hibernate, and I receive the error when I run it on server (Glassfish v4.1 is used). Below is the error:

cannot Deploy project1 deploy is failing=Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'dataSource1' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dataSource1' is defined. Please see server.log for more details.

How can I fix the this error? Thanks in advance.

This is 'applicationContext.xml' file:

http://i.stack.imgur.com/ZuzHR.jpg

This is 'persistence.xml' file:

http://i.stack.imgur.com/7LLAH.jpg

1
The error seems quite clear... No bean named 'dataSource1' is defined. You are referencing a datasource that doesn't exist.M. Deinum
I have added 2 files of 'applicationContent.xml' & 'persistence.xml'. Where can I go to fix the error? Thanks. Sorry, I am a beginner.7d0
Add it as content to your post, not as links. But read the stacktrace and figure out which bean you need to reference. I suspect it is a bean named dataSource.M. Deinum

1 Answers

0
votes

Like @M. Deinum has commented, you need to ensure you have defined a bean with the name "dataSource1" and of type javax.sql.DataSource similar to this:

<bean id="dataSource" class="oracle.jdbc.pool.OracleDataSource">  
    <property name="URL" value="${url}" />  
    <property name="user" value="${username}"/>  
    <property name="password" value="${password}"/>   
  </property>  
</bean>