I´m getting a little bit lost in my own (maven enabled) dynamic WEB – Project. The project works fine, I´ve got a RESTful WebService (Jersey) running and I´m able to consume it.
… my next step was to persist my domain classes, with Spring Data and Neo4j. So, I´ve added some tags to my pom.xml
...
<repository>
<id>spring-milestone</id>
<name>Spring Maven MILESTONE Repository</name>
<url>http://maven.springframework.org/milestone</url>
</repository>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
...
my next step was to annotate my entity-classes… here is a simple example:
...
@NodeEntity
public class Category {
@GraphId Long nodeId;
String categoryType;
public Category(String categoryType){
this.categoryType = categoryType;
}
}
...
okay, everything´s fine… now I want to persist my category-object…
@Autowired Neo4jTemplate template;
@Test @Transactional
public void toGraphDb() {
template.save(new Category("mashineCategory"));
}
when I run the test I´m getting a NullPointerException, cause the template is null
I guess there is something missing in my project, but I´m not sure in which folder/file to add informations/files…
here is my web.xml:
...
<display-name>ElisaSimulatorM4</display-name>
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>de.elisa.communication.webservice.restservice.implementation</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
...
in some guides I read something about dispatcherServlets and an applicatonContext.xml, but I have no idea where to put it in my project.
Maybe someone can help me out…
Ps. I wanted to upload a screenshot from my project-tree but as a greenhorn I haven’t got enough reputation… sorry for that
Perhaps it is best to look into the supplied examples of Spring Data Neo4j http://spring.neo4j.org/examples there are some for simple projects like hello-world and some for more advanced web-applications cineasts.
To get the idea the Spring Documentation about the general setup of a Spring(Web) application should help you.
You should probably start with a console application to get the ideas and then incorporate that in your web-application.
The applicationContext.xml file is the SpringFramework configuration file. It should be enough to have a minimal one, like this from the hello-world example.
Put it in src/main/resources/applicationContext.xml