0

My question is similar to this one posted a while ago The autowiring of Spring Data Repos fail when the external libraries are in EAR's lib folder.

The wiring works fine when all jars are included in WEB-INF/lib. I tried setting the 'skinnyWar' to false but this is duplicating the jars in both EAR and WAR.

The application uses Spring Batch Admin 1.2.2 and Spring Data 1.1 with Spring 3.2.2 based. Maven Version used is 3.3. The runtime is Websphere 7.x

I have another application that works perfectly fine with skinnywar set to true - this uses spring-ws, spring-data 4.0.x version.

The WAR POM

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <artifactId>batchadmin-web</artifactId>
    <parent>
    <groupId>com.xyz.interfaces</groupId>
    <artifactId>batch-parent</artifactId>
    <version>1.0.BUILD-SNAPSHOT</version>
    <relativePath>../batch-parent/pom.xml</relativePath>
    </parent>
    <packaging>war</packaging>
    <name>Batch Admin Interface Web</name>
    <dependencies>
<!-- Application specific jars/modules Not included for brevity-->

    </dependencies>

    <build>
            <finalName>springbatch-admin</finalName>
            <outputDirectory>${project.basedir}\src\main\webapp\WEB-INF\classes</outputDirectory>
            <testOutputDirectory>${project.basedir}\src\main\webapp\WEB-INF\classes</testOutputDirectory>
            <plugins>
                    <plugin>
                            <artifactId>maven-war-plugin</artifactId>
                            <version>2.4</version>
                            <configuration>
                                    <archive>
                                             <manifest>
                                                    <addClasspath>true</addClasspath>
                                                    <classpathPrefix>lib/</classpathPrefix>
                                            </manifest>
                                     </archive>
                                       <packagingExcludes>WEB-INF/lib/spring-beans*.jar</packagingExcludes>  
                            </configuration>
                    </plugin>
            </plugins>
    </build>
    </project>

The EAR POM content:

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <artifactId>batchadmin-ear</artifactId>
    <parent>
    <groupId>com.xyz.interfaces</groupId>
    <artifactId>batch-parent</artifactId>
    <version>1.0.BUILD-SNAPSHOT</version>
    <relativePath>../batch-parent/pom.xml</relativePath>
    </parent>
    <packaging>ear</packaging>
    <name>Batch Admin Interface</name>
    <dependencies>
            <dependency>
                    <groupId>com.xyz.interfaces</groupId>
                    <artifactId>batchadmin-web</artifactId>
                    <type>war</type>
                    <version>${project.version}</version>
            </dependency>
    </dependencies>
    <build>
            <finalName>SpringBatchEAR</finalName>
            <plugins>
                    <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-ear-plugin</artifactId>
                            <version>2.9.1</version>

                            <configuration>
                                    <skinnyWars>true</skinnyWars>
                                    <defaultLibBundleDir>lib/</defaultLibBundleDir>
                                    <modules>
                                            <webModule>
                                                    <groupId>com.xyz.interfaces</groupId>
                                                    <artifactId>batchadmin-web</artifactId>
                                                    <contextRoot>/springbatch-admin</contextRoot>
                                                    <bundleFileName>springbatch-admin.war</bundleFileName>
                                            </webModule>
                                    </modules>

                            </configuration>
                    </plugin>
            </plugins>
    </build>

Update: Since the EAR has only one Web module, used 'Single class loader for application' for 'WAR class loader policy' in the Websphere. This way, I am able to make this work.

I would like to know how to make this work without changing the classloader option as this might not be preferred when multiple web modules are present.

Community
  • 1
  • 1
patb23
  • 387
  • 5
  • 21
  • First which maven version do you use? Which version of maven-ear-plugin, maven-war-plugin are you using and how does your pom look like (war, ear)... – khmarbaise Oct 17 '14 at 20:57
  • @khmarbaise, I have updated my question with the details of WAR and EAR POM content. – patb23 Oct 20 '14 at 13:19

0 Answers0