Hello; I'm having another issue with the maven-embedded-glassfish-plugin
(version 3.1.1).
I am able to start the server and run a Maven failsafe test. The server
comes up and goes down exactly as I would expect so no issues there. Thanks
indirectly go to Alexis for
http://blogs.oracle.com/alexismp/entry/glassfish_embedded_and_javadb_embeddedwhich
provided me this recipe.
However, my integration test case that I run via maven-failsafe-plugin hangs
trying to establish a connection with a new InitialContext().lookup() call.
I have no other servers running on my box at the moment, so it's not a port
3700 conflict (port 3700 doesn't show up in a netstat listing; perhaps
there's some other way to rule out a port conflict?).
Here is (some of) my pom.xml configuration for my ear project. Some values
(versions, etc.) are inherited from a parent POM. I have more to say after
the excerpt below.
<dependencies>
<dependency>
<!-- for picking up all the stuff that needs to be there for new
IntialContext() to work properly -->
<groupId>org.glassfish.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<plugins>
<plugin>
<groupId>org.glassfish</groupId>
<artifactId>maven-embedded-glassfish-plugin</artifactId>
<version>${glassfishVersion}</version>
<configuration>
<goalPrefix>embedded-glassfish</goalPrefix>
<app>${project.build.directory}/${project.build.finalName}.ear</app>
<autoDelete>true</autoDelete>
<port>9292</port>
</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>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>Compile test classes</id>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>Run integration tests</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
That configuration causes everything to work properly: embedded glassfish
starts up fine, finds my .ear file, deploys it, and then
maven-failsafe-plugin takes over and runs my integration tests.
At this point my test class does this:
new
InitialContext().lookup("java:global/myapp/bozo-ejb-1.19-SNAPSHOT/HelloBean!com.foobar.HelloBean");
...which matches one of the global portable JNDI names that Glassfish tells
me it has established. The new InitialContext() call works fine; i.e. all
classes are loaded, it obviously tries to connect to Glassfish and--
--then the thing just sits there.
Eventually it dies with a communications error:
Caused by: java.net.ConnectException: Connection refused
at sun.nio.ch.Net.connect(Native Method)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:500)
at
com.sun.corba.ee.impl.orbutil.ORBUtility.openSocketChannel(ORBUtility.java:110)
at
org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:324)
...so for whatever reason something is not answering the phone on port 3700
(where CORBA normally does its thing).
Is there some kind of delay or sleep I have to bake in to my test? Is there
some other reason why my test would not be able to communicate with the
running Glassfish instance?
Best,
Laird