Ramar
Ramar

Reputation: 1564

why .NoSuchMethodError: org.springframework.core.convert.converter.ConverterRegistry.addConverter

My maven project uses spring, hibernate. I get "no such method error". I believe it is due to some conflict in version in dependencies but dont know what. The build is successful. But during "NetBeans: Deploying on GlassFish Server 4.0" (i use the run button in Netbeans), i get below error which i have tried hard to eliminate without success. Any assistance is appreciated...

failed on GlassFish Server 4.0 
 Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.NoSuchMethodError: org.springframework.core.convert.converter.ConverterRegistry.addConverter(Ljava/lang/Class;Ljava/lang/Class;Lorg/springframework/core/convert/converter/Converter;)V.

Below i my pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>Spring3HibernateMaven</groupId>
    <artifactId>AttestationSpring3HibernateMaven</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <description></description>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.0</version>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>javax.persistence</groupId>
            <artifactId>persistence-api</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <!-- === -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.2.7.Final</version>
        </dependency>
         <!-- === -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>3.5.6-Final</version>
            <exclusions>
                <exclusion>
                    <artifactId>hibernate-commons-annotations</artifactId>
                    <groupId>org.hibernate</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.2.7.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>5.0.1.Final</version>
        </dependency>

<!-- === -->
       <!-- 
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>3.3.2.GA</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>3.3.1.GA</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.2.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.2.0.Final</version>
            <type>jar</type>
        </dependency>

        -->
        <dependency> 
            <groupId>org.slf4j</groupId> 
            <artifactId>slf4j-log4j12</artifactId> 
            <version>1.4.2</version> 
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.10</version>
        </dependency>
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>20030825.184428</version>
        </dependency>
        <dependency>
            <groupId>commons-pool</groupId>
            <artifactId>commons-pool</artifactId>
            <version>20030825.183949</version>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.1</version>
            <type>jar</type>
        </dependency>
    </dependencies>
    <properties>
        <org.springframework.version>3.2.1.RELEASE
        </org.springframework.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <netbeans.hint.deploy.server>gfv4ee7</netbeans.hint.deploy.server>
    </properties>
    <name>AttestationSpring3HibernateMaven</name>
</project>

Below is my spring-servlet.xml where datasource, sessionfactory configurations are made..

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


<bean id="sessionFactory"
    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">

        <property name="dataSource" ref="dataSource"/>
    <property name="packagesToScan" value="org.attestation.entities" />
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
        </props>

    </property>
        <!--====== 

    <property name="dataSource" ref="dataSource" />
    <property name="configLocation">
        <value>classpath:hibernate.cfg.xml</value>
    </property>
    <property name="configurationClass">
        <value>org.hibernate.cfg.AnnotationConfiguration</value>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">${jdbc.dialect}</prop>
            <prop key="hibernate.show_sql">true</prop>
        </props>
    </property>
            -->
</bean>

<tx:annotation-driven />

<bean id="transactionManager"
    class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>

Upvotes: 1

Views: 17812

Answers (5)

Anwar Panhwar
Anwar Panhwar

Reputation: 1

yes, try to add all the jars of same version , and check whether all jars are added successfully to run Spring code .I also had same problem than i removed the different version jar files and it worked for me!

Upvotes: -1

Steve
Steve

Reputation: 51

Just had one of our junior developers here had a very similar error with a spring boot app. Turns out IntelliJ was messed up, we quit IntelliJ, deleted the ".idea" folder within the project, and re-opened. Things worked just fine after that.

It seems that there must have been some caching that IntelliJ was doing to either store libraries or resolve dependencies. And somehow that cache got corrupted.

I know that the original post mentioned NetBeans (not IntelliJ) but I figured leaving this answer here might help. I don't have enough reputation to comment.

Upvotes: 0

Kaster
Kaster

Reputation: 89

If text file encoding of your project is "Cp1252", change it to "UTF-8".

Upvotes: 0

Ramar
Ramar

Reputation: 1564

The problem originated when i adapted the project from a working maven+spring+hibernate project. In a zealous attempt, i updated the pom.xml with all the latest versions of dependencies which i think led to the problem. But why it leads to problem, i am not sure. But for now, i have reverted to the original working (but older) versions of dependencies in pom.xml and everything has started working fine. Thanks for your assistance & efforts.

Upvotes: 3

Gerard Ribas
Gerard Ribas

Reputation: 727

Check if all jars of Spring Framework has the same version. I had this problem before and it occurs because one dependency of spring framework was in other version number.

You can check the conflicts using maven console:

mvn dependency:tree -Dverbose

Upvotes: 5

Related Questions