[ 
http://jira.codehaus.org/browse/SUREFIRE-427?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dan Fabulich closed SUREFIRE-427.
---------------------------------

    Resolution: Won't Fix

This one's definitely a puzzler!

I'm really not sure why this is happening.  My best guess is that jboss isn't 
looking for persistence.xml in the current classpath by normal means, but is 
instead attempting to determine its codebase directly and searching only in 
there.  (That would force it to look only in the target/classes directory and 
not in any other jar or directory on the classpath.)

Interestingly, I was able to reproduce this problem without any Maven at all.  
Using surefire.test.class.path from target/surefire-reports/TEST-TestSuite.xml, 
I constructed a command-line execution of TestNG that exhibited exactly the 
same problem:

java -cp 
C:\tmp\SUREFIRE-427_Test\target\test-classes;C:\tmp\SUREFIRE-427_Test\target\classes;c:\localrepo\javax\ejb\ejb-api\3.0\ejb-api-3.0.jar;c:\localrepo\javax\persistence\persistence-api\1.0\persistence-api-1.0.jar;c:\localrepo\javax\servlet\servlet-api\2.5\servlet-api-2.5.jar;c:\localrepo\org\testng\testng\5.5\testng-5.5-jdk15.jar;c:\localrepo\junit\junit\3.8.1\junit-3.8.1.jar;c:\localrepo\org\jboss\embedded\thirdparty-all\beta2\thirdparty-all-beta2.jar;c:\localrepo\org\hibernate\hibernate\3.2.4.sp1\hibernate-3.2.4.sp1.jar;c:\localrepo\javax\transaction\jta\1.0.1B\jta-1.0.1B.jar;c:\localrepo\asm\asm-attrs\1.5.3\asm-attrs-1.5.3.jar;c:\localrepo\dom4j\dom4j\1.6.1-jboss\dom4j-1.6.1-jboss.jar;c:\localrepo\antlr\antlr\2.7.6\antlr-2.7.6.jar;c:\localrepo\cglib\cglib\2.1_3\cglib-2.1_3.jar;c:\localrepo\asm\asm\1.5.3\asm-1.5.3.jar;c:\localrepo\javax\faces\jsf-api\1.2_04-p02\jsf-api-1.2_04-p02.jar;c:\localrepo\org\jboss\embedded\hibernate-all\beta2\hibernate-all-beta2.jar;c:\localrepo\org\jboss\seam\jboss-seam\2.0.0.GA\jboss-seam-2.0.0.GA.jar;c:\localrepo\jboss\javassist\3.3.ga\javassist-3.3.ga.jar;c:\localrepo\javax\el\el-api\1.0\el-api-1.0.jar;c:\localrepo\org\jboss\seam\jboss-el\2.0.0.GA\jboss-el-2.0.0.GA.jar;c:\localrepo\org\hibernate\hibernate-entitymanager\3.3.1.ga\hibernate-entitymanager-3.3.1.ga.jar;c:\localrepo\org\hibernate\hibernate-annotations\3.3.0.ga\hibernate-annotations-3.3.0.ga.jar;c:\localrepo\org\hibernate\hibernate-commons-annotations\3.0.0.ga\hibernate-commons-annotations-3.0.0.ga.jar;c:\localrepo\org\hibernate\hibernate-validator\3.0.0.GA\hibernate-validator-3.0.0.GA.jar;c:\localrepo\jboss\jboss-common-core\2.0.4.GA\jboss-common-core-2.0.4.GA.jar;c:\localrepo\org\jboss\embedded\jboss-embedded-all\beta2\jboss-embedded-all-beta2.jar;c:\localrepo\org\jboss\embedded\jboss-embedded-api\beta2\jboss-embedded-api-beta2.jar;c:\localrepo\org\jboss\embedded\jboss-deployers\beta2\jboss-deployers-beta2.jar;
 org.testng.TestNG -testclass 
au.com.prowse.cory.seammavenexample.security.userrole.UserRoleRepositoryLocalTest
 

(This command line works if you put persistence.xml back in src/main/resources 
and rebuild; it stops working again if you remove src/main/persistence.xml, 
clean, and rebuild.)

Since the problem reproduces without Surefire, it's hard to see what we could 
do in Surefire to fix it.

I predict that the only way to fix it will be to put your persistence.xml file 
in the same directory/folder as your main classes; I surmise that this is the 
way the JBoss team designed it to work, and that there's nothing we can do 
about it from our end.

If you can find an alternate TestNG command line that DOES work, let me know 
and Surefire can try to emulate it.  But I don't think there is one, so I'm 
going to mark this "Won't Fix."

P.S. I was also able to reproduce the strange 2.3/2.4 behavior; that should 
probably be filed as a bug against Maven Core.  (I think what's going on is the 
POM's parent [or one of its grandparents?] refers to Surefire 2.3; for some 
reason the parent is inappropriately overriding your declared pom.)


> persistence.xml being ignored in test path when in test/resources/META-INF
> --------------------------------------------------------------------------
>
>                 Key: SUREFIRE-427
>                 URL: http://jira.codehaus.org/browse/SUREFIRE-427
>             Project: Maven Surefire
>          Issue Type: Bug
>          Components: classloading, TestNG support
>    Affects Versions: 2.4
>         Environment: Ubuntu Linux 7.10 (Gutsy Gibbon)
> Java 1.5.0_11
> Maven 2.0.8
> TestNG 5.7 (jdk5)
>            Reporter: Cory Prowse
>            Priority: Blocker
>         Attachments: seamMavenExample-20080104.tar.bz2, SUREFIRE-427_Test.zip
>
>
> The file 
>   src/test/resources/META-INF/persistence.xml 
> is not included in the test path.
> When this file is moved to 
>   src/main/resources/META-INF/persistence.xml 
> then it is loaded correctly.
> The attached application will fail to build, complaining about no default 
> persistence unit in the deployment
> I'm confused why it isn't working as the META-INF directory in the test 
> resources does contain another file that IS picked up during the test by 
> JBoss Embedded (file: components.xml).
> This is using Maven 2.0.8 which explicitly states in its release notes:
>   "MNG-3118 - Test-classes should come before classes in the classpath. 
> This may slightly alter behavior of tests. The test-classes is now
> included first in the classpath to allow test resources to override
> normal runtime ones."
> I have emailed the users list and not received a response.  Is there anything 
> I could try to help?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira


Reply via email to