Announcement Announcement Module
Collapse
No announcement yet.
Spring data graph, "NodeEntity" can not be used as "Form Object" in the webflow? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring data graph, "NodeEntity" can not be used as "Form Object" in the webflow?

    Hi, I am getting NullPointerException when trying to save a form object.
    Neo4jNodeBacking.ajc was set to null after deserialization.

    Version:
    Code:
    	<properties>
    		<java-version>1.5</java-version>
    		<springframework-version>3.0.5.RELEASE</springframework-version>
    		<springwebflow-version>2.3.0.BUILD-SNAPSHOT</springwebflow-version>
    		<springsecurity-version>3.0.5.RELEASE</springsecurity-version>
    		<org.slf4j-version>1.5.10</org.slf4j-version>
    		<aspectj.version>1.6.12.M1</aspectj.version>
                   <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                    <datastore-graph.version>1.2.0.BUILD-SNAPSHOT</datastore-graph.version>	 
    	</properties>
    the exceptions:
    Code:
    SEVERE: Servlet.service() for servlet [Spring MVC Dispatcher Servlet] in context with path [/publ-web] threw exception [Request processing failed; nested exception is org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing [AnnotatedAction@1e600bf targetAction = [EvaluateAction@13b2fdc expression = journalService.saveJournal(journal), resultExpression = [null]], attributes = map[[empty]]] in state 'journalForm' of flow 'newdata/journal' -- action execution attributes were 'map[[empty]]'] with root cause
    java.lang.NullPointerException
    	at org.springframework.data.neo4j.support.node.Neo4jNodeBacking.ajc$interMethod$org_springframework_data_neo4j_support_node_Neo4jNodeBacking$org_springframework_data_neo4j_core_NodeBacked$persist(Neo4jNodeBacking.aj:132)
    	at at.ac.iiasa.ime.publ.domain.Journal.persist(Journal.java:1)
    	at org.springframework.data.neo4j.support.node.Neo4jNodeBacking.ajc$interMethodDispatch1$org_springframework_data_neo4j_support_node_Neo4jNodeBacking$org_springframework_data_neo4j_core_NodeBacked$persist(Neo4jNodeBacking.aj)
    	at org.springframework.data.neo4j.repository.NodeGraphRepository.save(NodeGraphRepository.java:42)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:368)
    	at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:349)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    	at $Proxy90.save(Unknown Source)
    NodeEntity:
    Code:
    @NodeEntity
    public class Journal implements java.io.Serializable {
    	
    	private static final long serialVersionUID = 1L;
    	@Indexed private String name;
    	public Journal(){}
    	public String getName() {
    		return name;
    	}
    	public void setName(String name) {
    		this.name = name;
    	}
    	
    }
    Repository & Service
    Code:
    public interface JournalRepository extends  GraphRepository<Journal>, NamedIndexRepository<Journal> {}
    
    @Service("journalService")
    @Transactional
    public class JournalServiceImpl implements JournalService {
    
    	@Autowired private JournalRepository journalRepository;
    	@Override
    	public Journal getJournal(Long idJournal) {
    		Journal journal;
    		if(idJournal==null)
    		{
    		   journal = new Journal();
    		}
    		else
    		{
    			journal = journalRepository.findOne(idJournal);
    		}
    
    		return journal;
    	}
    
    	@Override
    	public void saveJournal(Journal journal){
    	   journalRepository.save(journal);
    	}
    
    	
    }
    Workflow:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <flow xmlns="http://www.springframework.org/schema/webflow"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="
    		http://www.springframework.org/schema/webflow 
    		http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">	
       
        <persistence-context />
    	<view-state id="journalForm" view="newdata/journalForm" model="journal">
    	 <on-entry>
    	   <evaluate expression="journalService.getJournal(requestParameters.idJournal)" result="viewScope.journal" />
    	 </on-entry>
    		<transition on="submit" to="success">
    	  	        <evaluate expression="journalService.saveJournal(journal)" />
    		</transition> 
    	</view-state>
    	
    	<end-state id="success" view="redirect:/newdata/dashboard"  commit="true"/>
    
    </flow>
    View:

    Code:
    <form:form modelAttribute="journal">
    Name: <form:input path="name" />
    <button type="submit" name="_eventId_submit">Submit</button>
    </form:form>

  • #2
    By now node-entities are not serializable when they are attached to a "live" node or relationship (which are not serializable). There is also some setup involved at construction. I'll look into adding a readResolve method to deal with that. Could you please raise a JIRA issue for this.

    Thanks so much

    Michael

    Comment


    • #3
      Hi Michael,
      I am sorry for late reply, I just returned from vacation. I will create a Jira ticket for this issue now.

      Thanks very much.
      Hongtao

      Comment

      Working...
      X