วันพฤหัสบดีที่ 19 มีนาคม พ.ศ. 2552

Problem from using JPA in grails with maven

I got this problem when i called $mvn grails:run-app.
[groovyc] Compiling 9 source files to /media/src/source/Eclipse/TestFrameWork/workspace/groovy/my-app/target/classes
[groovyc] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, Compile error during compilation with javac.
[groovyc] /media/src/source/Eclipse/TestFrameWork/workspace/groovy/my-app/src/java/org/grails/samples/Person.java:3: package javax.persistence does not exist
[groovyc] import javax.persistence.Entity;
[groovyc] ^
[groovyc] /media/src/source/Eclipse/TestFrameWork/workspace/groovy/my-app/src/java/org/grails/samples/Person.java:4: package javax.persistence does not exist
[groovyc] import javax.persistence.GeneratedValue;
[groovyc] ^
[groovyc] /media/src/source/Eclipse/TestFrameWork/workspace/groovy/my-app/src/java/org/grails/samples/Person.java:5: package javax.persistence does not exist
[groovyc] import javax.persistence.GenerationType;
[groovyc] ^
[groovyc] /media/src/source/Eclipse/TestFrameWork/workspace/groovy/my-app/src/java/org/grails/samples/Person.java:6: package javax.persistence does not exist
[groovyc] import javax.persistence.Id;
[groovyc] ^
[groovyc] /media/src/source/Eclipse/TestFrameWork/workspace/groovy/my-app/src/java/org/grails/samples/Person.java:7: package javax.persistence does not exist
[groovyc] import javax.persistence.Version;
[groovyc] ^
[groovyc] /media/src/source/Eclipse/TestFrameWork/workspace/groovy/my-app/src/java/org/grails/samples/Person.java:26: cannot find symbol
[groovyc] symbol: class Entity
[groovyc] @Entity
[groovyc] ^
[groovyc] /media/src/source/Eclipse/TestFrameWork/workspace/groovy/my-app/src/java/org/grails/samples/Person.java:28: cannot find symbol
[groovyc] symbol : class Id
[groovyc] location: class org.grails.samples.Person
[groovyc] @Id
[groovyc] ^
[groovyc] /media/src/source/Eclipse/TestFrameWork/workspace/groovy/my-app/src/java/org/grails/samples/Person.java:29: cannot find symbol
[groovyc] symbol : class GeneratedValue
[groovyc] location: class org.grails.samples.Person
[groovyc] @GeneratedValue(strategy=GenerationType.AUTO)
[groovyc] ^
[groovyc] /media/src/source/Eclipse/TestFrameWork/workspace/groovy/my-app/src/java/org/grails/samples/Person.java:31: cannot find symbol
[groovyc] symbol : class Version
[groovyc] location: class org.grails.samples.Person
[groovyc] @Version
[groovyc] ^
[groovyc] 9 errors
[groovyc]
[groovyc]
[groovyc] 1 error
Compilation error: Compilation Failed

It seems javax.persistence does not exist in maven dependencies of grails-maven-archetype 1.0.
To fix this problem, I added ejb3-persistence in pom.xml.

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>ejb3-persistence</artifactId>
<version>1.0.2.GA</version>
</dependency>

ไม่มีความคิดเห็น:

แสดงความคิดเห็น