Announcement Announcement Module
Collapse
No announcement yet.
[neo4j] No property service found; JUnit test fails Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • [neo4j] No property service found; JUnit test fails

    I am trying to get a grasp on Spring data neo4j following the cineast source.. I followed the structure of the code and the error is coming from my class resourceServiceRepository which extends Service. These are all generic classes and i am trying to understand complex function, like actor and director both extend person but person is the only class that has @NodeEntity. I don't have real data to use so am just using name description uri. i have relationships to make linked data (both direction relationship) with no properties. This is sort of an rdf example in the vocabulary (class naming) i'm using. None of the errors are in my code but give a "No property service found for type class jackal.mytest.domain.ResourceService". What is a property service and how is it defined?

    EDIT: This fails before the test even begins and I cannot find anything about property service in the spring data neo4j reference doc.

    EDIT: The error is from ResourceService - resourceServiceRepository if from bean creation: "Error creating bean with name 'datasourceServiceRepository'"

    ResourceService
    PHP Code:
    public class ResourceService extends Service
    {
        
        public 
    ResourceService(String idString nameString uri)
        {
            
    super (idnameuri);
        }
         
        public 
    ResourceService() { }
        
        public 
    ResourceService(String id)
        {
            
    super(idnullnull);
        }
        
        @
    RelatedToVia
        Collection
    <Linkedlinks;
        
        public 
    Iterable<LinkedgetLinks()
        {
            return 
    links;
        }
        
        public 
    Linked createLink(ResourceService rsResource res)
        {
            final 
    Linked l = new Linked(resrs);
            
    stores.add(l);
            return 
    l;
        }
        


    Stack trace
    PHP Code:
    2012-04-22 14:33:20,805 [mainERROR org.springframework.test.context.TestContextManager Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@3539113cto prepare test instance [null(jackal.mytest.domain.DomainTest)]
    java.lang.IllegalStateExceptionFailed to load ApplicationContext
        at org
    .springframework.test.context.TestContext.getApplicationContext(TestContext.java:308)
        
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
        
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
        
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
        
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)
        
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)
        
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)
        
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
        
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
        
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
        
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
        
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
        
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
        
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
        
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
        
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
        
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
        
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
        
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
        
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
        
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
        
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
        
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
    Caused byorg.springframework.beans.factory.BeanCreationExceptionError creating bean with name 'resourceServiceRepository'FactoryBean threw exception on object creationnested exception is java.lang.IllegalArgumentExceptionNo property service found for type class jackal.mytest.domain.ResourceService
        at org
    .springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149)
        
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
        
    at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1440)
        
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:304)
        
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
        
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
        
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
        
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
        
    at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:84)
        
    at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
        
    at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:280)
        
    at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:304)
        ... 
    24 more
    Caused by
    java.lang.IllegalArgumentExceptionNo property service found for type class jackal.mytest.domain.ResourceService
        at org
    .springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:73)
        
    at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:92)
        
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:312)
        
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:294)
        
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:258)
        
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:239)
        
    at org.springframework.data.repository.query.parser.Part.<init>(Part.java:69)
        
    at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:180)
        
    at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:260)
        
    at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:240)
        
    at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:71)
        
    at org.springframework.data.neo4j.repository.query.DerivedCypherRepositoryQuery.<init>(DerivedCypherRepositoryQuery.java:51)
        
    at org.springframework.data.neo4j.repository.query.GraphQueryMethod.createQuery(GraphQueryMethod.java:121)
        
    at org.springframework.data.neo4j.repository.GraphRepositoryFactory$1.resolveQuery(GraphRepositoryFactory.java:113)
        
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:269)
        
    at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:142)
        
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:114)
        
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:38)
        
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
        ... 
    35 more 
    Last edited by Jackal789; Apr 24th, 2012, 10:09 PM.

  • #2
    Could you please also show your Service class and ResourceServiceRepository? As well as your spring config.

    Which version of SDN are you using?

    Thanks

    Comment


    • #3
      Originally posted by MichaelHunger View Post
      Could you please also show your Service class and ResourceServiceRepository? As well as your spring config.

      Which version of SDN are you using?

      Thanks
      2.0.1.RELEASE is in my pom. You'll notice I setup the code extremely similar to cineasts. Thank you for helping!

      Service class
      PHP Code:
      package jackal.mytest.domain;

      import org.springframework.data.neo4j.annotation.*;
      import java.util.ArrayList;
      import java.util.Collection;
      import java.util.Set;

      @
      NodeEntity
      public class Service 
      {
          @
      GraphId Long nodeId;

          @
      Indexed
          String id
      ;
          
          
      String description;
          
          @
      RelatedTo
          Set
      <Tagtags;
          
          private 
      String uri;
          private 
      String owner
          private 
      String name;
          
          protected 
      Service (String idString nameString ownerString uri)
          {
              
      this.id id
              
      this.name name;
              
      this.owner owner;
              
      this.uri uri;
          }
          
          protected 
      Service (String idString nameString ownerString uriString... tags)
          {
              
      this.id id
              
      this.name name;
              
      this.owner owner;
              
      this.uri uri;
              
              for (
      String t tags)
              {
                  
      this.addTag(t);
              }
          }
          
          protected 
      Service ()
          {}

          
          public 
      String getId() {
              return 
      id;
          }
          
          public 
      void setId(String id) {
              
      this.id id;
          }
          
          public 
      String getUri() {
              return 
      uri;
          }
          
          public 
      void setUri(String uri) {
              
      this.uri uri;
          }
          
          public 
      String getOwner() {
              return 
      owner;
          }
          
          public 
      void setOwner(String owner) {
              
      this.owner owner;
          }
          
          public 
      String getName() {
              return 
      name;
          }
          
          public 
      void setName(String name) {
              
      this.name name;
          }
          
          public 
      void addTag (String tag)
          {
              
      this.tags.add(new Tag(tag));
          }
          
          public 
      Collection<TaggetTags()
          {
              return 
      tags;
          }
          
          public 
      boolean removeTag(Tag tag)
          {
              return 
      this.tags.remove(tag);
          }
          
          @
      Override
          
      public boolean equals(Object o )
          {
              if (
      this == o) return true;
              if (
      == null getClass() != o.getClass()) return false;
              
              
      Service s = (Serviceo;
              if (
      nodeId == null) return super.equals(o);
              return 
      nodeId.equals(s.nodeId);
          }
          
          @
      Override
          
      public int hashCode()
          {
              return 
      nodeId != null nodeId.hashCode() : super.hashCode();
          }
      // class Service 
      ResourceServiceRepository
      PHP Code:
      package jackal.mytest.repository;

      import jackal.mytest.domain.ResourceService;

      import org.springframework.data.domain.Page;
      import org.springframework.data.domain.Pageable;
      import org.springframework.data.neo4j.repository.GraphRepository;
      import org.springframework.data.neo4j.repository.NamedIndexRepository;
      import org.springframework.data.neo4j.repository.RelationshipOperationsRepository;

      public interface 
      ResourceServiceRepository extends GraphRepository<ResourceService>,
                              
      NamedIndexRepository<ResourceService>,
                              
      RelationshipOperationsRepository<ResourceService>

      {
          
      ResourceService findByName(String name);
          
          
      ResourceService findById(String id);
          
          
      //Page<ResourceService> findByServiceLike(String service, Pageable page); // this line was cause of error


      Spring Config xml
      PHP Code:
      <?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:spring-configured/>
          <context:annotation-config/>
          <context:component-scan base-package="jackal.mytest"/>
          
          <neo4j:config storeDirectory="target/test-core-db"/>
          <neo4j:repositories base-package="jackal.mytest.repository"/>
          
          <bean id="graphDatabaseService" class="org.neo4j.test.ImpermanentGraphDatabase" destroy-method="shutdown"/>
          
      </beans>
      I have tried this with and without the graphDatabaseService bean
      Last edited by Jackal789; Apr 25th, 2012, 07:51 AM.

      Comment


      • #4
        So after playing around with my classes the error is thrown from the repository line Page<ResourceService> findByServiceLike... I comment it out and the error is no longer thrown. This is a feature I noticed from Cineasts that I think would be really neat to implement but am not sure how it's done since I have seen nothing else about this Page type in the source.

        Can someone elaborate on how it functions in Cineasts? Thanks!
        Last edited by Jackal789; Apr 25th, 2012, 07:50 AM.

        Comment

        Working...
        X