Cobertura plugin missing Spring classes in classpath?

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

Cobertura plugin missing Spring classes in classpath?

by Dmitry Matyukhin-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm a Maven novice and I'm trying to use Cobertura plugin in a
multi-module project.

After configuring Coberbura plugin to run in the site phase there are
multiple ClassNotFoundExceptions.
Though, in the regular "mvn clean test" run there are no issues and
all tests go through okay.

I also tried to use Cobertura plugin in a regular fashion (configuring
it to be run in the verify phase) but it got exactly the same
exceptions.

I'm attaching the poms for parent and module projects as well as
Spring configuration, the unit-test class and the 'mvn site' log.

Can anyone help me with properconfiguration?

Thanks,
Dmitry

<?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>
    <groupId>org.nskmda.routemap</groupId>
    <artifactId>backend</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>Back-End</name>
    <url>http://maven.apache.org</url>

    <repositories>
        <repository>
            <id>java.net</id>
            <url>http://download.java.net/maven/1</url>
            <layout>legacy</layout>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>apache.org</id>
            <name>Maven Plugin Snapshots</name>
            <url>http://people.apache.org/repo/m2-snapshot-repository</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.4</version>
            </dependency>
            <dependency>
                <groupId>org.jmock</groupId>
                <artifactId>jmock-junit4</artifactId>
                <version>2.5.1</version>
            </dependency>
            <dependency>
                <groupId>javaee</groupId>
                <artifactId>javaee-api</artifactId>
                <version>5</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <version>2.5.6</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aspects</artifactId>
                <version>2.5.6</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aop</artifactId>
                <version>2.5.6</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>2.5.6</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-orm</artifactId>
                <version>2.5.6</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-dao</artifactId>
                <version>2.0.8</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-test</artifactId>
                <version>2.5.6</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-jdbc</artifactId>
                <version>2.5.6</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
                <version>3.4.0.GA</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
                <version>3.4.0.GA</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-annotations</artifactId>
                <version>3.4.0.GA</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
                <version>1.5.2</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jmock</groupId>
            <artifactId>jmock-junit4</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javaee</groupId>
            <artifactId>javaee-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.8.0-BETA</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-dao</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.3.1</version>
                <configuration>
                    <includes>
                        <include>**/*Test.java</include>
                    </includes>
                    <forkMode>once</forkMode>
                    <junitArtifactName>junit:junit-dep</junitArtifactName>
                </configuration>
            </plugin>
<!--
            <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>cobertura-maven-plugin</artifactId>
                <executions>
                        <execution>
                                <goals>
                                        <goal>clean</goal>
                                        <goal>check</goal>
                                </goals>
                        </execution>
                </executions>
            </plugin>
-->
        </plugins>
    </build>

        <reporting>
            <plugins>
              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                <targetJdk>1.5</targetJdk>
                </configuration>
              </plugin>
                        <plugin>
                                <groupId>org.codehaus.mojo</groupId>
                                <artifactId>cobertura-maven-plugin</artifactId>
                        </plugin>
            </plugins>
          </reporting>


    <modules>
        <module>model</module>
        <module>dao-interface</module>
        <module>dao-implementation</module>
    <module>services-interface</module>
        <module>services-implementation</module>
  </modules>

</project>
<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/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>org.nskmda.routemap</groupId>
    <artifactId>dao-implementation</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>dao-implementation</name>
    <url>http://maven.apache.org</url>

    <parent>
        <groupId>org.nskmda.routemap</groupId>
        <artifactId>backend</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <pluginRepositories>
        <pluginRepository>
            <id>codehaus-mojo</id>
            <url>http://repository.codehaus.org/org/codehaus/mojo/</url>
        </pluginRepository>
    </pluginRepositories>
    <dependencies>
        <dependency>
            <groupId>org.nskmda.routemap</groupId>
            <artifactId>model</artifactId>
            <version>${version}</version>
        </dependency>
        <dependency>
            <groupId>org.nskmda.routemap</groupId>
            <artifactId>dao-interface</artifactId>
            <version>${version}</version>
        </dependency>
        <dependency>
            <groupId>hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
            <version>1.8.0.7</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.8.0</version>
        </dependency>
    </dependencies>

    <build>
        <testResources>
            <testResource>
                <directory>${basedir}/src/test/resources</directory>
                <filtering>true</filtering>
            </testResource>
            <testResource>
                <directory>${basedir}/src/test/resources/META-INF</directory>
                <filtering>true</filtering>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>sql-maven-plugin</artifactId>
                <version>1.3</version>

                <dependencies>
                    <dependency>
                        <groupId>hsqldb</groupId>
                        <artifactId>hsqldb</artifactId>
                        <version>1.8.0.7</version>
                        <scope>test</scope>
                    </dependency>
                </dependencies>

                <configuration>
                    <driver>org.hsqldb.jdbcDriver</driver>
                    <url>jdbc:hsqldb:file:testdb;shutdown=true</url>
                    <username>sa</username>
                    <password/>
                    <printResultSet>true</printResultSet>
                    <!-- the servers/server/id[.=${settingsKey}/(username|password) may be configured in the settings.xml] -->
                    <!--<settingsKey>sensibleKey</settingsKey>-->
                    <!--all executions are ignored if -Dmaven.test.skip=true-->
                    <!--<skip>${maven.test.skip}</skip>-->
                    <onError>abort</onError>
                </configuration>

                <executions>
                    <execution>
                        <id>create-schema</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <autocommit>true</autocommit>
                            <fileset>
                                <basedir>${basedir}</basedir>
                                <includes>
                                    <include>src/test/resources/sql/setup.sql</include>
                                </includes>
                            </fileset>
                             <onError>continue</onError>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>


<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
                        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
                        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">

    <context:annotation-config/>

        <bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
                <property name="entityManagerFactory" ref="hibernateEntityManagerFactory"/>
        </bean>

<!--
        <tx:advice id="txAdvice" transaction-manager="txManager">
                <tx:attributes>
                        <tx:method name="*" propagation="REQUIRED" />
                </tx:attributes>
        </tx:advice>

        <aop:config>
                <aop:pointcut id="routeMapDaoPointcut" expression="execution(* org.nskmda.routemap.dao.intf.RouteMapDao.*(..))"/>
                <aop:advisor advice-ref="txAdvice" pointcut-ref="routeMapDaoPointcut"/>
        </aop:config>

-->

    <bean id="hibernateEntityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
        <property name="persistenceUnitName" value="hibernatePersistenceUnit"/>
    </bean>

    <bean id="routeMapDao" class="org.nskmda.routemap.dao.impl.RouteMapDaoEJBImpl" />

</beans>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

mvn_site.log (278K) Download Attachment

Parent Message unknown Re: Cobertura plugin missing Spring classes in classpath?

by Dmitry Matyukhin-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, all

In case anyone is still interested.
I managed to resolve the issue.
A couple of tips:
- I used spring-dao v. 2.0.8. Somehow Surefire plugin used to get spring-beans
v. 2.5.6 while Cobertura plugin still ran Surefire with spring-beans v. 2.0.8
which caused ClassNotFoundException to be thrown by Spring (since all other
Spring artifacts were of v. 2.5.6). After exactly specifying spring-beans v.
2.5.6 dependency this issue disappeared. Need to check if exact version for
spring-beans is still needed with newer v. 2.3 of Cobertura plugin (announced
today).
- After solving this got actual issue with the "java.lang.ClassFormatError:
Absent Code" error (see
http://www.nabble.com/JUnit-tests-requiring-j2ee.jar-fail-when-running-mvn-surefire:test-td15060503.html).
The problem was resolved after switching to actual javaee classes from the same
java.net maven repository. Actually, any of other open source implementations
could be used (like Geronimo or GlassFish).

Hope, this helps.

Dmitry


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

    http://xircles.codehaus.org/manage_email