Using spring-data-cassandra and spring-data-rest-webmvc

646 views
Skip to first unread message

Jega A

unread,
May 12, 2014, 10:45:18 AM5/12/14
to spring-dat...@googlegroups.com
Hi
I am working on a POC that involves basic CRUD in Cassandra and also some integration to Sorl.
I am trying to use spring-data-cassandra along with spring-data-rest-webmvc. This way I can make the Cassandra operations available as REST services.
I am using Java 1.7

When I try to use these together I get the following runt time error:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'repositoryExporterHandlerAdapter' defined in class org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.springframework.data.util.ClassTypeInformation.from(Ljava/lang/Class;)Lorg/springframework/data/util/TypeInformation;

Seems to me like there is some mismatch of libraries used by spring-data-cassandra and spring-data-rest-webmvc.
If I remove references to spring-data-cassandra then the error goes away so I am suspecting that there is some conflict in the libraries used by these two packages.

To reproduce the problem I simplified the project. Here is the Java file (the conflict arises when I add @EnableCassandraRepositories and @Import(RepositoryRestMvcConfiguration.class) together.

=====

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories;
import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration;



@Configuration
@EnableCassandraRepositories
@Import(RepositoryRestMvcConfiguration.class)
@EnableAutoConfiguration
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

}

==============
Here is the pom.xml file

============

<?xml version="1.0" encoding="UTF-8"?>
    <modelVersion>4.0.0</modelVersion>

    <groupId>cass-test3</groupId>
    <artifactId>cass-test3</artifactId>
    <version>1.0-SNAPSHOT</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.0.2.RELEASE</version>
    </parent>

    <repositories>
        <repository>
            <id>spring-libs-snapshot</id>
            <url>http://repo.spring.io/libs-snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>

        <repository>
            <id>spring-milestones</id>
            <url>http://repo.spring.io/libs-snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-cassandra</artifactId>
            <version>1.0.0.BUILD-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-rest-webmvc</artifactId>
        </dependency>
    </dependencies>


</project>
====

Here is the full stack trace

==
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'repositoryExporterHandlerAdapter' defined in class org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.springframework.data.util.ClassTypeInformation.from(Ljava/lang/Class;)Lorg/springframework/data/util/TypeInformation;
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:648)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:311)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:909)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:898)
at Application.main(Application.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.NoSuchMethodError: org.springframework.data.util.ClassTypeInformation.from(Ljava/lang/Class;)Lorg/springframework/data/util/TypeInformation;
at org.springframework.data.rest.webmvc.ResourceProcessorHandlerMethodReturnValueHandler.<clinit>(ResourceProcessorHandlerMethodReturnValueHandler.java:52)
at org.springframework.data.rest.webmvc.ResourceProcessorInvokingHandlerAdapter.afterPropertiesSet(ResourceProcessorInvokingHandlerAdapter.java:75)
at org.springframework.data.rest.webmvc.RepositoryRestHandlerAdapter.afterPropertiesSet(RepositoryRestHandlerAdapter.java:45)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
... 20 more



==
 

Thanks for any help in helping me solve this one.

Jega

Jega A

unread,
May 12, 2014, 1:12:53 PM5/12/14
to spring-dat...@googlegroups.com
With a little more digging with mvn dependency:tree I found the following differences

+- org.springframework.data:spring-data-cassandra:jar:1.0.0.BUILD-SNAPSHOT:compile
|  +- org.springframework.data:spring-data-commons:jar:1.8.0.BUILD-SNAPSHOT:compile

+- org.springframework.data:spring-data-rest-webmvc:jar:2.0.2.RELEASE:compile
|  |  +- org.springframework.data:spring-data-commons:jar:1.7.2.RELEASE:compile

Looks like the spring-data-commons.jar used by spring-data-cassandra and spring-data-rest-webmvc are different. That may be why this error could be occuring.
Any ideas on how this can be addressed?

Thanks
Jega

David Webb (Prowave)

unread,
May 12, 2014, 1:37:16 PM5/12/14
to Jega A, spring-dat...@googlegroups.com

Please see this on the upcoming release train where everything is dependent on SDCommons 1.8.0.

 

https://github.com/spring-projects/spring-data-commons/wiki/Release-Train-Dijkstra

 

I think you should switch you SDC* version to 1.0.0.RC1 and change your SDRest version to 2.1.0.RC1 to resolve this.

 

Then, then SDC* hits the first RELEASE status, you will be using both the latest versions of both Spring Data modules.

 

HTH.

 

Dave

--
You received this message because you are subscribed to the Google Groups "Spring Data Cassandra" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spring-data-cass...@googlegroups.com.
To post to this group, send email to spring-dat...@googlegroups.com.
Visit this group at http://groups.google.com/group/spring-data-cassandra.
To view this discussion on the web visit https://groups.google.com/d/msgid/spring-data-cassandra/7f46528b-9162-44da-bbcd-7878c75d98b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jega A

unread,
May 12, 2014, 5:28:23 PM5/12/14
to David Webb (Prowave), spring-dat...@googlegroups.com
Thanks for all your very prompt help.

I changed the pom.xml to reflect the versions that David recommended. Now the problem with mismatched commons  seems to have gone away. I am seeing some other exception (that I will need to narrow down).
Now my pom.xml looks like the following:

===
<?xml version="1.0" encoding="UTF-8"?>
    <modelVersion>4.0.0</modelVersion>

    <groupId>cass-test3</groupId>
    <artifactId>cass-test3</artifactId>
    <version>1.0-SNAPSHOT</version>


    <!-- need to include spring-boot-starter-web that is in dependencies below-->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.0.2.RELEASE</version>
        
        
    </parent>

    <repositories>

        <repository>
            <id>spring-libs-snapshot</id>
            <url>http://repo.spring.io/libs-snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>


        </repository>


        <repository>
            <id>spring-milestones</id>
            <url>http://repo.spring.io/libs-snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>

    </repositories>

    <dependencies>

        
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-rest-webmvc</artifactId>
            <version>2.1.0.RC1</version>

        </dependency>


        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-cassandra</artifactId>
            <version>1.0.0.RC1</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>


    </dependencies>


</project>
===

Jega

--
Jega

Oliver Gierke

unread,
May 13, 2014, 5:12:43 PM5/13/14
to spring-dat...@googlegroups.com, David Webb (Prowave)
If you're using Spring Boot, using the dependency tag for SD REST doesn't really help as it works with the dependencyManagement tags to enforce versions. Try to set this property:

<spring-data-rest.version>2.1.0.RC1</spring-data-rest.version>

If that still fails, please post the output of mvn dependency:tree.

Cheers,
Ollie
To unsubscribe from this group and stop receiving emails from it, send an email to spring-data-cassandra+unsub...@googlegroups.com.



--
Jega
Reply all
Reply to author
Forward
0 new messages