-1

I make multimodule application (vaadin, spring, hibernate) I have big problem with access to DAO (or model, generally with persistence in persistence module)

I need create spring xml bean definition in core or create spring bean in web (in applicationContext.xml) ?

I get error :

services/TestService.java:[3,11] package dao does not exist
cannot find symbol  symbol:   class User
Generally core don't see persistence class

Generally, i have 3 modules :

  • core
  • persistence
  • web

Core pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 <parent>
    <artifactId>eControl</artifactId>
    <groupId>pl.cwik.dawid</groupId>
    <version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>core</artifactId>

<dependencies>
    <dependency>
        <groupId>pl.cwik.dawid</groupId>
        <artifactId>persistence</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.springframework/spring-beans -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>4.3.11.RELEASE</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-commons -->
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-commons</artifactId>
        <version>1.13.7.RELEASE</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa -->
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-jpa</artifactId>
        <version>1.11.7.RELEASE</version>
    </dependency>


</dependencies>

And persistence pom

<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
    <artifactId>eControl</artifactId>
    <groupId>pl.cwik.dawid</groupId>
    <version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>persistence</artifactId>

<dependencies>
    <!-- https://mvnrepository.com/artifact/org.hibernate.javax.persistence/hibernate-jpa-2.1-api -->
    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.1-api</artifactId>
        <version>1.0.0.Final</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>5.2.11.Final</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>2.0.0.Final</version>
    </dependency>



    <!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>42.1.4</version>
    </dependency>


</dependencies>
  • Hi, while it is nice that your code is open-source, I don't think searching in repo to find the actual problem is what everyone dreams about. Especially since class User is not used in TestService. It looks like the error happens in some uncommited change. – Vlasec Nov 07 '17 at 22:15
  • @Vlasec Class test service is example class. I have in package dao, class User.class I'm think, it's problem in spring configuration on multi module project ? – Dawid Ćwik Nov 08 '17 at 11:44
  • I noticed one problem in your XML. You are asking for persistence 1.0-SNAPSHOT, but your current version is 1.0.0-SNAPSHOT. That means you either get an older version, or you could also get no library at all if you never had 1.0-SNAPSHOT version. – Vlasec Nov 09 '17 at 10:12
  • That's my fault, it is a really stupid thing ! Thanks ! – Dawid Ćwik Nov 09 '17 at 17:43

2 Answers2

0

The problem is, maven project persistence is version 1.0.0-SNAPSHOT. But core is dependent on 1.0-SNAPSHOT which is either a version that never existed, or some older version missing some files.

Vlasec
  • 5,500
  • 3
  • 27
  • 30
0

The problem solves by comment @Vlasec .

I noticed one problem in your XML. You are asking for persistence 1.0-SNAPSHOT, but your current version is 1.0.0-SNAPSHOT. That means you either get an older version, or you could also get no library at all if you never had 1.0-SNAPSHOT version. – Vlasec Nov 9 at 10:12

That's my fault, it is a really stupid thing ! Thanks !