0
votes

I am trying conect gwt-spring-hibernate. The problem is the next: When I try to create the bean with name SessionFactory I get this error:

jun 04, 2013 11:13:00 AM org.apache.catalina.core.StandardContext listenerStart SEVERE: Excepción enviando evento inicializado de contexto a instancia de escuchador de clase org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.VerifyError: class org.hibernate.type.WrappedMaterializedBlobType overrides final method getReturnedClass.()Ljava/lang/Class; at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1486) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:589) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) Caused by: java.lang.VerifyError: class org.hibernate.type.WrappedMaterializedBlobType overrides final method getReturnedClass.()Ljava/lang/Class; at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:791) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2904) at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559) at org.hibernate.type.BasicTypeRegistry.(BasicTypeRegistry.java:91) at org.hibernate.type.TypeResolver.(TypeResolver.java:59) at org.hibernate.cfg.Configuration.(Configuration.java:250) at org.hibernate.cfg.Configuration.(Configuration.java:302) at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.(LocalSessionFactoryBuilder.java:104) at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:277) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483) ... 22 more

jun 04, 2013 11:13:00 AM org.apache.catalina.core.StandardContext startInternal SEVERE: Error listenerStart

I was looking for to solve this error, but no way. Everybody say that I have some libraries twice in my proyect, but I didn't find anything.

Pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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">

<!-- POM file generated with GWT webAppCreator -->
<modelVersion>4.0.0</modelVersion>
<groupId>com.pcf</groupId>
<artifactId>lfy</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>GWT Maven Archetype</name>


<properties>
<!-- Convenience property to set the GWT version -->

  <spring.version>3.2.0.RELEASE</spring.version>
</properties>

<dependencies>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-core</artifactId>
  <version>${spring.version}</version>
</dependency>

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-context</artifactId>
  <version>${spring.version}</version>
</dependency>

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-tx</artifactId>
  <version>${spring.version}</version>
</dependency>

<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-orm</artifactId>
   <version>${spring.version}</version>
</dependency>

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>${spring.version}</version>
</dependency>


<dependency>
  <groupId>commons-dbcp</groupId>
  <artifactId>commons-dbcp</artifactId>
  <version>1.2.2</version>
</dependency>

<dependency>
    <groupId>javax.persistence</groupId>
    <artifactId>persistence-api</artifactId>
    <version>1.0</version>
</dependency>

<dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-core</artifactId>
   <version>4.1.9.Final</version>
</dependency>




<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.7</version>
  <scope>test</scope>
</dependency>

</dependencies>

<build>
<!-- Generate compiled stuff in the folder used for developing mode -->
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>

<plugins>

  <!-- GWT Maven Plugin -->
  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>gwt-maven-plugin</artifactId>
    <version>2.5.1</version>
    <executions>
      <execution>
        <goals>
          <goal>compile</goal>
          <goal>test</goal>
          <goal>i18n</goal>
          <goal>generateAsync</goal>
        </goals>
      </execution>
    </executions>
    <!-- Plugin configuration. There are many available options, see 
      gwt-maven-plugin documentation at codehaus.org -->
    <configuration>
      <runTarget>principal.html</runTarget>
      <hostedWebapp>${webappDirectory}</hostedWebapp>
      <i18nMessagesBundle>com.pcf.lfy.client.Messages</i18nMessagesBundle>
    </configuration>
  </plugin>

  <!-- Copy static web files before executing gwt:run -->
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.1.1</version>

    <executions>
      <execution>
        <phase>compile</phase>
        <goals>
          <goal>exploded</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <webappDirectory>${webappDirectory}</webappDirectory>
    </configuration>

  </plugin>


  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
      <source>1.7</source>
      <target>1.7</target>
    </configuration>
  </plugin>
 </plugins>
 </build>

</project>

My applicationContext.xml is the next:

<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:aop="http://www.springframework.org/schema/aop"          
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" 
xmlns:task="http://www.springframework.org/schema/task"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
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/jee http://www.springframework.org/schema/jee/spring-jee-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/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">

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

<!-- <tx:annotation-driven />

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="MyPersistenceUnit" />
 </bean>

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

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
    <property name="url" value="jdbc:mysql://127.0.0.1:3306/pfc;create=true"></property>
    <property name="username" value="xxx" />
    <property name="password" value="xxx" />
</bean>

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource"></property>
    <property name="packagesToScan" value="com.pcf.lfy.shared.dto"></property>

    <property name="hibernateProperties">
        <props>
            <prop key="dialect">org.hibernate.dialect.MySQL5Dialect</prop>
            <prop key="hibernate.show_sql">true</prop>
        </props>
    </property>

</bean>

 <bean id="transactionManager"
    class="org.springframework.orm.hibernate4.HibernateTransactionManager" 
    p:sessionFactory-ref="sessionFactory">
 </bean>

</beans>

That is all. I don't see twice any library and I getting crazy.

Thanks a lot!

2
Could you please post the web.xml - Ralph
Yes sure! I have corrected an error, but all is the same: - Luismiv85
You don't have posted the web.xml - Ralph
I found the web.xml, next time please use the "edit" function to edit your question instead of posting an answer with additional information. - Ralph

2 Answers

0
votes

Everything looks fine (except that I have not found any GWT dependencies in your POM, but I never used it so I can not justify).

If you use eclipse, than open the pom.xml (with exclipse) and switch to the "hirarchy" tab, check that there is no second hibernate dependency.

0
votes

Here you can see mi web.xml

    <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

    <!-- provide hooks for the web application so as to load the Spring context upon startup -->
   <listener>
       <listener-class>
           org.springframework.web.context.ContextLoaderListener
       </listener-class>
   </listener>

  <!-- Servlets -->

  <servlet>
      <servlet-name>springGwtRemoteServiceServlet</servlet-name>
      <servlet-class>org.spring4gwt.server.SpringGwtRemoteServiceServlet</servlet-class>
  </servlet>




   <!--<servlet>
    <servlet-name>greetServlet</servlet-name>
    <servlet-class>com.pcf.lfy.server.GreetingServiceImpl</servlet-class>
  </servlet>-->

  <servlet-mapping>
     <servlet-name>springGwtRemoteServiceServlet</servlet-name>
     <url-pattern>/principal/springGwtServices/*</url-pattern>
  </servlet-mapping>

   <!--<servlet-mapping>
    <servlet-name>greetServlet</servlet-name>
    <url-pattern>/principal/greet</url-pattern>
  </servlet-mapping>-->

  <!-- Default page to serve -->
  <welcome-file-list>
    <welcome-file>principal.html</welcome-file>
  </welcome-file-list>

</web-app>

I have corrected one thing:

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

by

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

but no way...

Thanks for the answer!