2

My project is configured to use Eclipselink, build tool is Maven. I need to use JPA2 metamodel inside my code, so my pom.xml contains related configuration:

        <plugin>
            <groupId>org.bsc.maven</groupId>
            <artifactId>maven-processor-plugin</artifactId>
            <version>2.0.4</version>
            <executions>
                <execution>
                    <id>process</id>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <phase>generate-sources</phase>
                    <configuration>
                        <outputDirectory>${project.build.directory}/generated-sources/metamodel</outputDirectory>
                        <compilerArguments>
                            -Aeclipselink.persistencexml=${project.basedir}/src/main/resources/META-INF/business/user/persistence.xml
                        </compilerArguments>
                        <processors>
                            <processor>org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor
                            </processor>
                        </processors>
                    </configuration>
                </execution>
            </executions>
        </plugin>

When I try to execute mvn clean compile, I have errors during build:

[INFO] --- maven-processor-plugin:2.0.4:process (process) @ fsdp-user-service-datalayer ---
[INFO] Source directory: <path>\UserService\DataLayer\target\generated-sources\metamodel added
[INFO] Adding compiler arg: -Aeclipselink.persistencexml=<path>\UserService\DataLayer/src/main/resources/META-INF/business/user/persistence.xml
[INFO] javac option: -cp
[INFO] javac option: <jars list>
[INFO] javac option: -proc:only
[INFO] javac option: -Aeclipselink.persistencexml=<path>\UserService\DataLayer/src/main/resources/META-INF/business/user/persistence.xml
[INFO] javac option: -processor
[INFO] javac option: org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor
[INFO] javac option: -d
[INFO] javac option: <path>\UserService\DataLayer\target\classes
[INFO] javac option: -s
[INFO] javac option: <path>\UserService\DataLayer\target\generated-sources\metamodel
[INFO] diagnostic <path>\UserService\DataLayer\src\main\java\user\dao\impl\UserDAOImpl.java:11: cannot find symbol
symbol  : class UserEntity_
location: package user.entity
[INFO] diagnostic Note: Creating static metadata factory ...
[INFO] diagnostic Note: Found Option : eclipselink.persistencexml, with value: <path>\UserService\DataLayer/src/main/resources/META-INF/business/user/persistence.xml
[INFO] diagnostic Note: Optional file was not found: META-INF/orm.xml continuing with generation.
[INFO] diagnostic Note: Optional file was not found: META-INF/eclipselink-orm.xml continuing with generation.
[INFO] diagnostic Note: Optional file was not found: META-INF/business/user/orm.xml continuing with generation.
[INFO] diagnostic warning: The following options were not recognized by any processor: '[eclipselink.persistencexml]'
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ fsdp-user-service-datalayer ---
[debug] execute contextualize
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ fsdp-user-service-datalayer ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 11 source files to <path>\UserService\DataLayer\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] <path>\UserService\DataLayer\src\main\java\user\dao\impl\UserDAOImpl.java:[11,57] cannot find symbol
symbol  : class UserEntity_
location: package user.entity
[ERROR] <path>\UserService\DataLayer\src\main\java\user\dao\impl\UserDAOImpl.java:[99,22] cannot find symbol
symbol  : variable UserEntity_
location: class user.dao.impl.UserDAOImpl
[INFO] 2 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.112s

Only after execution of mvn compile again I have successfull compilation.

[INFO] --- maven-processor-plugin:2.0.4:process (process) @ fsdp-user-service-datalayer ---
[INFO] Source directory: <path>\UserService\DataLayer\target\generated-sources\metamodel added
[INFO] Adding compiler arg: -Aeclipselink.persistencexml=<path>\UserService\DataLayer/src/main/resources/META-INF/business/user/persistence.xml
[INFO] javac option: -cp
[INFO] javac option: <jars>
[INFO] javac option: -proc:only
[INFO] javac option: -Aeclipselink.persistencexml=<path>\UserService\DataLayer/src/main/resources/META-INF/business/user/persistence.xml
[INFO] javac option: -processor
[INFO] javac option: org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor
[INFO] javac option: -d
[INFO] javac option: <path>\UserService\DataLayer\target\classes
[INFO] javac option: -s
[INFO] javac option: <path>\UserService\DataLayer\target\generated-sources\metamodel
[INFO] diagnostic <path>\UserService\DataLayer\src\main\java\user\dao\impl\UserDAOImpl.java:11: cannot find symbol
symbol  : class UserEntity_
location: package user.entity
[INFO] diagnostic Note: Creating static metadata factory ...
[INFO] diagnostic Note: Found Option : eclipselink.persistencexml, with value: <path>\UserService\DataLayer/src/main/resources/META-INF/business/user/persistence.xml
[INFO] diagnostic Note: Optional file was not found: META-INF/orm.xml continuing with generation.
[INFO] diagnostic Note: Optional file was not found: META-INF/eclipselink-orm.xml continuing with generation.
[INFO] diagnostic Note: File loaded : META-INF/business/user/orm.xml, is eclipselink-orm file: false
[INFO] diagnostic Note: Found Option : eclipselink.persistencexml, with value: <path>\UserService\DataLayer/src/main/resources/META-INF/business/user/persistence.xml
[INFO] diagnostic Note: Optional file was not found: META-INF/orm.xml continuing with generation.
[INFO] diagnostic Note: Optional file was not found: META-INF/eclipselink-orm.xml continuing with generation.
[INFO] diagnostic Note: File loaded : META-INF/business/user/orm.xml, is eclipselink-orm file: false
[INFO] diagnostic warning: The following options were not recognized by any processor: '[eclipselink.persistencexml]'
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ fsdp-user-service-datalayer ---
[debug] execute contextualize
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ fsdp-user-service-datalayer ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 12 source files to <path>\UserService\DataLayer\target\classes
[INFO] 
[INFO] --- aspectj-maven-plugin:1.4:compile (compile) @ fsdp-user-service-datalayer ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.720s
[INFO] Finished at: Thu Aug 02 17:45:18 MSK 2012
[INFO] Final Memory: 26M/62M
[INFO] ------------------------------------------------------------------------

Main difference between two logs is what "unsucess clean compile" log have these lines:

[INFO] diagnostic Note: File loaded : META-INF/business/user/orm.xml, is eclipselink-orm file: false
[INFO] diagnostic Note: Found Option : eclipselink.persistencexml, with value: <path>\UserService\DataLayer/src/main/resources/META-INF/business/user/persistence.xml
[INFO] diagnostic Note: Optional file was not found: META-INF/orm.xml continuing with generation.
[INFO] diagnostic Note: Optional file was not found: META-INF/eclipselink-orm.xml continuing with generation.
[INFO] diagnostic Note: File loaded : META-INF/business/user/orm.xml, is eclipselink-orm file: false

but "success compile" log doesn't.

So question is: why I have so strange behavior?

user641652
  • 65
  • 1
  • 7
  • Can you find the user/orm.xml file before the unsuccessful run and then look for it after? The process needs it to build the metamodel, and my guess is copying it to where it is needed only after the metamodel creation process. This might be why you get the 'file was not found' message, preventing the UserEntity_ from being created. Second pass can then find the file on the path and so create the UserEntity_ needed to compile the UserDAOImpl class. – Chris Aug 02 '12 at 19:39
  • I found the solution. `{basedir}` should be used instead of `{project.basedir}` in the persistence.xml path – user641652 Aug 08 '12 at 05:04

0 Answers0