Maven2 test not finding src/resources/META-INF/persistence.xml

View: New views
4 Messages — Rating Filter:   Alert me  

Maven2 test not finding src/resources/META-INF/persistence.xml

by Ryan de Laplante :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This message is cross posted in nbusers mailing list. I just remembered someone telling me that this mailing list is more appropriate for maven questions.  

Hi,

I have a maven2 project and has a persistence.xml in  src/main/resources/META-INF/ and src/test/resources/META-INF/.   I've got a dependency on TopLink JPA provider configured. When I execute the test it uses the persistence.xml from main instead of test folder.  When I rename the main persistence.xml (leaving the test one named properly), then no persistence.xml is found.

Any idea what is happening?

FYI Spring 2.5.5 is the JPA container. It is trying to initialize a PU to inject it into an entityManagerFactory bean.


Thanks,
Ryan

Re: Maven2 test not finding src/resources/META-INF/persistence.xml

by Ryan de Laplante :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I found this ticket:

http://jira.codehaus.org/browse/SUREFIRE-427

They were using the JBoss EJB container in unit tests and having the same problem.  They ended up deciding that the problem was not Maven surefire plugin, but the EJB container.  That made me wonder if my problem is the Spring container.

I found that I could specify the path to the persistenceXml file in my spring xml file:

<bean id="entityManagerFactory" class= "org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="persistenceXmlLocation" value="file:/home/ryan/dev/MyProject/src/test/resources/META-INF/persistence.xml"/>
...

And now I'm past this problem.  Well, except the fact that I must specify the full path.  No matter what I enter using classpath: prefix doesn't work.  I don't know what Spring thinks the classpath is, or how that even gets set.


Thanks,
Ryan

Re: Maven2 test not finding src/resources/META-INF/persistence.xml [SOLVED]

by Ryan de Laplante :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This works for me in my test's applicationContext.xml

<property name="persistenceXmlLocation" value="META-INF/persistence.xml"/>


Thanks,
Ryan

Re: Maven2 test not finding src/resources/META-INF/persistence.xml

by Cyrill Rüttimann-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

We discovered this week that a specific combination of maven and  
surefire plugin versions produce different behaviour regarding the  
class loading strategy. For example maven-2.0.7 and surefire-2.4.3 the  
classpath is classes first and second test-classes. This is what  
happens to you, right? If you run maven-2.0.9 and surefire-2.4.2 you  
are fine.

Just turn on debugging and watch the classpath maven uses.


Regards,


On 12.09.2008, at 16:15, Ryan de Laplante wrote:

>
> This message is cross posted in nbusers mailing list. I just  
> remembered
> someone telling me that this mailing list is more appropriate for  
> maven
> questions.
>
> Hi,
>
> I have a maven2 project and has a persistence.xml in
> src/main/resources/META-INF/ and src/test/resources/META-INF/.    
> I've got a
> dependency on TopLink JPA provider configured. When I execute the  
> test it
> uses the persistence.xml from main instead of test folder.  When I  
> rename
> the main persistence.xml (leaving the test one named properly), then  
> no
> persistence.xml is found.
>
> Any idea what is happening?
>
> FYI Spring 2.5.5 is the JPA container. It is trying to initialize a  
> PU to
> inject it into an entityManagerFactory bean.
>
>
> Thanks,
> Ryan
>
> --
> View this message in context: http://www.nabble.com/Maven2-test-not-finding-src-resources-META-INF-persistence.xml-tp19456760p19456760.html
> Sent from the mevenide - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email