You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by lsacco <oc...@gmail.com> on 2008/11/04 21:08:21 UTC
Surefire 2.4.3 Classloading issue
I've read the previous posts on this issue, but still see that a resource I
am relying on (META-INF/persistence.xml) that exists in src/test/resources
is not being used by the surefire plugin. If I move this resource to
src/main/resources it works fine. I am using Maven 2.0.9.
Any ideas why src/test/resources doesn't take precedence?
TIA,
Lou
--
View this message in context: http://www.nabble.com/Surefire-2.4.3-Classloading-issue-tp20330022p20330022.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Surefire 2.4.3 Classloading issue
Posted by lsacco <oc...@gmail.com>.
Yes, that's correct. I have my production persistence.xml in
src/main/resources/META-INF that will use Oracle, but for integration
testing I want to use HSQLDB, so I have a persistence.xml in
src/test/resources/META-INF to *override* the main resource. When I compile
I definitely see two distinct persistence.xml's and the one I want to use
for testing resides in target/test-classes as I would expect. However, this
one is not being used and instead the Oracle based one is being used that's
in target/classes.
I'm completely baffled by this because when I review the manifest for the
jar that is created it shows test-classes as first (rightly so):
Manifest-Version: 1.0
Class-Path:
file:/C:/Documents%20and%20Settings/lsacco/.m2/repository/org/apache/maven/surefire/surefire-booter/2.4.3/surefire-booter-2.4.3.jar
file:/C:/Documents%20and%20Settings/lsacco/.m2/repository/org/apache/maven/surefire/surefire-api/2.4.3/surefire-api-2.4.3.jar
file:/C:/eclipse_workspaces/europa3/PCNRequestApprovalWeb/target/test-classes/
file:/C:/eclipse_workspaces/europa3/PCNRequestApprovalWeb/target/classes/
classPathUrl.1=C\:\\eclipse_workspaces\\europa3\\PCNRequestApprovalWeb\\target\\classes
classPathUrl.0=C\:\\eclipse_workspaces\\europa3\\PCNRequestApprovalWeb\\target\\test-classes
Mucking around with forkMode=never or useSystemClassOnly=false|true or the
manifest-jar=false (which I can't use because my cmdline args > 8092),
results in none of my tests working (even the non-db integration ones), so
the best bet is the settings in the previous post. As I said previously, I
can exclude the persistence.xml from the main resources and then all tests
run, but obviously the resulting build artifact will be unusable.
-Lou
Baptiste MATHUS-4 wrote:
>
> Why do you speak about "precedence"? Do you have many persistence.xml
> files?
> When you just do "compiler:*testCompile", what do you have in your target
> subdirs?* Do you see persistence.xml file?
>
> If the resources seems to be present in those dirs, then also try using
> forkMode=never to see if that could be a problem of classloading.
>
> My 2 cents...
> Cheers.
>
> --
> Baptiste <Batmat> MATHUS - http://batmat.net
> Sauvez un arbre,
> Mangez un castor !
>
>
--
View this message in context: http://www.nabble.com/Surefire-2.4.3-Classloading-issue-tp20330022p20348813.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Surefire 2.4.3 Classloading issue
Posted by Baptiste MATHUS <ml...@batmat.net>.
Why do you speak about "precedence"? Do you have many persistence.xml files?
When you just do "compiler:*testCompile", what do you have in your target
subdirs?* Do you see persistence.xml file?
If the resources seems to be present in those dirs, then also try using
forkMode=never to see if that could be a problem of classloading.
My 2 cents...
Cheers.
2008/11/4 lsacco <oc...@gmail.com>
>
> I've read the previous posts on this issue, but still see that a resource I
> am relying on (META-INF/persistence.xml) that exists in src/test/resources
> is not being used by the surefire plugin. If I move this resource to
> src/main/resources it works fine. I am using Maven 2.0.9.
>
> Any ideas why src/test/resources doesn't take precedence?
>
> TIA,
> Lou
> --
> View this message in context:
> http://www.nabble.com/Surefire-2.4.3-Classloading-issue-tp20330022p20330022.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
--
Baptiste <Batmat> MATHUS - http://batmat.net
Sauvez un arbre,
Mangez un castor !
Re: Surefire 2.4.3 Classloading issue
Posted by lsacco <oc...@gmail.com>.
I went ahead and skipped trying to resolve this in surefire. Here's the
solution should anyone need it for Spring-JPA integration:
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="persistenceXmlLocation"
value="classpath:META-INF/persistence.xml" />
</bean>
--
View this message in context: http://www.nabble.com/Surefire-2.4.3-Classloading-issue-tp20330022p20353573.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Surefire 2.4.3 Classloading issue
Posted by lsacco <oc...@gmail.com>.
After running mvn help:effective-pom I see the plugin being set as expected:
<sourceDirectory>C:\eclipse_workspaces\europa3\PCNRequestApprovalWeb\src\main\java</sourceDirectory>
<testSourceDirectory>C:\eclipse_workspaces\europa3\PCNRequestApprovalWeb\src\test\java</testSourceDirectory>
<outputDirectory>C:\eclipse_workspaces\europa3\PCNRequestApprovalWeb\target\classes</outputDirectory>
<testOutputDirectory>C:\eclipse_workspaces\europa3\PCNRequestApprovalWeb\target\test-classes</testOutputDirectory>
<defaultGoal>install</defaultGoal>
<resources>
<resource>
<directory>C:\eclipse_workspaces\europa3\PCNRequestApprovalWeb\src\main\resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>C:\eclipse_workspaces\europa3\PCNRequestApprovalWeb/src/test/resources</directory>
<includes>
<include>**/*.xml</include>
<include>import.sql</include>
</includes>
</testResource>
</testResources>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<childDelegation>true</childDelegation>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<argLine>-Xmx512m</argLine>
<forkMode>once</forkMode>
<includes>
<include>**/*Test*.java</include>
<include>**/Test*.java</include>
</includes>
</configuration>
</plugin>
When I run the -X option I see that the test-classes directory is first
ahead of classes, yet if I exclude *.xml, import.sql from the resources it
will work fine, but of course, that's not an acceptable solution.
[DEBUG] Configuring mojo
'org.apache.maven.plugins:maven-surefire-plugin:2.4.3:test' -->
[DEBUG] (f) argLine = -Xmx512m
[DEBUG] (f) basedir = C:\eclipse_workspaces\europa3\PCNRequestApprovalWeb
[DEBUG] (f) childDelegation = true
[DEBUG] (f) classesDirectory =
C:\eclipse_workspaces\europa3\PCNRequestApprovalWeb\target\classes
[DEBUG] (f) classpathElements =
[C:\eclipse_workspaces\europa3\PCNRequestApprovalWeb\target\test-classes,
C:\eclipse_workspaces\europa3\PCNRequestApprovalWeb\target\classes,
Any ideas why this might be the case?
Lou
--
View this message in context: http://www.nabble.com/Surefire-2.4.3-Classloading-issue-tp20330022p20334699.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org