Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2e-users] WAR dependency not working in m2e

On a follow-up, I attach a simple test case with a parent and 2 modules.
- module1 is WAR
- module2 is jar

If you run "mvn test" in the parent, it works.

If you import it into eclipse and try to run module2's CopiedSpringPropertiesTest:

java.io.FileNotFoundException: class path resource [originalApplicationContext.xml] cannot be opened because it does not exist
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)

originalApplicationContext.xml is in module1.
I installed m2e-wtp in my Eclipse, but the configuration in the zip file doesn't work.

Perhaps this is easier to understand what the problem might be.

Cheers,

Miguel Almeida

On Wed, Nov 16, 2011 at 2:43 PM, Miguel Almeida <migueldealmeida@xxxxxxxxx> wrote:
Dear all,

I have a following project structure configured in Eclipse Indigo:

-parent:
----------acceptance
----------webApp (type war)

My acceptance depends on webApp, so I added the dependency:

        <dependency>(...)
            <artifactId>webApp</artifactId>
            <scope>test</scope>
            <type>TYPE</type>
        </dependency>

When TYPE=WAR my junit tests fail in Eclipse. If TYPE=jar they work correctly, but my CI server (and maven in CLI, I presume) will fail saying they can't find webApp.jar.

I read something about this in http://ykyuen.wordpress.com/2009/10/30/maven-dependency-on-jarwar-package/, so I decided to give it a go:
- My maven-war-plugin snippet at webApp became [1]
- I added <classifier>classes</classifier> to the dependency in acceptance.

While both my CI server and "mvn test" work correctly, running an acceptance test from Eclipse fails as before, with a java.lang.ExceptionInInitializerError tracked down to "java.io.FileNotFoundException: class path resource [spring-sessionFactory.xml] cannot be opened because it does not exist". This file is in webApp/src/main/resources.


Could you tell me what I am doing wrong? Do you know what is causing this and what the correct configuration should be?

Cheers,

Miguel Almeida

[1]
<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                        <manifestEntries>
                            <Implementation-Build>${buildNumber}</Implementation-Build>
                        </manifestEntries>
                    </archive>
                    <webResources>
                        <resource>
                            <directory>${basedir}/src/main/webapp/WEB-INF</directory>
                            <filtering>true</filtering>
                            <targetPath>WEB-INF</targetPath>
                            <includes>
                                <include>**/config.xml</include>
                            </includes>
                        </resource>
                    </webResources>
                    <attachClasses>true</attachClasses>
                    <classesClassifier>classes</classesClassifier>
                </configuration>
            </plugin>

Attachment: testCase.zip
Description: Zip archive


Back to the top