2

I've created a new project which will only run the integration test with

  • maven-ear-plugin
  • maven-failsafe-plugin
  • maven-embedded-glassfish-plugin

When I set the packaging to ear the ear file gets created, glassfish runs but the tests are being ignored and I get the following message

[failsafe:integration-test] No tests to run.

and glassfish undeploy fails

[embedded-glassfish:undeploy]
17/08/2012 10:08:17 AM PluginUtil doUndeploy
INFO: Deployer = com.sun.enterprise.admin.cli.embeddable.DeployerImpl@105f0f87
17/08/2012 10:08:17 AM com.sun.enterprise.loader.ASURLClassLoader$SentinelInputStream
report
WARNING: Input stream has been finalized or forced closed without being explicitly
closed; stream instantiation reported in following stack trace
java.lang.Throwable
at com.sun.enterprise.loader.ASURLClassLoader$SentinelInputStream.
(ASURLClassLoader.java:1230)

When I set the packing to jar I get

Running packageName.MyServiceTest
17/08/2012 10:09:34 AM com.sun.enterprise.v3.server.CommonClassLoaderServiceImpl
findDerbyClient
INFO: Cannot find javadb client jar file, derby jdbc driver will not be available by
default.
org.omg.CORBA.COMM_FAILURE: FINE: IOP00410001: Connection failure: socketType:
IIOP_CLEAR_TEXT; hostname: localhost; port: 3700 vmcid: OMG minor code: 1
completed: No
at sun.reflect.GeneratedConstructorAccessor27.newInstance(Unknown Source)

and glassfish does not start

I know it has to do something with Maven lifecycle that its not allowing me to create the ear file, start the glassfish embedded server and run integration tests in the same project.

Can someone please suggest me a solution ? I'm trying to create the ear file with just the EJB and Business entities project and deploy it to embedded glassfish server to run the integration test with maven-failsafe-plugin instead of deploying the ear file created by the parent pom.xml which adds UI and other projects into the ear file.

Here is my pom.xml file

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0

<parent>
    <groupId>company.MyProject</groupId>
    <artifactId>MyProject</artifactId>
    <version>3.8.1-SNAPSHOT</version>
</parent>

<artifactId>MyProject-integration-test</artifactId>
<packaging>jar</packaging>

<name>MyProject Integration Tests</name>

<properties>
    <ear-final-name>MyProject-integration-test-${project.version}</ear-final-name>
</properties>

<dependencies>
    <dependency>
        <groupId>org.glassfish.extras</groupId>
        <artifactId>glassfish-embedded-all</artifactId>
        <version>3.1.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.concordion</groupId>
        <artifactId>concordion</artifactId>
        <version>1.4.2</version>
        <scope>test</scope>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>org.concordion</groupId>
        <artifactId>concordion-extensions</artifactId>
        <version>1.0.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>MyProject-ejb</artifactId>
        <version>${project.version}</version>
        <type>ejb</type>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.aspose</groupId>
        <artifactId>aspose-words-jdk15</artifactId>
        <version>${aspose.libraryVersion}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>javax.persistence</groupId>
        <artifactId>persistence-api</artifactId>
        <version>1.0.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>hibernate-entitymanager</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>3.4.0.GA</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>3.3.2.GA</version>
    </dependency>
    <dependency>
        <groupId>hibernate-annotations</groupId>
        <artifactId>hibernate-annotations</artifactId>
        <version>3.4.0.GA</version>
    </dependency>
    <dependency>
        <groupId>hibernate-commons-annotations</groupId>
        <artifactId>hibernate-commons-annotations</artifactId>
        <version>3.4.0.GA</version>
    </dependency>
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc14</artifactId>
        <version>10.1.0.5.0</version>
    </dependency>
    <dependency>
        <groupId>ehcache</groupId>
        <artifactId>ehcache</artifactId>
        <version>1.2.3</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.6</version>
    </dependency>
    <dependency>
        <groupId>org-apache-commons-logging</groupId>
        <artifactId>org-apache-commons-logging</artifactId>
        <version>1.1.0</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ear-plugin</artifactId>
            <version>2.5</version>
            <configuration>
                <version>5</version>
                <displayName>MyProject</displayName>
                <defaultLibBundleDir>lib</defaultLibBundleDir>
                <finalName>${ear-final-name}</finalName>
                <name>MyProject-integration-test</name>
                <modules>
                    <ejbModule>
                        <groupId>company.MyProject</groupId>
                        <artifactId>MyProject-ejb</artifactId>
                        <bundleFileName>MyProject-ejb.jar</bundleFileName>
                    </ejbModule>
                    <jarModule>
                        <groupId>company.MyProject</groupId>
                        <artifactId>MyProject-business-entities</artifactId>
                        <bundleFileName>MyProject-business-entities-3.8.1-SNAPSHOT.jar</bundleFileName>
                    </jarModule>
                    <jarModule>
                        <groupId>company.MyProject</groupId>
                        <artifactId>MyProject-util</artifactId>
                        <bundleFileName>MyProject-util-3.8.1-SNAPSHOT.jar</bundleFileName>
                    </jarModule>
                </modules>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.12</version>
            <executions>
                <execution>
                    <id>failsafe-integration-tests</id>
                    <phase>integration-test</phase>
                    <goals>
                        <goal>integration-test</goal>
                    </goals>
                </execution>
                <execution>
                    <id>failsafe-verify</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                    <version>4.8.2</version>
                </dependency>
            </dependencies>
        </plugin>

        <plugin>
            <groupId>org.glassfish</groupId>
            <artifactId>maven-embedded-glassfish-plugin</artifactId>
            <version>3.1.1</version>
            <configuration>
                <goalPrefix>embedded-glassfish</goalPrefix>
                <autoDelete>true</autoDelete>
                <app>${basedir}/target/MyProject-integration-test-${project.version}.ear</app> 
                <port>8080</port>
                <configFile>src/test/resources/glassfish/config/domain.xml</configFile>
            </configuration>
            <executions> 
                <execution>
                    <id>start-glassfish</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>start</goal>
                    </goals>
                </execution>
                <execution>
                    <id>glassfish-deploy</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>deploy</goal>
                    </goals>
                </execution>
                <execution>
                    <id>glassfish-undeploy</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>undeploy</goal>
                    </goals>
                </execution>

                <execution>
                    <id>stop-glassfish</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions> 
        </plugin> 
    </plugins>

</build>

Dev2
  • 153
  • 1
  • 9

3 Answers3

1

Yep, it working now. Turns out the problem was with my domain.xml file. The default domain.xml comes with the port numbers with prefix 2 which should be removed and in embedded glassfish 3.1 < port> 8080 < /port> does not work if < configFile> is set (ref this doco) http://embedded-glassfish.java.net/nonav/plugindocs/3.1/stop-mojo.html.

I just had to set IIOP port in domain.xml to 3700 and in my test

 Properties props = new Properties();  
 props.put("org.omg.CORBA.ORBInitialPort", "3700");
 Context ctx = new InitialContext(props);   

Thanks guys

Dev2
  • 153
  • 1
  • 9
0

You can do the packaging and starting the glassfish in a single call.

have you tried:

mvn verify 

to do so?

khmarbaise
  • 92,914
  • 28
  • 189
  • 235
  • Yep, i've tried that. Running mvn verify produced the above results. We are now going to try Arquillian. Hopefully it will be easier to deploy an ear file with arquillian onto glassfish and run integration tests. – Dev2 Aug 19 '12 at 05:33
  • Can you please tell me how can get an Instance of the Glassfish started by maven in my testcase? – Dev2 Aug 22 '12 at 00:56
  • Yep, it working now. Turns out the problem was with my domain.xml file. The default domain.xml comes with the port numbers with prefix 2 which should be removed and in embedded glassfish 3.1 8080 does not work if is set (ref this doco) http://embedded-glassfish.java.net/nonav/plugindocs/3.1/stop-mojo.html. I just had to set IIOP port in domain.xml to 3700 and in my test Properties props = new Properties(); props.put("org.omg.CORBA.ORBInitialPort", "3700"); Context ctx = new InitialContext(props); Thanks guys – Dev2 Aug 22 '12 at 12:26
0

Possibly another solution to specify the IIOP ports of Glassfish (first it is necessary to confirm the server IP and IIOP listener ports):

System.setProperty("org.omg.CORBA.ORBInitialHost", "127.0.0.1");
System.setProperty("org.omg.CORBA.ORBInitialPort", "8037");
Context ctx = new InitialContext();