Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Deploying wab with persistence.xml(Caused by: java.lang.IllegalArgumentException: No persistence unit with name 'hibernatePersistenceUnit' found)
Deploying wab with persistence.xml [message #898775] Fri, 27 July 2012 14:11 Go to next message
Sebastián Seifert is currently offline Sebastián SeifertFriend
Messages: 8
Registered: March 2012
Junior Member
Hi again!

I have been fighting with this for several days. The title is pretty descriptive so I will post the code needed and console output.

This is my persistence-context.xml

<?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:p="http ://www.springframework.org/schema/p"
        xmlns:tx="http ://www.springframework.org/schema/tx"
        xmlns:context="http ://www.springframework.org/schema/context"
        xmlns:jdbc="http ://www.springframework.org/schema/jdbc"
        xmlns:jpa="http ://www.springframework.org/schema/data/jpa"
        xmlns:util="http ://www.springframework.org/schema/util"
        xsi:schemaLocation="
			http ://www.springframework.org/schema/beans
			http ://www.springframework.org/schema/beans/spring-beans-3.1.xsd
			http ://www.springframework.org/schema/tx
			http ://www.springframework.org/schema/tx/spring-tx-3.1.xsd
			http ://www.springframework.org/schema/context
			http ://www.springframework.org/schema/context/spring-context-3.1.xsd
			http ://www.springframework.org/schema/jdbc
			http ://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
			http ://www.springframework.org/schema/data/jpa
			http ://www.springframework.org/schema/data/jpa/spring-jpa.xsd
			http ://www.springframework.org/schema/util
			http ://www.springframework.org/schema/util/spring-util-3.1.xsd">

	<context:property-placeholder properties-ref="deployProperties" />

	<tx:annotation-driven transaction-manager="transactionManager" />

	<!-- Activate Spring Data JPA repository support -->
	<jpa:repositories base-package="por.arg.sarcoo.repository" />
  
	<!-- Declare a datasource that has pooling capabilities-->
	<bean id="jpaDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
		destroy-method="close"
		p:driverClass="${app.jdbc.driverClassName}"
		p:jdbcUrl="${app.jdbc.url}"
		p:user="${app.jdbc.username}"
		p:password="${app.jdbc.password}"
		p:acquireIncrement="5"
		p:idleConnectionTestPeriod="60"
		p:maxPoolSize="100"
		p:maxStatements="50"
		p:minPoolSize="10" />
	
	<!-- Declare a JPA entityManagerFactory -->
	<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
		p:persistenceXmlLocation="classpath*:META-INF/persistence.xml"
		p:persistenceUnitName="hibernatePersistenceUnit"
		p:dataSource-ref="jpaDataSource"
		p:jpaVendorAdapter-ref="hibernateVendor"/>
		
	<!-- Specify our ORM vendor -->
	<bean id="hibernateVendor" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
		p:showSql="false"/>

	<!-- Declare a transaction manager-->
	<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
		p:entityManagerFactory-ref="entityManagerFactory"/>
		
	<bean class="org.springframework.orm.hibernate4.HibernateExceptionTranslator"/>
		
</beans>


Here is my persitence.xml

<persistence 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_2_0.xsd"
             version="2.0">

	<persistence-unit name="hibernatePersistenceUnit">
		<mapping-file>META-INF/orm.xml</mapping-file>
		<properties>
			<property name="hibernate.hbm2ddl.auto" value="update" />
			<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
		</properties>
   </persistence-unit>

</persistence>


And my pom.xml

<project xmlns="http ://maven.apache.org/POM/4.0.0" xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http ://maven.apache.org/POM/4.0.0 http ://maven.apache.org/maven-v4_0_0.xsd">
  
  <modelVersion>4.0.0</modelVersion>
  
  <groupId>pop.arg.sarcoo</groupId>
  <artifactId>pop.arg.sarcoo.web</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>pop.arg.sarcoo.web</name>
  
  <properties>
    <spring.version>3.1.1.RELEASE</spring.version>
    <spring.security.version>3.1.0.RELEASE</spring.security.version>
    <spring.data.version>1.0.0.RELEASE</spring.data.version>
    <spring.fasterxml.version>0.5.4</spring.fasterxml.version>
    <virgo.version>3.5.0.M03</virgo.version>
    <javax.version>3.0.0.v201103241009</javax.version>
    <javax.persistence.version>2.0.0</javax.persistence.version>
    <javax.annotation.version>1.0.0</javax.annotation.version>
    <javax.validation.version>1.0.0.GA</javax.validation.version>
    <hibernate.ejb.version>4.1.0.Final</hibernate.ejb.version>
    <mchange.version>0.9.1.2</mchange.version>
    <jboss.jandex.version>1.0.3.Final</jboss.jandex.version>
    <maven.bundle.plugin.version>2.3.7</maven.bundle.plugin.version>
  </properties>
  
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
	  <groupId>javax.servlet</groupId>
	  <artifactId>javax.servlet</artifactId>
	  <version>${javax.version}</version>	
	</dependency>
	<dependency> 
	  <groupId>javax.persistence</groupId>
	  <artifactId>com.springsource.javax.persistence</artifactId> 
	  <version>${javax.persistence.version}</version> 
	</dependency>
	<dependency> 
	  <groupId>javax.validation</groupId> 
	  <artifactId>com.springsource.javax.validation</artifactId> 
	  <version>${javax.validation.version}</version> 
	</dependency>
	<dependency> 
	  <groupId>org.jboss</groupId> 
	  <artifactId>com.springsource.org.jboss.jandex</artifactId> 
	  <version>${jboss.jandex.version}</version> 
	</dependency>
	<dependency> 
	  <groupId>javax.annotation</groupId> 
	  <artifactId>com.springsource.javax.annotation</artifactId> 
	  <version>${javax.annotation.version}</version> 
	</dependency>
    <dependency>
      <groupId>org.springframework</groupId>
	  <artifactId>org.springframework.spring-library</artifactId>
	  <type>libd</type>
	  <version>${spring.version}</version>
	  <scope>provided</scope>
	</dependency>
	<dependency> 
	  <groupId>org.springframework.security</groupId>
	  <artifactId>org.springframework.security.core</artifactId> 
	  <version>${spring.security.version}</version> 
	</dependency>
	<dependency> 
	  <groupId>org.springframework.security</groupId> 
	  <artifactId>org.springframework.security.web</artifactId> 
	  <version>${spring.security.version}</version> 
	</dependency>
	<dependency>
	  <groupId>org.springframework.security</groupId>
	  <artifactId>org.springframework.security.config</artifactId>
      <version>${spring.security.version}</version>
	</dependency>
	<dependency>
      <groupId>org.springframework.data</groupId>
      <artifactId>spring-data-jpa</artifactId>
      <version>${spring.data.version}</version>
	</dependency>
	<dependency> 
	  <groupId>com.fasterxml</groupId> 
	  <artifactId>com.springsource.com.fasterxml.classmate</artifactId> 
	  <version>${spring.fasterxml.version}</version> 
	</dependency>
	<dependency> 
	  <groupId>org.hibernate</groupId> 
	  <artifactId>com.springsource.org.hibernate.ejb</artifactId>
	  <version>${hibernate.ejb.version}</version>
	</dependency>
	<dependency> 
	  <groupId>org.hibernate</groupId> 
	  <artifactId>com.springsource.org.hibernate</artifactId>
	  <version>${hibernate.ejb.version}</version>
	</dependency>
	<dependency> 
	  <groupId>com.mchange.c3p0</groupId> 
	  <artifactId>com.springsource.com.mchange.v2.c3p0</artifactId> 
	  <version>${mchange.version}</version> 
	</dependency>          
  </dependencies>
  
  
  <repositories>
    <repository>
      <id>com.springsource.repository.libraries.release</id>
      <name>SpringSource Enterprise Bundle Repository - SpringSource Library Releases</name> 
      <url>http ://repository.springsource.com/maven/libraries/release</url>
    </repository>
    <repository> 
      <id>com.springsource.repository.libraries.external</id> 
      <name>SpringSource Enterprise Bundle Repository - External Library Releases</name> 
      <url>http ://repository.springsource.com/maven/libraries/external</url> 
    </repository>
    <repository> 
      <id>com.springsource.repository.bundles.release</id> 
      <name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name> 
      <url>http ://repository.springsource.com/maven/bundles/release</url> 
    </repository> 
    <repository> 
      <id>com.springsource.repository.bundles.external</id> 
      <name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name> 
      <url>http ://repository.springsource.com/maven/bundles/external</url>
    </repository> 
  </repositories>
  
  <build>
    <finalName>pop.arg.sarcoo.web</finalName>
    
    <plugins>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <archive>
            <!-- add the generated manifest to the war -->
            <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
          </archive>
        </configuration>
      </plugin>
      <plugin>
    	<groupId>org.apache.felix</groupId>
    	<artifactId>maven-bundle-plugin</artifactId>
    	<version>${maven.bundle.plugin.version}</version>
        <extensions>true</extensions>
        <executions>
          <execution>
            <id>bundle-manifest</id>
            <phase>process-classes</phase>
            <goals>
              <goal>manifest</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <supportedProjectTypes>
            <supportedProjectType>jar</supportedProjectType>
            <supportedProjectType>bundle</supportedProjectType>
            <supportedProjectType>war</supportedProjectType>
          </supportedProjectTypes>
          <instructions>
            <_wab>src/main/webapp</_wab>
            <Bundle-Version>1.0.1-SNAPSHOT</Bundle-Version>
			<Web-ContextPath>/sarcoo</Web-ContextPath>
			<Meta-Persistence>/META-INF/persistence.xml</Meta-Persistence>
			<Import-Package>
			  *,
			  javax.servlet,
			  org.springframework.context,
			  org.springframework.context.config,
			  org.springframework.web.context,
			  org.springframework.web.filter,
			  org.springframework.web.servlet,
			  org.springframework.web.servlet.view,
			  org.springframework.beans.factory.xml,
			  org.springframework.beans.factory.config,
			  org.springframework.orm.jpa,
			  org.springframework.orm.jpa.vendor,
			  org.springframework.orm.hibernate4,
			  org.springframework.data.repository.core.support,
			  org.hibernate,
			  org.hibernate.ejb,
			  org.eclipse.virgo.web.dm;version=${virgo.version},
			  com.mchange.v2.c3p0
			</Import-Package>
			<Import-Bundle>
			  org.springframework.security.web;version=${spring.security.version},
			  org.springframework.security.core;version=${spring.security.version},
			  org.springframework.security.config;version=${spring.security.version}
			</Import-Bundle>
          </instructions>
        </configuration>
      </plugin>
      
      <plugin>
		<groupId>net.flybyte.virgo</groupId>
		<artifactId>virgo-maven-plugin</artifactId>
		<version>1.0.1-SNAPSHOT</version>
		<configuration>
		  <virgoRoot>${env.VIRGO_HOME}</virgoRoot>
		</configuration>
	  </plugin>
	</plugins>

 </build>

</project>



The resulting bundle pop.arg.sarcoo.web.war, with persistence.xml and orm.xml in /WEB-INF/classes/META-INF/.

The stacktrace:

[2012-07-26 17:01:31.989] ERROR start-signalling-4           o.a.catalina.core.ContainerBase.[Catalina].[localhost].[/sarcoo]  Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/persistence-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No persistence unit with name 'hibernatePersistenceUnit' found
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1097)
	at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.registerBeanPostProcessors(AbstractDelegatedExecutionApplicationContext.java:502)
	at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.registerBeanPostProcessors(AbstractDelegatedExecutionApplicationContext.java:451)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:449)
	at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.access$301(AbstractDelegatedExecutionApplicationContext.java:60)
	at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext$1.run(AbstractDelegatedExecutionApplicationContext.java:168)
	at org.eclipse.gemini.blueprint.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
	at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.normalRefresh(AbstractDelegatedExecutionApplicationContext.java:164)
	at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext$NoDependenciesWaitRefreshExecutor.refresh(AbstractDelegatedExecutionApplicationContext.java:78)
	at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:157)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
	at org.eclipse.gemini.web.tomcat.internal.TomcatServletContainer.startWebApplication(TomcatServletContainer.java:124)
	at org.eclipse.gemini.web.internal.StandardWebApplication.start(StandardWebApplication.java:95)
	at org.eclipse.virgo.web.core.internal.WebBundleLifecycleListener.onStarted(WebBundleLifecycleListener.java:122)
	at org.eclipse.virgo.kernel.install.artifact.internal.StandardArtifactStateMonitor.onStarted(StandardArtifactStateMonitor.java:271)
	at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact.asyncStartSucceeded(AbstractInstallArtifact.java:319)
	at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact.access$0(AbstractInstallArtifact.java:316)
	at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact$StateMonitorSignal.signalSuccessfulCompletion(AbstractInstallArtifact.java:252)
	at org.eclipse.virgo.kernel.core.internal.BundleStartTracker$1.run(BundleStartTracker.java:140)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:680)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/persistence-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No persistence unit with name 'hibernatePersistenceUnit' found
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:400)
	at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:275)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:139)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.<init>(PersistenceExceptionTranslationInterceptor.java:79)
	at org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.<init>(PersistenceExceptionTranslationAdvisor.java:70)
	at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:103)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1475)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1443)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	... 35 common frames omitted
Caused by: java.lang.IllegalArgumentException: No persistence unit with name 'hibernatePersistenceUnit' found
	at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.obtainPersistenceUnitInfo(DefaultPersistenceUnitManager.java:535)
	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.determinePersistenceUnitInfo(LocalContainerEntityManagerFactoryBean.java:287)
	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:239)
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
	... 50 common frames omitted



Please HELP!!! hahahaha, I´m getting crazy with this.

Another question:

Is there a way to get everything from this post to a mail or RSS? I would like to see new questions and try to help too. If not I´ll have to look at this page every day.

THANKS!
Re: Deploying wab with persistence.xml [message #926118 is a reply to message #898775] Fri, 28 September 2012 10:09 Go to previous message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
I can't solve your persistence problem, but you can subscribe to the whole Virgo forum here or you can subscribe to individual threads when viewing the threads. Should be pretty easy to find... Wink
Previous Topic:Eclipse Virgo's auto deploy takes long time when many files
Next Topic:Virgo 3.6.0.M01 Released
Goto Forum:
  


Current Time: Fri Dec 19 13:06:23 GMT 2014

Powered by FUDForum. Page generated in 0.01732 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software