# DAO classes from different module not recognized

**URL:** <https://community.neo4j.com/t/dao-classes-from-different-module-not-recognized/23555>\
**Category:** Neo4j Graph Platform\
**Tags:** spring, data-modeling, ogm\
**Created:** [August 16, 2020, 3:40pm UTC](https://community.neo4j.com/t/dao-classes-from-different-module-not-recognized/23555 "2020-08-16T15:40:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hreskodavid57](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/hreskodavid57/32/12988_2.png) [@hreskodavid57](https://community.neo4j.com/u/hreskodavid57)\
**Post date:** [August 16, 2020, 3:40pm UTC](https://community.neo4j.com/t/dao-classes-from-different-module-not-recognized/23555/1 "2020-08-16T15:40:32Z")

</div>

Hi I am using org.springframework.boot:spring-boot-starter-data-neo4j -\> 2.2.3.RELEASE library to work with Neo4j. I have multi module project where my DAO classes are in separate module. The problem is when I am trying to do some operation on Neo4j database I got following error -\>

`# [neo4j :: Getting java.lang.IllegalArgumentException: Class class com.my.domain.Address is not a valid entity class. Please check the entity mapping]`

MY ADDRESS DAO :

```auto
@NodeEntity
@Getter
@Setter
public class Address {

    @Id
    @GeneratedValue(strategy = UuidStrategy.class)
    private Long id;

    private String country;
    private String city;
    private String street;
    private String postalCode;

    @Relationship(value = "LIVES_AT", direction = INCOMING)
    private User user;

}

```

DAO classes are recognized in Intellij IDEA and I can also build my project with Gradle, but during runtime mentioned error is occuring. Please can you tell me how can I fix this issue ? Is there any way to tell neo4j to recognize these external DAO classes ? Thanks for help.

---

<div class="post-metadata">

**Author:** ![amsilf](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/amsilf/32/13216_2.png) [@amsilf](https://community.neo4j.com/u/amsilf)\
**Post date:** [August 17, 2020, 2:25am UTC](https://community.neo4j.com/t/dao-classes-from-different-module-not-recognized/23555/2 "2020-08-17T02:25:40Z")

</div>

It's hard to say what's the problem without seeing the whole code but I doesn't looks like that the issue is not with neo4j, but more like with your spring configuration; could you please share your project structure and a way your configure spring?

---

<div class="post-metadata">

**Author:** ![hreskodavid57](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/hreskodavid57/32/12988_2.png) [@hreskodavid57](https://community.neo4j.com/u/hreskodavid57)\
**Post date:** [August 17, 2020, 8:23am UTC](https://community.neo4j.com/t/dao-classes-from-different-module-not-recognized/23555/3 "2020-08-17T08:23:11Z")

</div>

Hi after some research I find out that problem was in session OGM creates. It was not checking these external packages for DAOs so I was forced to override default session as following -\>

```auto
 @Bean
    public SessionFactory sessionFactory() {
        org.neo4j.ogm.config.Configuration configuration = new org.neo4j.ogm.config.Configuration.Builder()
                .uri(databaseUrl)
                .credentials(userName, password)
                .build();
        return new SessionFactory(configuration,"my.external.package.with.dao");
    }

    @Bean
    public Neo4jTransactionManager transactionManager() {
        return new Neo4jTransactionManager(sessionFactory());
    }

```

I am not sure if this correct implementation because I read one stack overflow post where guy mentioned that it is not needed to override session in case spring-data-neo4j library. So is there another way to update session with new DAO package ? Thanks for help @amsilf

---

<div class="post-metadata">

**Author:** ![amsilf](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/amsilf/32/13216_2.png) [@amsilf](https://community.neo4j.com/u/amsilf)\
**Post date:** [August 24, 2020, 4:38am UTC](https://community.neo4j.com/t/dao-classes-from-different-module-not-recognized/23555/4 "2020-08-24T04:38:21Z")

</div>

Sorry for late reply, that's a bit strange behaviour, @EnableTransactionManagement and @EnableNeo4jRepositories should do the job for you; you have to initialize transaction manager manually only if it's required to have connection to multiple dbms, e.g. to neo4j and mysql or some unique rollback behaviour is required.

---

<div class="post-metadata">

**Author:** ![hreskodavid57](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/hreskodavid57/32/12988_2.png) [@hreskodavid57](https://community.neo4j.com/u/hreskodavid57)\
**Post date:** [August 24, 2020, 8:33am UTC](https://community.neo4j.com/t/dao-classes-from-different-module-not-recognized/23555/5 "2020-08-24T08:33:54Z")

</div>

without creating custom sessionFactory and transactionManager my project did not work
