Announcement Announcement Module
Collapse
No announcement yet.
NullPointerException at Neo4jTemplate.findAll ??? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • NullPointerException at Neo4jTemplate.findAll ???

    I also posted this problem on https://jira.springsource.org/browse/DATAGRAPH-134

    I initialize with:

    Code:
    logger.info("Starting Neo4j");
    String dir = "/together/project/SatukanCinta/satukancinta-neo4j-db_dev";
    graphDatabaseService = new EmbeddedGraphDatabase(dir);
    DelegatingGraphDatabase graphDatabase = new DelegatingGraphDatabase(graphDatabaseService);
    graphTemplate = new Neo4jTemplate(graphDatabase);
    Here's my Skill entity:

    Code:
    package com.satukancinta.domain;
    
    import java.util.Set;
    
    import org.neo4j.graphdb.Direction;
    import org.springframework.data.neo4j.annotation.Indexed;
    import org.springframework.data.neo4j.annotation.NodeEntity;
    import org.springframework.data.neo4j.annotation.RelatedTo;
    
    @NodeEntity
    public class Skill {
    
    	@Indexed
    	private String name;
    	
    	@RelatedTo(type="TELLS", direction=Direction.INCOMING)
    	Set<User> tellers;
    
    	public String getName() {
    		return name;
    	}
    
    	public void setName(String name) {
    		this.name = name;
    	}
    	
    }
    I get the list of all nodes by:

    Code:
    @Inject Neo4jTemplate neo4j;
    
    ...
    
    public List<Skill> getSkills() {
    		ArrayList<Skill> skills = Lists.newArrayList(neo4j.findAll(Skill.class));
    		return skills;
    	}
    Access it from JSF View :

    Code:
    <h:dataTable value="#{skillsView.skills}" var="skill">
    	    	<h:column>
    	    		<f:facet name="header">Name</f:facet>
    	    		#{skill.name}
    	    	</h:column>
    	    </h:dataTable>
    But I get Error:

    Code:
    21:51:18,710 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (http--127.0.0.1-8080-1) Error Rendering View[/skills.xhtml]: javax.el.ELException: /skills.xhtml @20,60 value="#{skillsView.skills}": java.lang.NullPointerException
    	at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:114) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
    ...
    Caused by: java.lang.NullPointerException
    	at org.springframework.data.neo4j.support.Neo4jTemplate.findAll(Neo4jTemplate.java:158) [spring-data-neo4j-2.0.0.RC1.jar:]
    	at com.satukancinta.ui.SkillsView.getSkills(SkillsView.java:40) [classes:]
    	at com.satukancinta.ui.SkillsView$Proxy$_$$_WeldClientProxy.getSkills(SkillsView$Proxy$_$$_WeldClientProxy.java) [classes:]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_26]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_26]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_26]
    	at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_26]
    	at javax.el.BeanELResolver.getValue(BeanELResolver.java:302) [jboss-el-api_2.2_spec-1.0.0.Final.jar:1.0.0.Final]
    	at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
    	at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
    	at org.apache.el.parser.AstValue.getValue(AstValue.java:134) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
    	at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:187) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
    	at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:55) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
    	at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
    	... 39 more
    Also tried:

    Code:
    @Produces public GraphRepository<Skill> getSkillRepository() {
    		return graphTemplate.repositoryFor(Skill.class);
    	}
    
    ...
    
    	@Inject GraphRepository<Skill> skillRepo;
    	
    	public List<Skill> getSkills() {
    		ArrayList<Skill> skills = Lists.newArrayList(skillRepo.findAll());
    		return skills;
    	}
    But got another error, but still NullPointerException:

    Code:
    22:10:00,221 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/satukancinta-web].[FacesServlet]] (http--127.0.0.1-8080-1) Servlet.service() for servlet FacesServlet threw exception: java.lang.NullPointerException
    	at org.springframework.data.neo4j.support.Neo4jTemplate.isNodeEntity(Neo4jTemplate.java:281) [spring-data-neo4j-2.0.0.RC1.jar:]
    	at org.springframework.data.neo4j.support.Neo4jTemplate.repositoryFor(Neo4jTemplate.java:111) [spring-data-neo4j-2.0.0.RC1.jar:]
    	at com.satukancinta.web.Persistence.getSkillRepository(Persistence.java:46) [classes:]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_26]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_26]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_26]
    	at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_26]
    	at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
    	at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
    	at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
    	at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
    	at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
    	at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstance(MethodInjectionPoint.java:169) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
    	at org.jboss.weld.bean.ProducerMethod$1.produce(ProducerMethod.java:149) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
    	at org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:361) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
    	at org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:67) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
    	at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:693) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
    	at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:775) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
    	at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:138) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
    	at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:875) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
    	at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:887) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
    	at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1$1.proceed(ManagedBean.java:182) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
    	at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:54) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
    	at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1.work(ManagedBean.java:176) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
    	at org.jboss.weld.bean.ManagedBean$FixInjectionPoint.run(ManagedBean.java:142) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
    	at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.inject(ManagedBean.java:170) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
    	at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:339) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
    	at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:122) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
    	at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:99) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
    	at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:87) [weld-core-1.1.2.Final.jar:2011-07-26 15:02]
    	at com.satukancinta.ui.SkillsView$Proxy$_$$_WeldClientProxy.getSkills(SkillsView$Proxy$_$$_WeldClientProxy.java) [classes:]
    ...

  • #2
    Did you also try to initialize the template with the ApplicationContext ?

    Or in the programmatic case, try to call a template.postConstruct() after the initialization.

    Please report if either of those helped.

    Comment


    • #3
      Originally posted by MichaelHunger View Post
      Did you also try to initialize the template with the ApplicationContext ?

      Or in the programmatic case, try to call a template.postConstruct() after the initialization.

      Please report if either of those helped.
      THANK YOU!!

      Yes:

      Code:
      		graphTemplate = new Neo4jTemplate(graphDatabase);
      		graphTemplate.postConstruct();
      postConstruct makes it work!

      I'll have to remember that next time I try to bypass Spring ;-)

      I'll close the bug.

      Comment

      Working...
      X