Reputation: 1916
i have problem with maven. When i try to compile test classes (mvn test-compile
), it fails to find the tested classes used in test classes. For example class UserTest
can't be compiled because compiler can't find class User
which is being used inside the UserTest
class. The problem is most likely in the class path not including target folder during test-compile
phase, which is weird because i thought maven does include it.
If anyone had any ideas how to fix this issue, i would be greatful.
The pom.xml file can be found here http://github.com/tomasherman/JBTBackup/blob/master/pom.xml, just like rest of the project.
The maven output is as follows:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building JBTBackup Maven Webapp
[INFO] task-segment: [test-compile]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources
[WARNING] While downloading hibernate:hibernate:3.0.5
This artifact has been relocated to org.hibernate:hibernate:3.0.5.
[INFO] [compiler:compile {execution: default-compile}]
[INFO] No sources to compile
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/arg/workspace/JBTBackup/src/test/resources
[INFO] [sql:execute {execution: add-test-data}]
[INFO] Executing file: /tmp/pre-test-editdb.1278025605sql
[INFO] 0 of 0 SQL statements executed successfully
[INFO] [compiler:testCompile {execution: default-testCompile}]
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 2 source files to /home/arg/workspace/JBTBackup/target/test-classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/arg/workspace/JBTBackup/src/test/java/org/tomasherman/JBTBackup/Resource/Entity/UserTest.java:[26,15] cannot find symbol
symbol : class User
location: class org.tomasherman.JBTBackup.Resource.Entity.UserTest
[ERROR] /home/arg/workspace/JBTBackup/src/test/java/org/tomasherman/JBTBackup/Resource/Entity/UserTest.java:[27,15] cannot find symbol
symbol : class User
location: class org.tomasherman.JBTBackup.Resource.Entity.UserTest
[ERROR] /home/arg/workspace/JBTBackup/src/test/java/org/tomasherman/JBTBackup/Resource/Entity/UserTest.java:[28,15] cannot find symbol
symbol : class User
location: class org.tomasherman.JBTBackup.Resource.Entity.UserTest
[ERROR] /home/arg/workspace/JBTBackup/src/test/java/org/tomasherman/JBTBackup/Resource/Entity/BTFileTest.java:[23,15] cannot find symbol
symbol : class User
location: class org.tomasherman.JBTBackup.Resource.Entity.BTFileTest
[ERROR] /home/arg/workspace/JBTBackup/src/test/java/org/tomasherman/JBTBackup/Resource/Entity/BTFileTest.java:[25,15] cannot find symbol
symbol : class BTFile
location: class org.tomasherman.JBTBackup.Resource.Entity.BTFileTest
[ERROR] /home/arg/workspace/JBTBackup/src/test/java/org/tomasherman/JBTBackup/Resource/Entity/UserTest.java:[26,29] cannot find symbol
symbol : class User
location: class org.tomasherman.JBTBackup.Resource.Entity.UserTest
[ERROR] /home/arg/workspace/JBTBackup/src/test/java/org/tomasherman/JBTBackup/Resource/Entity/UserTest.java:[27,29] cannot find symbol
symbol : class User
location: class org.tomasherman.JBTBackup.Resource.Entity.UserTest
[ERROR] /home/arg/workspace/JBTBackup/src/test/java/org/tomasherman/JBTBackup/Resource/Entity/UserTest.java:[28,29] cannot find symbol
symbol : class User
location: class org.tomasherman.JBTBackup.Resource.Entity.UserTest
[ERROR] /home/arg/workspace/JBTBackup/src/test/java/org/tomasherman/JBTBackup/Resource/Entity/BTFileTest.java:[23,29] cannot find symbol
symbol : class User
location: class org.tomasherman.JBTBackup.Resource.Entity.BTFileTest
[ERROR] /home/arg/workspace/JBTBackup/src/test/java/org/tomasherman/JBTBackup/Resource/Entity/BTFileTest.java:[25,31] cannot find symbol
symbol : class BTFile
location: class org.tomasherman.JBTBackup.Resource.Entity.BTFileTest
[INFO] 10 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
/home/arg/workspace/JBTBackup/src/test/java/org/tomasherman/JBTBackup/Resource/Entity/UserTest.java:[26,15] cannot find symbol
symbol : class User
location: class org.tomasherman.JBTBackup.Resource.Entity.UserTest
/home/arg/workspace/JBTBackup/src/test/java/org/tomasherman/JBTBackup/Resource/Entity/UserTest.java:[27,15] cannot find symbol
symbol : class User
location: class org.tomasherman.JBTBackup.Resource.Entity.UserTest
/home/arg/workspace/JBTBackup/src/test/java/org/tomasherman/JBTBackup/Resource/Entity/UserTest.java:[28,15] cannot find symbol
symbol : class User
location: class org.tomasherman.JBTBackup.Resource.Entity.UserTest
/home/arg/workspace/JBTBackup/src/test/java/org/tomasherman/JBTBackup/Resource/Entity/BTFileTest.java:[23,15] cannot find symbol
symbol : class User
location: class org.tomasherman.JBTBackup.Resource.Entity.BTFileTest
/home/arg/workspace/JBTBackup/src/test/java/org/tomasherman/JBTBackup/Resource/Entity/BTFileTest.java:[25,15] cannot find symbol
symbol : class BTFile
location: class org.tomasherman.JBTBackup.Resource.Entity.BTFileTest
/home/arg/workspace/JBTBackup/src/test/java/org/tomasherman/JBTBackup/Resource/Entity/UserTest.java:[26,29] cannot find symbol
symbol : class User
location: class org.tomasherman.JBTBackup.Resource.Entity.UserTest
/home/arg/workspace/JBTBackup/src/test/java/org/tomasherman/JBTBackup/Resource/Entity/UserTest.java:[27,29] cannot find symbol
symbol : class User
location: class org.tomasherman.JBTBackup.Resource.Entity.UserTest
/home/arg/workspace/JBTBackup/src/test/java/org/tomasherman/JBTBackup/Resource/Entity/UserTest.java:[28,29] cannot find symbol
symbol : class User
location: class org.tomasherman.JBTBackup.Resource.Entity.UserTest
/home/arg/workspace/JBTBackup/src/test/java/org/tomasherman/JBTBackup/Resource/Entity/BTFileTest.java:[23,29] cannot find symbol
symbol : class User
location: class org.tomasherman.JBTBackup.Resource.Entity.BTFileTest
/home/arg/workspace/JBTBackup/src/test/java/org/tomasherman/JBTBackup/Resource/Entity/BTFileTest.java:[25,31] cannot find symbol
symbol : class BTFile
location: class org.tomasherman.JBTBackup.Resource.Entity.BTFileTest
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Thu Aug 26 12:54:37 CEST 2010
[INFO] Final Memory: 17M/172M
[INFO] ------------------------------------------------------------------------
Thanks for all comments, Tomas Herman
Upvotes: 0
Views: 5915
Reputation: 97379
You have to move your application classes to src/main/java/... instead of src/main/resources, cause Maven assumes (convention over configuration) that your java classes are located in src/main/java. This means they will never be compiled.
Upvotes: 4
Reputation: 122649
There is no explicit import for the User
class in your UserTest.java
file, which implies in should be somewhere in the org.tomasherman.JBTBackup.Resource.Entity
package.
However, there's no such file in either src/test/java/org/tomasherman/JBTBackup/Resource/Entity
or src/main/java/org/tomasherman/JBTBackup/Resource/Entity
.
I can't see anything in your POM file to generate this class potentially (like hbm2java). Maybe you've forgotten to commit it?
Upvotes: 2
Reputation: 116266
Note that Maven already failed to compile the classes to be tested:
[INFO] [compiler:compile {execution: default-compile}]
[INFO] No sources to compile
And @Gopi's comment explains why this happened. You should put your code under src/main/java
for Maven to see it by default.
Upvotes: 2
Reputation: 5894
Did you try to invoke mvn compile test-compile, or just mvn clean install ?
Upvotes: 1