Hi experts,
I'm trying to build my first small application and getting errors. Its
my first programming-project since 3 years and now I have to learn
neo4j, spring and maven :-)
I'm using Neo4J Server and want to access via REST. This works fine -
i tested it with the jersey-api-client. I think that there is a
problem with my pom.xml.
I would be so thankful for help. I'm spending now 2 days on that
problem. Thank you in advance!
You find my error-message and the end of the discussion.
This is my Class with main-function:
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
final FileSystemXmlApplicationContext ctx = new
FileSystemXmlApplicationContext("src/config/applicationContext.xml");
}
}
This is the applicationContext.xml:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans
xmlns="
http://www.springframework.org/schema/beans"
xmlns:context="
http://www.springframework.org/schema/context"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xmlns:neo4j="
http://www.springframework.org/schema/data/neo4j"
xmlns:tx="
http://www.springframework.org/schema/tx"
xsi:schemaLocation="
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/data/neo4j
http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<context:annotation-config/>
<context:component-scan base-package="com.project.app">
<context:exclude-filter type="annotation"
expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<!-- REST Connection to Neo4j server -->
<bean id="graphDatabaseService"
class="org.springframework.data.neo4j.rest.SpringRestGraphDatabase">
<constructor-arg value="http://192.168.178.42:7474/db/data"/>
</bean>
<!-- Neo4j configuration (creates Neo4jTemplate) -->
<neo4j:config storeDirectory="graphDatabaseService"/>
<!-- Package w/ automagic repositories -->
<neo4j:repositories base-package="repo"/>
<bean id="BENU" class="controller.UserController"></bean>
</beans>
My Controller:
public class UserController {
@Autowired
private UserRepository benu;
public void speicherBenutzer(){
User b = new User("123","Peter");
benu.save(b);
}
}
My Repository:
public interface UserRepository extends GraphRepository<User> {
}
My User:
@NodeEntity
public class User {
@GraphId Long id;
@Indexed private String login;
private String fullName;
private Date lastLogin;
@RelatedTo(type = "knows", direction = Direction.OUTGOING)
Set<User> friends;
public User() {}
public User(String login, String fullName) {
this.login = login;
this.fullName = fullName;
this.lastLogin = new Date();
this.friends = new HashSet<User>();
}
public void knows(User user) {
friends.add(user);
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public Date getLastLogin() {
return lastLogin;
}
public void setLastLogin(Date lastLogin) {
this.lastLogin = lastLogin;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public Set<User> getFriends() {
return friends;
}
public void setFriends(Set<User> friends) {
this.friends = friends;
}
public void setId(Long id) {
this.id = id;
}
}
Here are my dependencies from pom.xml:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-kernel</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-cypher</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>2.1.0.BUILD-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j-rest</artifactId>
<version>2.1.0.BUILD-SNAPSHOT</version>
<exclusions>
<exclusion>
<artifactId>neo4j-rest-graphdb</artifactId>
<groupId>org.neo4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.6.12</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>opensymphony</groupId>
<artifactId>sitemesh</artifactId>
<version>2.4.2</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.0.2.GA</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.8.3</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.1</version>
</dependency>
</dependencies>
This is my error-message:
Hello World!
43 [main] INFO
org.springframework.context.support.FileSystemXmlApplicationContext -
Refreshing
org.springframework.context.support.FileSystemXmlApplicationContext@485fcf2 9:
startup date [Wed May 09 12:37:55 CEST 2012]; root of context
hierarchy
87 [main] INFO
org.springframework.beans.factory.xml.XmlBeanDefinitionReader -
Loading XML bean definitions from file [K:\project\workspace\app1\src
\config\applicationContext.xml]
271 [main] INFO
org.springframework.beans.factory.support.DefaultListableBeanFactory -
Overriding bean definition for bean 'graphDatabaseService': replacing
[Generic bean: class
[org.springframework.data.neo4j.rest.SpringRestGraphDatabase]; scope=;
abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0;
autowireCandidate=true; primary=false; factoryBeanName=null;
factoryMethodName=null; initMethodName=null; destroyMethodName=null;
defined in file [K:\project\workspace\app1\src\config
\applicationContext.xml]] with [Root bean: class
[org.neo4j.kernel.EmbeddedGraphDatabase]; scope=singleton;
abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0;
autowireCandidate=true; primary=false; factoryBeanName=null;
factoryMethodName=null; initMethodName=null;
destroyMethodName=shutdown]
420 [main] INFO
org.springframework.beans.factory.support.DefaultListableBeanFactory -
Overriding bean definition for bean 'neo4jTemplate': replacing [Root
bean: class [null]; scope=; abstract=false; lazyInit=false;
autowireMode=3; dependencyCheck=0; autowireCandidate=true;
primary=false;
factoryBeanName=org.springframework.data.neo4j.config.Neo4jConfiguration#0;
factoryMethodName=neo4jTemplate; initMethodName=null;
destroyMethodName=(inferred); defined in class
org.springframework.data.neo4j.config.Neo4jConfiguration] with [Root
bean: class [null]; scope=; abstract=false; lazyInit=false;
autowireMode=3; dependencyCheck=0; autowireCandidate=true;
primary=false;
factoryBeanName=org.springframework.data.neo4j.config.Neo4jConfiguration#0;
factoryMethodName=neo4jTemplate;
...
read more »