bmatthews68 / inmemdb-maven-plugin

A Maven 3 plug-in that can be used to launch an in-memory database for use in integration tests. Apache Derby and HSQLDB are both supported.
http://inmemdb-maven-plugin.btmatthews.com
Apache License 2.0
15 stars 7 forks source link

centos 6.5 java.net.BindException: Cannot assign requested address #15

Closed gregh3269 closed 8 years ago

gregh3269 commented 10 years ago

Hello,

I am trying to use this plugin on centos 6.5 but I get a java.net.BindException: Cannot assign requested address.

[INFO] --- inmemdb-maven-plugin:1.3.0:run (run) @ roller-webapp --- [INFO] Configured database port: 4224 [INFO] Configured database username: APP [INFO] Configured database password: APP [INFO] Configured database name: rollerdb [INFO] [INFO] --- maven-surefire-plugin:2.16:test (default-test) @ roller-webapp --- [ERROR] Error starting or stopping the monitor java.net.BindException: Cannot assign requested address at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376) at java.net.ServerSocket.bind(ServerSocket.java:376) at java.net.ServerSocket.(ServerSocket.java:237) at com.btmatthews.utils.monitor.Monitor.runMonitor(Monitor.java:82) at com.btmatthews.utils.monitor.Monitor$1.run(Monitor.java:108) at java.lang.Thread.run(Thread.java:722)

I have checked port 4224 and its not in use.

The exception does not give enough information on which port it cannot assign, and I have looked at the source also.

Adding the element made no difference.

Have you any ideas on what port it wants?

        <plugin>
            <groupId>com.btmatthews.maven.plugins.inmemdb</groupId>
            <artifactId>inmemdb-maven-plugin</artifactId>
            <configuration>
                <monitorKey>inmemdb</monitorKey>
                <monitorPort>11527</monitorPort>
            </configuration>
            <executions>
                <execution>
                    <id>run</id>
                    <phase>test-compile</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <daemon>true</daemon>
                        <type>derby</type>
                        <database>rollerdb</database>
                        <username>APP</username>
                        <password>APP</password>
                        <port>4224</port>
                        <sources>
                            <script>
                                <sourceFile>${pom.basedir}/target/dbscripts/derby/createdb.sql</sourceFile>
                            </script>
                        </sources>
                    </configuration>
                </execution>
                <execution>
                    <id>stop</id>
                    <phase>package</phase>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

Cheers Greg

bmatthews68 commented 10 years ago

Hi Greg,

The stack trace implies that the conflict is on the monitor port (11527). This port is monitored by the plugin's control thread waiting for a shutdown command. You can use any free port number for this. It is configured by the element.

Kind regards, Brian

On 8 January 2014 07:57, gregh3269 notifications@github.com wrote:

Hello,

I am trying to use this plugin on centos 6.5 but I get a java.net.BindException: Cannot assign requested address.

[INFO] --- inmemdb-maven-plugin:1.3.0:run (run) @ roller-webapp --- [INFO] Configured database port: 4224 [INFO] Configured database username: APP [INFO] Configured database password: APP [INFO] Configured database name: rollerdb [INFO]

[INFO] --- maven-surefire-plugin:2.16:test (default-test) @ roller-webapp

[ERROR] Error starting or stopping the monitor java.net.BindException: Cannot assign requested address at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376) at java.net.ServerSocket.bind(ServerSocket.java:376) at java.net.ServerSocket.(ServerSocket.java:237) at com.btmatthews.utils.monitor.Monitor.runMonitor(Monitor.java:82) at com.btmatthews.utils.monitor.Monitor$1.run(Monitor.java:108) at java.lang.Thread.run(Thread.java:722)

I have checked port 4224 and its not in use.

The exception does not give enough information on which port it cannot assign, and I have looked at the source also.

Adding the element made no difference.

Have you any ideas on what port it wants?

    <plugin>
        <groupId>com.btmatthews.maven.plugins.inmemdb</groupId>
        <artifactId>inmemdb-maven-plugin</artifactId>
        <configuration>
            <monitorKey>inmemdb</monitorKey>
            <monitorPort>11527</monitorPort>
        </configuration>
        <executions>
            <execution>
                <id>run</id>
                <phase>test-compile</phase>
                <goals>
                    <goal>run</goal>
                </goals>
                <configuration>
                    <daemon>true</daemon>
                    <type>derby</type>
                    <database>rollerdb</database>
                    <username>APP</username>
                    <password>APP</password>
                    <port>4224</port>
                    <sources>
                        <script>
                            <sourceFile>${pom.basedir}/target/dbscripts/derby/createdb.sql</sourceFile>
                        </script>
                    </sources>
                </configuration>
            </execution>
            <execution>
                <id>stop</id>
                <phase>package</phase>
                <goals>
                    <goal>stop</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

Cheers Greg

— Reply to this email directly or view it on GitHubhttps://github.com/bmatthews68/inmemdb-maven-plugin/issues/15 .

gregh3269 commented 10 years ago

Brian,

thanks for the quick response, I get:

[gregh@dev app]$ cat /etc/services | grep 11527 [gregh@dev app]$

ie not in use.

Cheers Greg

gregh3269 commented 10 years ago

Brian,

Also for: mvn clean install -Dmaven.test.skip=true

shows:

[INFO] --- inmemdb-maven-plugin:1.3.0:run (run) @ roller-webapp --- [INFO] Configured database port: 4224 [INFO] Configured database username: APP [INFO] Configured database password: APP [INFO] Configured database name: rollerdb [INFO] [INFO] --- maven-surefire-plugin:2.16:test (default-test) @ roller-webapp --- [ERROR] Error starting or stopping the monitor java.net.BindException: Cannot assign requested address at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376) at java.net.ServerSocket.bind(ServerSocket.java:376) at java.net.ServerSocket.(ServerSocket.java:237) at com.btmatthews.utils.monitor.Monitor.runMonitor(Monitor.java:82) at com.btmatthews.utils.monitor.Monitor$1.run(Monitor.java:108) at java.lang.Thread.run(Thread.java:722) [INFO] Tests are skipped.

[INFO] --- inmemdb-maven-plugin:1.3.0:stop (stop) @ roller-webapp --- [INFO] Sending command "stop" to monitor [ERROR] Error sending command to monitor java.net.NoRouteToHostException: No route to host at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391) at java.net.Socket.connect(Socket.java:579) at java.net.Socket.connect(Socket.java:528) at java.net.Socket.(Socket.java:425) at java.net.Socket.(Socket.java:241) at com.btmatthews.utils.monitor.Monitor.sendCommand(Monitor.java:190) at com.btmatthews.utils.monitor.mojo.AbstractStopMojo.execute(AbstractStopMojo.java:40) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:318) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214) at org.apache.maven.cli.MavenCli.main(MavenCli.java:158) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:414) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:357) [INFO] [INFO] --- maven-install-plugin:2.4:install (default-install) @ roller-webapp ---

bmatthews68 commented 10 years ago

Hi Greg,

Use the following to see if the port is in use:

$ netstat -a | grep 11527

The plugin does not currently respect skipping tests. I hadn't thought of adding that before now but I will go ahead and add it.

Brian

On 8 January 2014 08:08, gregh3269 notifications@github.com wrote:

Brian,

Also for: mvn clean install -Dmaven.test.skip=true

shows:

[INFO] --- inmemdb-maven-plugin:1.3.0:run (run) @ roller-webapp --- [INFO] Configured database port: 4224 [INFO] Configured database username: APP [INFO] Configured database password: APP [INFO] Configured database name: rollerdb [INFO]

[INFO] --- maven-surefire-plugin:2.16:test (default-test) @ roller-webapp

[ERROR] Error starting or stopping the monitor java.net.BindException: Cannot assign requested address at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376) at java.net.ServerSocket.bind(ServerSocket.java:376) at java.net.ServerSocket.(ServerSocket.java:237) at com.btmatthews.utils.monitor.Monitor.runMonitor(Monitor.java:82) at com.btmatthews.utils.monitor.Monitor$1.run(Monitor.java:108) at java.lang.Thread.run(Thread.java:722) [INFO] Tests are skipped.

[INFO] --- inmemdb-maven-plugin:1.3.0:stop (stop) @ roller-webapp --- [INFO] Sending command "stop" to monitor [ERROR] Error sending command to monitor java.net.NoRouteToHostException: No route to host at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391) at java.net.Socket.connect(Socket.java:579) at java.net.Socket.connect(Socket.java:528) at java.net.Socket.(Socket.java:425) at java.net.Socket.(Socket.java:241) at com.btmatthews.utils.monitor.Monitor.sendCommand(Monitor.java:190) at com.btmatthews.utils.monitor.mojo.AbstractStopMojo.execute(AbstractStopMojo.java:40) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:318) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214) at org.apache.maven.cli.MavenCli.main(MavenCli.java:158) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:414) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:357) [INFO] [INFO] --- maven-install-plugin:2.4:install (default-install) @ roller-webapp ---

— Reply to this email directly or view it on GitHubhttps://github.com/bmatthews68/inmemdb-maven-plugin/issues/15#issuecomment-31812281 .

gregh3269 commented 10 years ago

Brian,

[gregh@dev app]$ netstat -a | grep 11527 [gregh@dev app]$

Same result ie not in use.

Is the configuration element in the correct place?

Cheers Greg.

bmatthews68 commented 10 years ago

The configuration is in the correct place. Would you be able to send me your full pom.xml?

I will continue to investigate. And am also adding an inmemdb.skip flag that you will be able to use to ignore skip the inmemdb plugin execution.

Kind regards, Brian

On 8 January 2014 08:40, gregh3269 notifications@github.com wrote:

Brian,

[gregh@dev app]$ netstat -a | grep 11527 [gregh@dev app]$

Same result ie not in use.

Is the in the correct place?

Cheers Greg.

— Reply to this email directly or view it on GitHubhttps://github.com/bmatthews68/inmemdb-maven-plugin/issues/15#issuecomment-31813750 .

gregh3269 commented 10 years ago

Brian,

Same the roller project default, except for the port to 4224 and the configuration element.

Also my centos is standard.

<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>

<parent>
    <groupId>org.apache.roller</groupId>
    <artifactId>roller-project</artifactId>
    <version>5.1.0-SNAPSHOT</version>
    <relativePath>../pom.xml</relativePath>
</parent>

<name>Roller Webapp</name>
<artifactId>roller-webapp</artifactId>
<packaging>war</packaging>

<properties>
    <testOutputDirectory>${project.build.testOutputDirectory}</testOutputDirectory>
    <testMediaDir>${project.build.testOutputDirectory}${file.separator}mediafiles</testMediaDir>
    <testUploadsDir>${project.build.testOutputDirectory}${file.separator}uploadsdir</testUploadsDir>
    <testThemesDir>${project.build.testOutputDirectory}${file.separator}themes</testThemesDir>
    <testIndexDir>${project.build.testOutputDirectory}${file.separator}index</testIndexDir>
    <testPlanetCache>${project.build.testOutputDirectory}${file.separator}planetcache</testPlanetCache>
    <lucene.version>4.6.0</lucene.version>
    <spring.version>3.2.4.RELEASE</spring.version>
    <spring.security.version>3.1.4.RELEASE</spring.security.version>
</properties>

<dependencies>

    <!-- Eclipselink JPA is the default JPA implementation used by
         Roller, comment out this dependency and uncomment Hibernate's
         to use that stack instead.

         Logging, other special configuration during JUnit tests can be
         placed in the src/test/resources/roller-custom.properties
         file.
     -->
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>eclipselink</artifactId>
        <version>2.5.0</version>
    </dependency>

    <!-- Alternative testing with Hibernate (used by default with JBoss)
         Important: set hibernate.transaction.factory_class=org.hibernate.transaction.JDBCTransactionFactory
         in your roller-custom.properties if using Hibernate with Tomcat

         org.javassist:javassist:3.15.0 cannot replace differently named javassist:javassist:3.11.0
         always provided by struts2-spring-plugin so filtering it out; already provided by JBoss anyway

         Note: Apache cannot distribute Hibernate due to it being LGPL, so these dependencies must be
         commented out in trunk.  We have this dependency declaration to help with testing on JBoss
         which uses Hibernate.
    -->
    <!--dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.2.3.Final</version>
        <exclusions>
            <exclusion>
                <groupId>org.javassist</groupId>
                <artifactId>javassist</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-jdk14</artifactId>
        <version>1.6.1</version>
        <scope>runtime</scope>
    </dependency-->

    <!-- To test with OpenJPA instead of EclipseLink, will need to add OpenJPA
         dependencies and static bytecode enhancement of the generated JPA classes
         to this pom.xml.  Check the Roller source code repository for a copy of
         this pom.xml prior to July 2013 for the necessary OpenJPA configuration -->

    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>

    <dependency>
        <groupId>com.google.inject</groupId>
        <artifactId>guice</artifactId>
        <version>3.0</version>
    </dependency>

    <dependency>
        <groupId>org.apache.lucene</groupId>
        <artifactId>lucene-analyzers-common</artifactId>
        <scope>compile</scope>
        <version>${lucene.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.lucene</groupId>
        <artifactId>lucene-queryparser</artifactId>
        <scope>compile</scope>
        <version>${lucene.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.velocity</groupId>
        <artifactId>velocity</artifactId>
        <version>1.7</version>
    </dependency>

    <dependency>
        <groupId>org.apache.xmlrpc</groupId>
        <artifactId>xmlrpc-common</artifactId>
        <version>3.1.3</version>
    </dependency>

    <dependency>
        <groupId>org.apache.xmlrpc</groupId>
        <artifactId>xmlrpc-client</artifactId>
        <version>3.1.3</version>
    </dependency>

    <dependency>
        <groupId>org.apache.xmlrpc</groupId>
        <artifactId>xmlrpc-server</artifactId>
        <version>3.1.3</version>
    </dependency>

    <dependency>
        <groupId>org.apache.ws.commons.util</groupId>
        <artifactId>ws-commons-util</artifactId>
        <version>1.0.2</version>
        <exclusions>
            <exclusion>
                <groupId>xml-apis</groupId>
                <artifactId>xml-apis</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>net.oauth.core</groupId>
        <artifactId>oauth</artifactId>
        <scope>compile</scope>
        <version>20100527</version>
    </dependency>

    <dependency>
        <groupId>net.oauth.core</groupId>
        <artifactId>oauth-provider</artifactId>
        <scope>compile</scope>
        <version>20100527</version>
    </dependency>

    <!-- web -->

    <dependency>
        <artifactId>servlet-api</artifactId>
        <groupId>javax.servlet</groupId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>net.java.dev.rome</groupId>
        <artifactId>rome</artifactId>
        <version>1.0.0</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>net.java.dev.rome</groupId>
        <artifactId>rome-fetcher</artifactId>
        <version>1.0.0</version>
        <scope>compile</scope>
        <exclusions>
            <!-- Version it would bring in, 2.4.0, is too old,
                 breaks OpenID functionality -->
            <exclusion>
                <groupId>xerces</groupId>
                <artifactId>xercesImpl</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>net.java.dev.rome</groupId>
        <artifactId>rome-propono</artifactId>
        <version>1.0.0</version>
        <scope>compile</scope>
        <exclusions>
            <exclusion>
                <groupId>xmlrpc</groupId>
                <artifactId>xmlrpc-common</artifactId>
            </exclusion>
            <exclusion>
                <groupId>xmlrpc</groupId>
                <artifactId>xmlrpc-client</artifactId>
            </exclusion>
            <exclusion>
                <groupId>ws-commons-util</groupId>
                <artifactId>ws-commons-util</artifactId>
            </exclusion>
            <exclusion>
                <groupId>javax.activation</groupId>
                <artifactId>activation</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <!-- spring deps -->

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
        <exclusions>
            <exclusion>
                <groupId>aopalliance</groupId>
                <artifactId>aopalliance</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>${spring.security.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-ldap</artifactId>
        <version>${spring.security.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-openid</artifactId>
        <version>${spring.security.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-taglibs</artifactId>
        <version>${spring.security.version}</version>
        <exclusions>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-web</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-acl</artifactId>
        <version>${spring.security.version}</version>
        <exclusions>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-jdbc</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-spring-plugin</artifactId>
        <version>2.3.15.3</version>
    </dependency>

    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-tiles-plugin</artifactId>
        <version>2.3.15.3</version>
    </dependency>

    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache</artifactId>
        <version>1.6.2</version>
    </dependency>

    <dependency>
        <groupId>xml-security</groupId>
        <artifactId>xmlsec</artifactId>
        <version>1.3.0</version>
    </dependency>

    <!-- Java EE deps -->

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4.7</version>
        <scope>provided</scope>
        <exclusions>
            <exclusion>
                <groupId>javax.activation</groupId>
                <artifactId>activation</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>commons-validator</groupId>
        <artifactId>commons-validator</artifactId>
        <version>1.4.0</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>commons-httpclient</groupId>
        <artifactId>commons-httpclient</artifactId>
        <version>3.1</version>
    </dependency>
    <dependency>
        <groupId>commons-beanutils</groupId>
        <artifactId>commons-beanutils</artifactId>
        <version>1.8.3</version>
    </dependency>
    <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
        <version>1.8</version>
    </dependency>

    <!-- test deps -->

    <dependency>
        <groupId>org.apache.derby</groupId>
        <artifactId>derbynet</artifactId>
        <version>${derby.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.ant</groupId>
        <artifactId>ant</artifactId>
        <version>1.9.2</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.derby</groupId>
        <artifactId>derbyclient</artifactId>
        <version>${derby.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>

    <finalName>roller</finalName>

    <plugins>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <attachClasses>true</attachClasses>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <configuration>
                <webApp>
                    <contextPath>/roller</contextPath>
                </webApp>
                <jettyXml>src/test/resources/jetty.xml</jettyXml>
                <systemProperties>
                    <systemProperty>
                        <name>roller.custom.config</name>
                        <value>${project.build.directory}/test-classes/roller-jettyrun.properties</value>
                    </systemProperty>
                </systemProperties>
            </configuration>
            <dependencies>
                <!-- Dependencies needed when using mvn jetty:run, not mvn test -->
                <dependency>
                    <groupId>org.apache.derby</groupId>
                    <artifactId>derby</artifactId>
                    <version>${derby.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.apache.derby</groupId>
                    <artifactId>derbyclient</artifactId>
                    <version>${derby.version}</version>
                </dependency>
            </dependencies>
        </plugin>

        <!-- Allow for standalone Tomcat deployment
             using mvn tomcat7:redeploy (See
             http://www.jroller.com/gmazza/entry/web_service_tutorial#maventomcat
             for necessary config info)
        -->
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.1</version>
            <configuration>
                <server>myTomcat</server>
                <path>/${project.build.finalName}</path>
            </configuration>
        </plugin>

        <!-- Activates the Derby database for unit tests and mvn jetty:run -->
        <plugin>
            <groupId>com.btmatthews.maven.plugins.inmemdb</groupId>
            <artifactId>inmemdb-maven-plugin</artifactId>
            <configuration>
                <monitorKey>inmemdb</monitorKey>
                <monitorPort>11527</monitorPort>
            </configuration>
            <executions>
                <execution>
                    <id>run</id>
                    <phase>test-compile</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <daemon>true</daemon>
                        <type>derby</type>
                        <database>rollerdb</database>
                        <username>APP</username>
                        <password>APP</password>
                        <port>4224</port>
                        <sources>
                            <script>
                                <sourceFile>${pom.basedir}/target/dbscripts/derby/createdb.sql</sourceFile>
                            </script>
                        </sources>
                    </configuration>
                </execution>
                <execution>
                    <id>stop</id>
                    <phase>package</phase>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.6</version>

            <executions>

                <execution>
                    <id>copy-main-resources</id>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${basedir}/target/classes</outputDirectory>
                        <resources>
                            <resource>
                                <directory>src/main/resources</directory>
                                <filtering>true</filtering>
                            </resource>
                        </resources>
                    </configuration>
                </execution>

                <execution>
                    <id>copy-dbscripts-resources</id>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <includeEmptyDirs>true</includeEmptyDirs>
                        <outputDirectory>${basedir}/target/dbscripts</outputDirectory>
                        <resources>
                            <resource>
                                <directory>${basedir}/src/main/resources/sql</directory>
                                <filtering>false</filtering>
                            </resource>
                        </resources>
                    </configuration>
                </execution>

                <execution>
                    <id>copy-resources</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.directory}/roller/WEB-INF/classes/dbscripts</outputDirectory>
                        <resources>
                            <resource>
                                <directory>target/dbscripts</directory>
                                <filtering>false</filtering>
                                <includes>
                                    <include>**/*.sql</include>
                                </includes>
                            </resource>
                        </resources>
                    </configuration>
                </execution>

            </executions>

            <configuration>
                <includeEmptyDirs>true</includeEmptyDirs>
            </configuration>

        </plugin>

        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.16</version>
            <configuration>
                <systemProperties>
                    <property>
                        <name>project.build.directory</name>
                        <value>${basedir}/target</value>
                    </property>
                </systemProperties>
            </configuration>
        </plugin>

        <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.7</version>

            <executions>
                <execution>
                    <id>gen-db-scripts</id>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <target>
                            <taskdef name="texen"
                                     classname="org.apache.velocity.texen.ant.TexenTask"
                                     classpathref="maven.compile.classpath"/>
                            <texen
                                controlTemplate  ="control.vm"
                                contextProperties="${basedir}/src/main/resources/sql/dbscripts.properties"
                                templatePath     ="${basedir}/src/main/resources/sql"
                                outputDirectory  ="${basedir}/target/dbscripts"
                                outputFile       ="README.txt"/>
                        </target>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>buildnumber-maven-plugin</artifactId>
            <version>1.2</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>create</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <doUpdate>false</doUpdate>
                <revisionOnScmFailure>UNKNOWN</revisionOnScmFailure>
            </configuration>
        </plugin>

    </plugins>

    <testResources>
        <testResource>
            <directory>${project.basedir}/../app/src/main/webapp/</directory>
            <filtering>false</filtering>
            <includes>
                <include>themes/**</include>
            </includes>
        </testResource>
        <testResource>
            <directory>${project.basedir}/src/test/resources</directory>
            <filtering>true</filtering>
            <includes>
                <include>**/**</include>
            </includes>
        </testResource>
    </testResources>

    <resources>
        <resource>
            <directory>${project.basedir}/src/main/resources</directory>
            <filtering>false</filtering>
            <includes>
                <include>org/**</include>
            </includes>
            <excludes>
                <exclude>**/sql/**</exclude>
            </excludes>
        </resource>
        <resource>
            <!-- ensure version gets substitution -->
            <directory>${project.basedir}/src/main/resources</directory>
            <filtering>true</filtering>
            <includes>
                <include>roller-version.properties</include>
            </includes>
        </resource>
    </resources>

</build>

gregh3269 commented 10 years ago

Brian Brian,

btw, Eclipse also complains about the test-compile

Plugin execution not covered by lifecycle configuration: com.btmatthews.maven.plugins.inmemdb:inmemdb-maven-plugin:1.3.0:run (execution: run, phase: test-compile)

Cheers Greg.

bmatthews68 commented 10 years ago

The plugin is really intended to used for integration testing and but I see that the project is using it for unit testing and the maven plugin for Eclipse is doesn't understand how to bind handle it in the context of Eclipse's incremental builds.

The following link explains how to configure a POM sot that Eclipse will ignore certain bindings http://wiki.eclipse.org/M2E_plugin_execution_not_covered#ignore_plugin_goal.

Kind regards, Brian

On 8 January 2014 09:26, gregh3269 notifications@github.com wrote:

Brian Brian,

btw, Eclipse also complains about the test-compile

Plugin execution not covered by lifecycle configuration: com.btmatthews.maven.plugins.inmemdb:inmemdb-maven-plugin:1.3.0:run (execution: run, phase: test-compile)

Cheers Greg.

— Reply to this email directly or view it on GitHubhttps://github.com/bmatthews68/inmemdb-maven-plugin/issues/15#issuecomment-31816185 .

bmatthews68 commented 10 years ago

Hi Greg,

I just made a release (1.4.0) of the plugin with now supports the element which can be used to skip execution of the run and stop goals.

If you want to skip execution when the unit tests are being skipped then you can use the following configuration:

${maven.test.skip

This release also includes an update to allow additional connection attributes to be specified as name value pairs in the element and merges them correctly with the settings I use internally in the plugin.

Incorporating the changes for the later had uncovered a problem in the integration tests which may be related to the problem you are currently experiencing. Can you try again with the latest version once the update has propagated to Maven Central.

Kind regards, Brian

On 8 January 2014 10:34, Brian Matthews brian@btmatthews.com wrote:

The plugin is really intended to used for integration testing and but I see that the project is using it for unit testing and the maven plugin for Eclipse is doesn't understand how to bind handle it in the context of Eclipse's incremental builds.

The following link explains how to configure a POM sot that Eclipse will ignore certain bindings http://wiki.eclipse.org/M2E_plugin_execution_not_covered#ignore_plugin_goal .

Kind regards, Brian

On 8 January 2014 09:26, gregh3269 notifications@github.com wrote:

Brian Brian,

btw, Eclipse also complains about the test-compile

Plugin execution not covered by lifecycle configuration: com.btmatthews.maven.plugins.inmemdb:inmemdb-maven-plugin:1.3.0:run (execution: run, phase: test-compile)

Cheers Greg.

— Reply to this email directly or view it on GitHubhttps://github.com/bmatthews68/inmemdb-maven-plugin/issues/15#issuecomment-31816185 .

gregh3269 commented 10 years ago

Brian,

Still no luck. Skipping the tests is not an option as I need them for our CI.

[INFO] --- inmemdb-maven-plugin:1.4.0:run (run) @ roller-webapp --- [INFO] Configured database port: 4224 [INFO] Configured database username: APP [INFO] Configured database attributes: {} [INFO] Configured database password: APP [INFO] Configured database name: rollerdb [ERROR] Error starting or stopping the monitor java.net.BindException: Cannot assign requested address at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376) at java.net.ServerSocket.bind(ServerSocket.java:376) at java.net.ServerSocket.(ServerSocket.java:237) at com.btmatthews.utils.monitor.Monitor.runMonitor(Monitor.java:125) at com.btmatthews.utils.monitor.Monitor$1.run(Monitor.java:155) at java.lang.Thread.run(Thread.java:722) [INFO] [INFO] --- maven-surefire-plugin:2.16:test (default-test) @ roller-webapp ---

[gregh@dev app]$ netstat -a | grep 4224 [gregh@dev app]$

Can you get it to print some more info on the address its trying to use?

Cheers Greg

bmatthews68 commented 10 years ago

Hi Greg,

Its the monitor port (11527) rather than the database server port (4224) that is causing the problem.

If the netstat -a | grep 11527 is not showing the port is in use then the only other then OS may have restricted this port. I'm used to the OS restricting ports < 1000 but have not encountered a high port being blocked.

Can you try using:

$ iptables -vnL

to see if are are any restrictions on that port or a range of ports that include it?

But ultimately I think you will need to find another port than 11527 as the monitor port.

Kind regards, Brian

On 8 January 2014 15:04, gregh3269 notifications@github.com wrote:

Brian,

Still no luck. Skipping the tests is not an option as I need them for our CI.

[INFO] --- inmemdb-maven-plugin:1.4.0:run (run) @ roller-webapp ---

[INFO] Configured database port: 4224 [INFO] Configured database username: APP [INFO] Configured database attributes: {}

[INFO] Configured database password: APP [INFO] Configured database name: rollerdb [ERROR] Error starting or stopping the monitor java.net.BindException: Cannot assign requested address at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376) at java.net.ServerSocket.bind(ServerSocket.java:376) at java.net.ServerSocket.(ServerSocket.java:237) at com.btmatthews.utils.monitor.Monitor.runMonitor(Monitor.java:125) at com.btmatthews.utils.monitor.Monitor$1.run(Monitor.java:155) at java.lang.Thread.run(Thread.java:722)

[INFO]

[INFO] --- maven-surefire-plugin:2.16:test (default-test) @ roller-webapp

[gregh@dev app]$ netstat -a | grep 4224 [gregh@dev app]$

Can you get it to print some more info on the address its trying to use?

Cheers Greg

— Reply to this email directly or view it on GitHubhttps://github.com/bmatthews68/inmemdb-maven-plugin/issues/15#issuecomment-31840129 .

gregh3269 commented 10 years ago

Brian,

Here is the iptables -vnL listing

I also tried the monitor port as 4225, with the same result, java.net.BindException: Cannot assign requested address.

Chain INPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination
1087K 242M ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 1 84 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0
4724 283K ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:993 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:25 96 19005 ACCEPT udp -- * * 0.0.0.0/0 224.0.0.251 state NEW udp dpt:5353 0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW udp dpt:631 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:631 0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW udp dpt:631 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:995 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:443 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:110 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:143 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp multiport ports 5901:5903,6001:6003 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp multiport ports 3690 214 47245 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination
0 0 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT 1090K packets, 205M bytes) pkts bytes target prot opt in out source destination

bmatthews68 commented 10 years ago

Hi Greg,

There are no clues there.

I've tried building the roller project locally on my MacBook Pro and build usually works though sometimes unit tests fail because the database is taking to long to start-up. That can be be fixed by increasing the retry interval ( http://inmemdb-maven-plugin.btmatthews.com/run-mojo.html#monitorRetryInterval) or retry count ( http://inmemdb-maven-plugin.btmatthews.com/run-mojo.html#monitorRetryCount). They default to 3 and 500ms respectively.

The next thing for me to try is building a VM with CentOS. Can you tell me where you got your CentOS distribution and what you installed on top of it?

Kind regards, Brian

On 8 January 2014 16:12, gregh3269 notifications@github.com wrote:

Brian,

Here is the iptables -vnL listing

I also tried the monitor port as 4225, with the same result, java.net.BindException: Cannot assign requested address.

Chain INPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination

1087K 242M ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 1 84 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0

4724 283K ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0

0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:993 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:25 96 19005 ACCEPT udp -- * * 0.0.0.0/0 224.0.0.251 state NEW udp dpt:5353 0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW udp dpt:631 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:631 0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW udp dpt:631 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:995 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:443 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:110 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:143 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp multiport ports 5901:5903,6001:6003 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp multiport ports 3690 214 47245 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination

0 0 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT 1090K packets, 205M bytes) pkts bytes target prot opt in out source destination

— Reply to this email directly or view it on GitHubhttps://github.com/bmatthews68/inmemdb-maven-plugin/issues/15#issuecomment-31848538 .

gregh3269 commented 10 years ago

Brian,

Is there any way I can run the monitor program manually outside of maven? ie in eclipse. I could try and debug it from my side.

Cheers Greg.

bmatthews68 commented 10 years ago

Hi Greg,

This blog explains how you can debug a Maven execution. If you use mvnDebug to kick off the Maven build for roller at the command line it will immediately hang until you connect from the debugger.

http://www.jasonwhaley.com/blog/2013/02/03/debugging-a-maven-build-with-mvnDebug/

You will want to checkout the source for the plugin from https://github.com/bmatthews68/inmemdb-maven-plugin and import it into Eclipse. You will need to make sure that you have enabled Eclipse to download sources since the problem arises in the monitor module.

Set your break points in the execute() method of RunMojo.java and then use Eclipse to attach to the stalled Maven build process.

Brian

On 8 January 2014 17:17, gregh3269 notifications@github.com wrote:

Brian,

Is there any way I can run the monitor program manually outside of maven? ie in eclipse. I could try and debug it from my side.

Cheers Greg.

— Reply to this email directly or view it on GitHubhttps://github.com/bmatthews68/inmemdb-maven-plugin/issues/15#issuecomment-31855700 .

gregh3269 commented 10 years ago

Brian,

Its seems something to do with Monitor.runMonitor(..)

InetAddress.getLocalHost()

in

ServerSocket serverSocket = new ServerSocket(portNumber, 1, InetAddress.getLocalHost());

for InetAddress.getLocalHost(); my server returns

devserver.co.uk/192.168.1.73

Which in my test program returns:

Exception in thread "main" java.net.BindException: Cannot assign requested address at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376) at java.net.ServerSocket.bind(ServerSocket.java:376) at java.net.ServerSocket.(ServerSocket.java:237) at com.btmatthews.utils.monitor.TestServerSocket.main(TestServerSocket.java:20)

My machine has two network cards one in the dmz router (first) and the other on my internal test network.

If I replace the code with:

InetAddress addr = InetAddress.getByName("127.0.0.1"); ServerSocket serverSocket = new ServerSocket(portNumber, 1, addr);

test program starts ok:

Creating server socket on port 4224 devserver.co.uk/192.168.1.73

I guess the question is what is the difference between using InetAddress.getLocalHost() and InetAddress.getByName("127.0.0.1").

Cheers Greg

bmatthews68 commented 10 years ago

This implies that there is a restriction imposed by the security manager. Under the hood getLocalHost() makes a call to checkConnect() with the devserver.co.uk and a port number of -1. If the security manager allows the connection then it returns devserver.co.uk. I guess this is basically asking can I connect to at least 1 unspecified port on devserver.co.uk.

Then in the ServerSocket() constructor we it is trying to bind to a specific port 11527 and this time checkConnect() is called with host name devserver.co.uk and port number 11527. This time it decides that the connection is not allowed.

Using the getLocalHost() gives me us the option of sending the shutdown signal from a remote machine and it also hides IPv4 vs IPv6 concerns. I'll have a think about alternatives here. Java 7 has a handy getLookbackAddress() option but thats not going to help us here because Maven uses Java 5.

So I think I will teak the Monitor component to use try using getLocalHost() first then fall back to getByAddress() if the bind fails.

Kind regards, Brian

On 8 January 2014 19:43, gregh3269 notifications@github.com wrote:

Brian,

Its seems something to do with Monitor.runMonitor(..)

InetAddress.getLocalHost()

in

ServerSocket serverSocket = new ServerSocket(portNumber, 1, InetAddress.getLocalHost());

for InetAddress.getLocalHost(); my server returns

devserver.co.uk/192.168.1.73

Which in my test program returns:

Exception in thread "main" java.net.BindException: Cannot assign requested address

at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376) at java.net.ServerSocket.bind(ServerSocket.java:376) at java.net.ServerSocket.(ServerSocket.java:237) at com.btmatthews.utils.monitor.TestServerSocket.main(TestServerSocket.java:20)

My machine has two network cards one in the dmz router (first) and the other on my internal test network.

If I replace the code with:

InetAddress addr = InetAddress.getByName("127.0.0.1"); ServerSocket serverSocket = new ServerSocket(portNumber, 1, addr);

test program starts ok:

Creating server socket on port 4224 devserver.co.uk/192.168.1.73

I guess the question is what is the difference between using InetAddress.getLocalHost() and InetAddress.getByName("127.0.0.1").

Cheers Greg

— Reply to this email directly or view it on GitHubhttps://github.com/bmatthews68/inmemdb-maven-plugin/issues/15#issuecomment-31870328 .

bmatthews68 commented 10 years ago

Hi Greg,

The latest version (1.4.2) of the plugin implements the fallback approach as described in me previous response. This should do the trick for you.

Kind regards, Brian

On 8 January 2014 20:17, Brian Matthews brian@btmatthews.com wrote:

This implies that there is a restriction imposed by the security manager. Under the hood getLocalHost() makes a call to checkConnect() with the devserver.co.uk and a port number of -1. If the security manager allows the connection then it returns devserver.co.uk. I guess this is basically asking can I connect to at least 1 unspecified port on devserver.co.uk.

Then in the ServerSocket() constructor we it is trying to bind to a specific port 11527 and this time checkConnect() is called with host name devserver.co.uk and port number 11527. This time it decides that the connection is not allowed.

Using the getLocalHost() gives me us the option of sending the shutdown signal from a remote machine and it also hides IPv4 vs IPv6 concerns. I'll have a think about alternatives here. Java 7 has a handy getLookbackAddress() option but thats not going to help us here because Maven uses Java 5.

So I think I will teak the Monitor component to use try using getLocalHost() first then fall back to getByAddress() if the bind fails.

Kind regards, Brian

On 8 January 2014 19:43, gregh3269 notifications@github.com wrote:

Brian,

Its seems something to do with Monitor.runMonitor(..)

InetAddress.getLocalHost()

in

ServerSocket serverSocket = new ServerSocket(portNumber, 1, InetAddress.getLocalHost());

for InetAddress.getLocalHost(); my server returns

devserver.co.uk/192.168.1.73

Which in my test program returns:

Exception in thread "main" java.net.BindException: Cannot assign requested address

at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376) at java.net.ServerSocket.bind(ServerSocket.java:376) at java.net.ServerSocket.(ServerSocket.java:237) at com.btmatthews.utils.monitor.TestServerSocket.main(TestServerSocket.java:20)

My machine has two network cards one in the dmz router (first) and the other on my internal test network.

If I replace the code with:

InetAddress addr = InetAddress.getByName("127.0.0.1"); ServerSocket serverSocket = new ServerSocket(portNumber, 1, addr);

test program starts ok:

Creating server socket on port 4224 devserver.co.uk/192.168.1.73

I guess the question is what is the difference between using InetAddress.getLocalHost() and InetAddress.getByName("127.0.0.1").

Cheers Greg

— Reply to this email directly or view it on GitHubhttps://github.com/bmatthews68/inmemdb-maven-plugin/issues/15#issuecomment-31870328 .

gregh3269 commented 10 years ago

Brian,

Great, it now starts so I can test what I need, it still does not shut down though,

possibly:

public void sendCommand(final String command, final Logger logger) { try { logger.logInfo("Sending command \"" + command + "\" to monitor"); final Socket socket = new Socket(InetAddress.getLocalHost(), monitorPort);

[INFO] --- inmemdb-maven-plugin:1.4.2:stop (stop) @ roller-webapp --- [INFO] Sending command "stop" to monitor [ERROR] Error sending command to monitor java.net.NoRouteToHostException: No route to host at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391) at java.net.Socket.connect(Socket.java:579) at java.net.Socket.connect(Socket.java:528) at java.net.Socket.(Socket.java:425) at java.net.Socket.(Socket.java:241) at com.btmatthews.utils.monitor.Monitor.connectMonitor(Monitor.java:350) at com.btmatthews.utils.monitor.Monitor.sendCommand(Monitor.java:223) at com.btmatthews.utils.monitor.mojo.AbstractStopMojo.execute(AbstractStopMojo.java:40) at com.btmatthews.maven.plugins.inmemdb.mojo.StopMojo.execute(StopMojo.java:54) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:318) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214) at org.apache.maven.cli.MavenCli.main(MavenCli.java:158) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:414) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:357) [INFO] [INFO] --- maven-install-plugin:2.4:install (default-install) @ roller-webapp ---

Cheers Greg.

gregh3269 commented 10 years ago

...updated source at com.btmatthews.utils.monitor.Monitor.connectMonitor(Monitor.java:350) /* * Connect to the monitor first attempting to use {@link java.net.InetAddress#getLocalHost()} then falling * back to using the loopback address if there is a security exception. * @return The connected socket. * @throws IOException If there was a problem connecting to the socket. * @since 2.1.2 */ private Socket connectMonitor() throws IOException { try { return new Socket(InetAddress.getLocalHost(), monitorPort); } catch (final ConnectException e) { return new Socket("localhost", monitorPort); } catch (NoRouteToHostException e) { return new Socket("localhost", monitorPort); <<<<<<<<<<<<<<<< } }

bmatthews68 commented 10 years ago

Hi Greg,

Can you live with it not shutting down cleanly? I started to heavily refactor the code so that it only downloads the dependencies for the database being tested. This was a change I had been planning in advance of adding support for NoSQL databases.

Kind regards, Brian

On 9 January 2014 08:57, gregh3269 notifications@github.com wrote:

...updated source at com.btmatthews.utils.monitor.Monitor.connectMonitor(Monitor.java:350) /**

  • Connect to the monitor first attempting to use {@linkhttps://github.com/linkjava.net.InetAddress#getLocalHost()} then falling
  • back to using the loopback address if there is a security exception. *
  • @return https://github.com/return The connected socket.
  • @throws https://github.com/throws IOException If there was a problem connecting to the socket.
  • @since https://github.com/since 2.1.2 */ private Socket connectMonitor() throws IOException { try { return new Socket(InetAddress.getLocalHost(), monitorPort); } catch (final ConnectException e) { return new Socket("localhost", monitorPort); } catch (UnknownHostException e) { return new Socket("localhost", monitorPort); <<<<<<<<<<<<<<<< } }

— Reply to this email directly or view it on GitHubhttps://github.com/bmatthews68/inmemdb-maven-plugin/issues/15#issuecomment-31912803 .

gregh3269 commented 10 years ago

Brian,

I can live with it, although it gives the exception, it still completes with a success.

Just to clarify, if you can add java.net.NoRouteToHostException or higher up the java.io.IOException instead of java.net.ConnectException it will fix the error.

private Socket connectMonitor() throws IOException { try { return new Socket(InetAddress.getLocalHost(), monitorPort); } catch (final ConnectException e) { return new Socket("localhost", monitorPort); } }

Thanks for your help, Greg.

nadeemanwar commented 10 years ago

Hi Brian: Why if is only for integration testing? It can be very useful for unit testing too.

Tcharl commented 10 years ago

Hi,

I don't see any use case for unit testing... Can you detail your use case?

Regards

2014-07-09 20:33 GMT+02:00 nadeemanwar notifications@github.com:

Hi Brian: Why if is only for integration testing? It can be very useful for unit testing too.

— Reply to this email directly or view it on GitHub https://github.com/bmatthews68/inmemdb-maven-plugin/issues/15#issuecomment-48515400 .

Charlie Mordant

Full OSGI/EE stack made with Karaf: https://github.com/OsgiliathEnterprise/net.osgiliath.parent

bmatthews68 commented 10 years ago

Hi,

Its always hard to find consensus on where the to draw the line between unit and integration testing. In my (personal) opinion one a unit test should have no external dependencies. So when I write unit tests for classes the service layer I completely mock out the DAO layer. And when I write unit tests for classes in the DAO layer I completely mock out the API used to access the database whether that be the JDBC connection; the Hibernate, iBatis or similar ORM or some vendor specific API. This can be very tedious but I always find enough bugs in my code following this approach to make it worth the effort.

By default the plugin binds the run and stop goals to the pre-integration-test and post-integration-test phase of the default build life-cycle. There are not equivalents when it comes to unit testing so would probably want to bind the run and stop goals to the process-test-classes and prepare-package phases.

One thing to keep in mind if you decide to do this is that you will need to make sure your unit tests are all independent. This is because you cannot guarantee the order in which the Surefire plugin will execute your unit tests.

Kind regards, Brian

On 9 July 2014 19:33, nadeemanwar notifications@github.com wrote:

Hi Brian: Why if is only for integration testing? It can be very useful for unit testing too.

— Reply to this email directly or view it on GitHub https://github.com/bmatthews68/inmemdb-maven-plugin/issues/15#issuecomment-48515400 .