1
votes

I am trying to configure some basic HTTP authentication over HTTPS using the spring security manager. I have got this working previously and I have it pretty much working now with one major problem. I get the error below when my flow tries to write the message to a VM queue. My mule config works fine if I remove the the security filter (<http:basic-security-filter realm="mule-realm"/>) line but as soon as this line is present I get the error below. I'm using a custom class as the mule payload, could this be part of the problem?

Any help will be much appreciated, I have run out of ideas...

From the log:

INFO  2012-02-17 11:18:27,188 [[rhea_interoperability_layer_v2].HTTPSConnector.receiver.02] org.mule.api.processor.LoggerMessageProcessor: Structured message: RestfulHttpRequest {
    url: ws/rest/v1/facilities
    body: null
    requestParms: [
        sector: Musha
        type: test
    ]} Full Message: 
org.mule.DefaultMuleMessage
{
  id=59003ade-5948-11e1-b071-65acfd51e8fc
  payload=org.jembi.rhea.RestfulHttpRequest
  correlationId=<not set>
  correlationGroup=-1
  correlationSeq=-1
  encoding=UTF-8
  exceptionPayload=<not set>

Message properties:
  INVOCATION scoped properties:
    queryTimeout=-1
  INBOUND scoped properties:
    Accept-Encoding=gzip,deflate
    Authorization=Basic YWRtaW46YWRtaW4=
    Connection=false
    Host=localhost:5000
    Keep-Alive=false
    MULE_ORIGINATING_ENDPOINT=endpoint.https.localhost.5000
    MULE_REMOTE_CLIENT_ADDRESS=/127.0.0.1:43740
    User-Agent=Jakarta Commons-HttpClient/3.1
    http.context.path=/
    http.method=GET
    http.request=/ws/rest/v1/facilities?sector=Musha&type=test
    http.request.path=/ws/rest/v1/facilities
    http.version=HTTP/1.1
    sector=Musha
    type=test
  OUTBOUND scoped properties:
    LOCAL_CERTIFICATES=[Ljava.security.cert.X509Certificate;@47abfd68
    MULE_ENCODING=UTF-8
    MULE_ENDPOINT=jdbc://insertMsg
        MULE_ROOT_MESSAGE_ID=59003ade-5948-11e1-b071-65acfd51e8fc
  SESSION scoped properties:
}
ERROR 2012-02-17 11:18:27,215 [[rhea_interoperability_layer_v2].HTTPSConnector.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy: 
********************************************************************************
Message               : An exception occurred while invoking message processor "DefaultMessageProcessorChain '(inner iterating chain) of OutboundEndpoint 'vm://normalizationQueue' request chain' 
[ 
  org.mule.endpoint.outbound.OutboundEventTimeoutMessageProcessor, 
  org.mule.endpoint.outbound.OutboundSessionHandlerMessageProcessor, 
  org.mule.endpoint.outbound.OutboundEndpointPropertyMessageProcessor, 
  org.mule.endpoint.outbound.OutboundRootMessageIdPropertyMessageProcessor, 
  org.mule.endpoint.outbound.OutboundResponsePropertiesMessageProcessor
]" with transaction "Transaction{factory=null, action=INDIFFERENT, timeout=0}".. Message payload is of type: RestfulHttpRequest
Type                  : org.mule.api.MessagingException
Code                  : MULE_ERROR-29999
Payload               : RestfulHttpRequest {
    url: ws/rest/v1/facilities
    body: null
    requestParms: [
        sector: Musha
        type: test
    ]}
JavaDoc               : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html
********************************************************************************
Exception stack is:
1. org.mule.config.spring.parsers.assembly.MapEntryCombiner (java.io.NotSerializableException)
  java.io.ObjectOutputStream:1180 (null)
2. java.io.NotSerializableException: org.mule.config.spring.parsers.assembly.MapEntryCombiner (org.apache.commons.lang.SerializationException)
  org.apache.commons.lang.SerializationUtils:111 (null)
3. An exception occurred while invoking message processor "DefaultMessageProcessorChain '(inner iterating chain) of OutboundEndpoint 'vm://normalizationQueue' request chain' 
[ 
  org.mule.endpoint.outbound.OutboundEventTimeoutMessageProcessor, 
  org.mule.endpoint.outbound.OutboundSessionHandlerMessageProcessor, 
  org.mule.endpoint.outbound.OutboundEndpointPropertyMessageProcessor, 
  org.mule.endpoint.outbound.OutboundRootMessageIdPropertyMessageProcessor, 
  org.mule.endpoint.outbound.OutboundResponsePropertiesMessageProcessor
]" with transaction "Transaction{factory=null, action=INDIFFERENT, timeout=0}".. Message payload is of type: RestfulHttpRequest (org.mule.api.MessagingException)
  org.mule.processor.TransactionalInterceptingMessageProcessor:63 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
********************************************************************************
Root Exception stack trace:
java.io.NotSerializableException: org.mule.config.spring.parsers.assembly.MapEntryCombiner
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
    at java.util.ArrayList.writeObject(ArrayList.java:673)
    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:616)
    at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:962)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
    at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
    at org.apache.commons.collections.map.AbstractHashedMap.doWriteObject(AbstractHashedMap.java:1182)
    at org.mule.util.CaseInsensitiveHashMap.writeObject(CaseInsensitiveHashMap.java:145)
    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:616)
    at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:962)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
    at java.util.TreeMap.writeObject(TreeMap.java:2275)
    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:616)
    at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:962)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
    at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
    at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:438)
    at org.mule.MessagePropertiesContext.writeObject(MessagePropertiesContext.java:420)
    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:616)
    at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:962)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
    at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
    at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:438)
    at org.mule.DefaultMuleMessage.writeObject(DefaultMuleMessage.java:1643)
    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:616)
    at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:962)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
    at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
    at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:141...
********************************************************************************

My flow config

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

<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:https="http://www.mulesoft.org/schema/mule/https" xmlns:jdbc="http://www.mulesoft.org/schema/mule/jdbc" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:mule-ss="http://www.mulesoft.org/schema/mule/spring-security" xmlns:ss="http://www.springframework.org/schema/security" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="CE-3.2.1" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd 
http://www.mulesoft.org/schema/mule/https http://www.mulesoft.org/schema/mule/https/current/mule-https.xsd 
http://www.mulesoft.org/schema/mule/jdbc http://www.mulesoft.org/schema/mule/jdbc/current/mule-jdbc.xsd 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd 
http://www.mulesoft.org/schema/mule/spring-security http://www.mulesoft.org/schema/mule/spring-security/3.1/mule-spring-security.xsd 
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd 
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd ">
    <mule-ss:security-manager>  
        <mule-ss:delegate-security-provider name="memory-provider" delegate-ref="authenticationManager"/> 
    </mule-ss:security-manager>
    <spring:beans>
        <ss:authentication-manager alias="authenticationManager">  
            <ss:authentication-provider> 
                <ss:user-service id="userService"> 
                    <ss:user name="admin" password="admin" authorities="ROLE_ADMIN"/> 
                </ss:user-service> 
            </ss:authentication-provider> 
        </ss:authentication-manager>
        <spring:bean id="jdbcDataSource" name="jdbcDataSource" class="org.enhydra.jdbc.standard.StandardDataSource" doc:name="jdbcDataSource">
            <spring:property name="password" value="${db.password}"/>
            <spring:property name="user" value="${db.user}"/>
            <spring:property name="url" value="${db.url}"/>
            <spring:property name="driverName" value="${db.driverName}"/>
        </spring:bean>
    </spring:beans>
    <context:property-placeholder xmlns:context="http://www.springframework.org/schema/context" location="classpath:my.properties"></context:property-placeholder>
    <jdbc:connector name="JDBCConnector" dataSource-ref="jdbcDataSource" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="JDBCConnector"/>
    <https:connector name="HTTPSConnector" cookieSpec="netscape" validateConnections="true" sendBufferSize="0" receiveBufferSize="0" receiveBacklog="0" clientSoTimeout="10000" serverSoTimeout="10000" socketSoLinger="0" proxyHostname="localhost" proxyPort="80" doc:name="HTTPSConnector">
        <https:tls-key-store path="keystore.jks" keyPassword="Jembi#123" storePassword="Jembi#123"/>
    </https:connector>
    <flow name="RESTEntryPoint" doc:name="RESTEntryPoint">
        <https:inbound-endpoint exchange-pattern="request-response" host="localhost" port="5000" connector-ref="HTTPSConnector" doc:name="HTTP">
            <http:basic-security-filter realm="mule-realm"/>
        </https:inbound-endpoint>
        <response>
            <custom-transformer class="org.jembi.rhea.transformers.RestfulHttpResponseToHttpResponseTransformer" doc:name="RestfulHttpResponseToHttpResponseTransformer"/>
            <logger message="Transaction responce sent from entry point: #[groovy:return message.toString();] with payload #[groovy:return message.payload.toString();]" level="INFO" doc:name="Logger"/>
        </response>
        <logger message="Message recieved at entry point: #[groovy:return message.toString();] with payload #[groovy:return message.payload.toString();]" level="INFO" doc:name="Log raw message"/>
        <custom-transformer class="org.jembi.rhea.transformers.HttpRequestToRestfulHttpRequestTransformer" doc:name="HttpRequestToRestfulHttpRequestTransformer"/>
        <logger message="Structured message: #[groovy: message.payload.toString();]" level="INFO" doc:name="Log Structured Message"/>
        <jdbc:outbound-endpoint exchange-pattern="request-response" queryKey="insertMsg" responseTimeout="10000" queryTimeout="-1" connector-ref="JDBCConnector" doc:name="Persist raw message">
            <jdbc:query key="insertMsg" value="insert into inbound_messages (payload, timestamp) values (#[groovy: return message.payload.toString();], now());"/>
        </jdbc:outbound-endpoint>
        <choice doc:name="Choice">
            <when expression="message.getInboundProperty('X-SENDING-APP') != null" evaluator="groovy">
                <processor-chain>
                    <logger message="Propagating sending app header" level="INFO" doc:name="Log propagate sending app header"/>
                    <message-properties-transformer doc:name="Propagate sending app header">
                        <add-message-property key="X-SENDING-APP" value="#[header:inbound:X-SENDING-APP]"/>
                    </message-properties-transformer>
                </processor-chain>
            </when>
            <otherwise>
                <processor-chain>
                    <logger message="No sending app header detected" level="INFO" doc:name="Log no sending app header"/>
                </processor-chain>
            </otherwise>
        </choice>
        <message-properties-transformer scope="invocation" doc:name="Message Properties">
            <delete-message-property key="queries"/>
            <delete-message-property key="LOCAL_CERTIFICATES"/>
        </message-properties-transformer>
        <logger message="Structured message: #[groovy: message.payload.toString();] Full Message: #[groovy: message.toString();]" level="INFO" doc:name="Log Structured Message"/>
        <vm:outbound-endpoint exchange-pattern="request-response" path="normalizationQueue" responseTimeout="10000" mimeType="text/plain" doc:name="Queue message"/>
    </flow>
</mule>

The custom payload class

package org.jembi.rhea;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class RestfulHttpRequest implements Serializable {

    private static final long serialVersionUID = 1L;

    private String url;
    private String body;
    private String httpMethod;

    // automatically extracted when a url is set
    private Map<String, String> requestParams = new HashMap<String, String>();

    // HTTPMethods
    public static String HTTP_GET = "GET";
    public static String HTTP_POST = "POST";
    public static String HTTP_PUT = "PUT";
    public static String HTTP_DELETE = "DELETE";

    ... getters and setters for the above ...

}
2
Mmmh, a non serializable object gets stuffed in the in-flight MuleMessage. With the current information, I suspect the "queries" invocation property: can you remove it right before the VM endpoint? If not better, please set "-Dmule.verbose.exceptions=true" and update the above log snippet with a more complete stacktrace.David Dossot
Yes it seems so. The weird thing is this only happens when I add the security filter line to the inbound endpoint. So, something non-serializable must be added to the MuleMessage because of the added security. I tried to remove the queries property with no effect. I've added the verbose stacktrace. Thanks for the help so far.Ryan Crichton

2 Answers

0
votes

There doesn't seem to be a VM consumer for the endpoint in your config, the only thing Mule can do is 'store' messages for this queue, and this requires payloads to be serializable in turn. Either add a consumer to the 'normalizationQueue' or make sure the payload is serializable.

0
votes

Ok, so I don't have an answer of exactly why this was happening but I managed to solve the problem. All I did was move the all the jdbc stuff out to a separate flow that gets called after this one. This solved my problem and all is now running smoothly.