ses
ses

Reputation: 13362

ESB Mule Client staring with xml-properties fails

I use Mule 3.x

I have a code that tests MuleClient connectivity.

This test is ok and works proper way:

public void testHello() throws Exception
    {
        MuleClient client = new MuleClient(muleContext);
        MuleMessage result = client.send("http://127.0.0.1:8080/hello", "some data", null);
        assertNotNull(result);
        assertNull(result.getExceptionPayload());
        assertFalse(result.getPayload() instanceof NullPayload);

        //TODO Assert the correct data has been received
        assertEquals("hello", result.getPayloadAsString());
    }

But this tes is not ok - it fail with an connection exceptions:

public void testHello_with_Spring() throws Exception {

    MuleClient client = new MuleClient("mule-config-test.xml");
    client.getMuleContext().start();

    //it fails here
    MuleMessage result = client.send("http://127.0.0.1:8080/hello", "some data", null);
    assertNotNull(result);

    assertNull(result.getExceptionPayload());
    assertFalse(result.getPayload() instanceof NullPayload);

    //TODO Assert the correct data has been received
    assertEquals("hello", result.getPayloadAsString());
}

The 'mule-config-test.xml' is used in both tests, the path for this file is ok, i checked.

This is error message I have in the end:

Exception stack is: 1. Address already in use (java.net.BindException) java.net.PlainSocketImpl:-2 (null) 2. Failed to bind to uri "http://127.0.0.1:8080/hello" (org.mule.transport.ConnectException)
org.mule.transport.tcp.TcpMessageReceiver:81 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/transport/ConnectException.html) -------------------------------------------------------------------------------- Root Exception stack trace: java.net.BindException: Address already in use at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:383) at java.net.ServerSocket.bind(ServerSocket.java:328) + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)


[10-05 16:33:37] ERROR HttpConnector [main]: org.mule.transport.ConnectException: Failed to bind to uri "http://127.0.0.1:8080/hello" [10-05 16:33:37] ERROR ConnectNotifier [main]: Failed to connect/reconnect: HttpConnector {
name=connector.http.mule.default lifecycle=stop this=7578a7d9
numberOfConcurrentTransactedReceivers=4
createMultipleTransactedReceivers=true connected=false
supportedProtocols=[http] serviceOverrides= } . Root Exception was: Address already in use. Type: class java.net.BindException [10-05 16:33:37] ERROR DefaultSystemExceptionStrategy [main]: Failed to bind to uri "http://127.0.0.1:8080/hello"

org.mule.api.lifecycle.LifecycleException: Cannot process event as "connector.http.mule.default" is stopped

Upvotes: 0

Views: 2214

Answers (1)

David Dossot
David Dossot

Reputation: 33413

I think the problem is in what you're not showing: testHello_with_Spring() is probably executing while Mule is already running. The second Mule you're starting in it then port-conflicts with the other one.

Are testHello() and testHello_with_Spring() in the same test suite? If yes, seeing that testHello() relies on an already running Mule, I'd say that would be the cause of port conflict for testHello_with_Spring().

Upvotes: 1

Related Questions