0
votes

I'm working on a spring-data-neo4j project ,and this project is developed by java ,but I want to change to grails for its productivity.I copy the following applicationContext.xml content into grails applicationContext.xml:

    <!--Custom Configuration-->
    <context:annotation-config/>
    <context:spring-configured/>
<!--    <context:component-scan base-package="com.turingmac">
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
    </context:component-scan>-->

    <!-- Neo4j configuration (creates Neo4jTemplate) -->
    <neo4j:config graphDatabaseService="graphDatabaseService"/>
    <bean id="graphDatabaseService" class="org.springframework.data.neo4j.rest.SpringRestGraphDatabase" scope="singleton">
        <constructor-arg index="0" value="http://localhost:7474/db/data"/>
    </bean>

    <neo4j:repositories base-package="com.turingmac.repository"/>
    <tx:annotation-driven mode="proxy"/>

but i got this error:

ERROR context.GrailsContextLoader - Error executing bootstraps: Error creating bean with name 'org.springframework.data.neo4j.config.Neo4jConfiguration#0': Cannot resolve reference to bean 'graphDatabaseService' while setting bean property 'graphDatabaseService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'graphDatabaseService' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.data.neo4j.rest.SpringRestGraphDatabase]: Constructor threw exception; nested exception is java.lang.ClassCastException: com.sun.proxy.$Proxy31 cannot be cast to javax.ws.rs.Produces Message: Error creating bean with name 'org.springframework.data.neo4j.config.Neo4jConfiguration#0': Cannot resolve reference to bean 'graphDatabaseService' while setting bean property 'graphDatabaseService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'graphDatabaseService' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.data.neo4j.rest.SpringRestGraphDatabase]: Constructor threw exception; nested exception is java.lang.ClassCastException: com.sun.proxy.$Proxy31 cannot be cast to javax.ws.rs.Produces Caused by BeanInstantiationException: Could not instantiate bean class [org.springframework.data.neo4j.rest.SpringRestGraphDatabase]: Constructor threw exception; nested exception is java.lang.ClassCastException: com.sun.proxy.$Proxy31 cannot be cast to javax.ws.rs.Produces Caused by ClassCastException: com.sun.proxy.$Proxy31 cannot be cast to javax.ws.rs.Produces

and I tried a lot of methods ,e.g. upgrading springframework version ,adding extra jars,it does't work.

1

1 Answers

1
votes

Every now and then I happen to stumble across this exception, and usually I delete the folder. slcache as per http://jira.grails.org/browse/GRAILS-9952 and https://stackoverflow.com/a/15954077/757413