Configuring MINA Server Endpoint

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Configuring MINA Server Endpoint

peter.berkman
I am configuring MINA via bean configuration, but the codec reference keeps throwing an excption:

{code}
        <bean id="pixpdqv2MinaFactory" class="org.apache.camel.component.mina.MinaComponent">
            <constructor-arg index="0" ref="nextgate-context-pixpdq-hl7v2"/>
        </bean>

        <bean id="hl7v2querylistenerEndpoint"
              factory-bean="pixpdqv2MinaFactory"
              factory-method="createEndpoint">
            <constructor-arg index="0" ref="hl7v2querylistenerConfig"/>
        </bean>

        <bean id="hl7v2feedlistenerEndpoint"
              factory-bean="pixpdqv2MinaFactory"
              factory-method="createEndpoint">
            <constructor-arg index="0" ref="hl7v2feedlistenerConfig"/>
        </bean>

        <bean id="hl7v2querylistenerConfig" class="org.apache.camel.component.mina.MinaConfiguration">
            <property name="protocol" value="tcp"/>
            <property name="host" value="${nextgate.ms.hl7v2.pixpdqquery.listenaddr}"/>
            <property name="port" value="${nextgate.ms.hl7v2.pixpdqquery.listenport}"/>
            <property name="sync" value="true"/>
            <property name="codec" ref="hl7codec" />
        </bean>

        <bean id="hl7v2feedlistenerConfig" class="org.apache.camel.component.mina.MinaConfiguration">
            <property name="protocol" value="tcp"/>
            <property name="host" value="${nextgate.ms.hl7v2.pixfeed.listenaddr}"/>
            <property name="port" value="${nextgate.ms.hl7v2.pixfeed.listenport}"/>
            <property name="sync" value="true"/>
            <property name="codec" ref="hl7codec" />
        </bean>

        <camelContext id="nextgate-context-pixpdq-hl7v2" xmlns="http://camel.apache.org/schema/spring">
 
  <route id="nextgate-route-pixpdq-hl7v2query">
                       
                       
                       
  <from ref="hl7v2querylistenerEndpoint" />
. . .

{code}


the exception:
{code}
[#|2013-01-30T11:55:20.281-0800|SEVERE|glassfish3.1.2|org.apache.catalina.core.ContainerBase|_ThreadID=154;_ThreadName=admin-thread-pool-4848(100);|ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hl7v2querylistenerEndpoint' defined in ServletContext resource [/WEB-INF/spring/nextgate-context-pixpdqv2.xml]: Cannot resolve reference to b
ean 'hl7v2querylistenerConfig' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hl7v2querylistenerConfig' defined in ServletContext resource [/WEB-INF/spring/nextgate-import-
pixpdqv2-unsecure.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.lang.String' to required type 'org.apache.mina.filter.codec.ProtocolCodecFactory' for pr
operty 'codec'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.apache.mina.filter.codec.ProtocolCodecFactory] for property 'codec': no matching editors or conversion strategy found
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:5389)
        at com.sun.enterprise.web.WebModule.start(WebModule.java:498)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
        at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2019)
        at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1669)
        at com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
. . .
{code}


any ideas?
Reply | Threaded
Open this post in threaded view
|

Re: Configuring MINA Server Endpoint

Babak Vahdat


Am 30.01.13 21:25 schrieb "peter.berkman" unter
<[hidden email]>:

>I am configuring MINA via bean configuration, but the codec reference
>keeps
>throwing an excption:
>
>{code}
> <bean id="pixpdqv2MinaFactory"
>class="org.apache.camel.component.mina.MinaComponent">
>    <constructor-arg index="0" ref="nextgate-context-pixpdq-hl7v2"/>
> </bean>
>
> <bean id="hl7v2querylistenerEndpoint"
>      factory-bean="pixpdqv2MinaFactory"
>      factory-method="createEndpoint">
>    <constructor-arg index="0" ref="hl7v2querylistenerConfig"/>
> </bean>
>
> <bean id="hl7v2feedlistenerEndpoint"
>      factory-bean="pixpdqv2MinaFactory"
>      factory-method="createEndpoint">
>    <constructor-arg index="0" ref="hl7v2feedlistenerConfig"/>
> </bean>
>
> <bean id="hl7v2querylistenerConfig"
>class="org.apache.camel.component.mina.MinaConfiguration">
>    <property name="protocol" value="tcp"/>
>    <property name="host"
>value="${nextgate.ms.hl7v2.pixpdqquery.listenaddr}"/>
>    <property name="port"
>value="${nextgate.ms.hl7v2.pixpdqquery.listenport}"/>
>    <property name="sync" value="true"/>
>    <property name="codec" ref="hl7codec" />
> </bean>
>
> <bean id="hl7v2feedlistenerConfig"
>class="org.apache.camel.component.mina.MinaConfiguration">
>    <property name="protocol" value="tcp"/>
>    <property name="host"
>value="${nextgate.ms.hl7v2.pixfeed.listenaddr}"/>
>    <property name="port"
>value="${nextgate.ms.hl7v2.pixfeed.listenport}"/>
>    <property name="sync" value="true"/>
>    <property name="codec" ref="hl7codec" />
> </bean>
>
> <camelContext id="nextgate-context-pixpdq-hl7v2"
>xmlns="http://camel.apache.org/schema/spring">
>  
>   <route id="nextgate-route-pixpdq-hl7v2query">
>
>
>
>   <from ref="hl7v2querylistenerEndpoint" />
>. . .
>
>{code}
>
>
>the exception:
>{code}
>[#|2013-01-30T11:55:20.281-0800|SEVERE|glassfish3.1.2|org.apache.catalina.
>core.ContainerBase|_ThreadID=154;_ThreadName=admin-thread-pool-4848(100);|
>ContainerBase.addChild:
>start:
>org.apache.catalina.LifecycleException:
>org.springframework.beans.factory.BeanCreationException: Error creating
>bean
>with name 'hl7v2querylistenerEndpoint' defined in ServletContext resource
>[/WEB-INF/spring/nextgate-context-pixpdqv2.xml]: Cannot resolve reference
>to
>b
>ean 'hl7v2querylistenerConfig' while setting constructor argument; nested
>exception is org.springframework.beans.factory.BeanCreationException:
>Error
>creating bean with name 'hl7v2querylistenerConfig' defined in
>ServletContext
>resource [/WEB-INF/spring/nextgate-import-
>pixpdqv2-unsecure.xml]: Initialization of bean failed; nested exception is
>org.springframework.beans.ConversionNotSupportedException: Failed to
>convert
>property value of type 'java.lang.String' to required type
>'org.apache.mina.filter.codec.ProtocolCodecFactory' for pr
>operty 'codec'; nested exception is java.lang.IllegalStateException:
>Cannot
>convert value of type [java.lang.String] to required type
>[org.apache.mina.filter.codec.ProtocolCodecFactory] for property 'codec':
>no
>matching editors or conversion strategy found
>        at
>org.apache.catalina.core.StandardContext.start(StandardContext.java:5389)
>        at com.sun.enterprise.web.WebModule.start(WebModule.java:498)
>        at
>org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java
>:917)
>        at
>org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
>        at
>org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
>        at
>com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2019)
>        at
>com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1669)
>        at
>com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
>. . .
>{code}
>
>
>any ideas?
>

Hi

I don't see any definition of your codec 'hl7codec' inside the Spring XML
which you reference to using ref="hl7codec".

You could also easily make use of the codec option inside the endpoint URI
itself which you should bind into the Registery first, see the codec
option here:

http://camel.apache.org/mina.html

There's also a Test here, however in Java and not XML but the idea is the
same:

https://svn.apache.org/repos/asf/camel/trunk/components/camel-mina/src/test
/java/org/apache/camel/component/mina/MinaCustomCodecTest.java

For example in Spring XML you would define your codec like:

<bean id="hl7codec"
class="org.apache.mina.filter.codec.textline.TextLineCodecFactory" />

And then inside your route:

<from uri="mina:tcp://localhost:5555?codec=#hl7codec"/>

 

Babak


>
>
>--
>View this message in context:
>http://camel.465427.n5.nabble.com/Configuring-MINA-Server-Endpoint-tp57265
>82.html
>Sent from the Camel - Users mailing list archive at Nabble.com.


Reply | Threaded
Open this post in threaded view
|

Re: Configuring MINA Server Endpoint

Babak Vahdat
And the defined codec of yours seems to be of type String however the expected type is org.apache.mina.filter.codec.ProtocolCodecFactory see:

http://camel.apache.org/maven/current/camel-mina/apidocs/org/apache/camel/component/mina/MinaConfiguration.html#setCodec%28org.apache.mina.filter.codec.ProtocolCodecFactory%29

So that Camel fails to do a type conversion for it. I think the codec type you need to define inside your Spring XML is:

http://camel.apache.org/maven/current/camel-hl7/apidocs/org/apache/camel/component/hl7/HL7MLLPCodec.html

Babak

Babak Vahdat wrote
Am 30.01.13 21:25 schrieb "peter.berkman" unter
<[hidden email]>:

>I am configuring MINA via bean configuration, but the codec reference
>keeps
>throwing an excption:
>
>{code}
> <bean id="pixpdqv2MinaFactory"
>class="org.apache.camel.component.mina.MinaComponent">
>    <constructor-arg index="0" ref="nextgate-context-pixpdq-hl7v2"/>
> </bean>
>
> <bean id="hl7v2querylistenerEndpoint"
>              factory-bean="pixpdqv2MinaFactory"
>      factory-method="createEndpoint">
>    <constructor-arg index="0" ref="hl7v2querylistenerConfig"/>
> </bean>
>
> <bean id="hl7v2feedlistenerEndpoint"
>              factory-bean="pixpdqv2MinaFactory"
>      factory-method="createEndpoint">
>    <constructor-arg index="0" ref="hl7v2feedlistenerConfig"/>
> </bean>
>
> <bean id="hl7v2querylistenerConfig"
>class="org.apache.camel.component.mina.MinaConfiguration">
>    <property name="protocol" value="tcp"/>
>    <property name="host"
>value="${nextgate.ms.hl7v2.pixpdqquery.listenaddr}"/>
>    <property name="port"
>value="${nextgate.ms.hl7v2.pixpdqquery.listenport}"/>
>    <property name="sync" value="true"/>
>    <property name="codec" ref="hl7codec" />
> </bean>
>
> <bean id="hl7v2feedlistenerConfig"
>class="org.apache.camel.component.mina.MinaConfiguration">
>    <property name="protocol" value="tcp"/>
>    <property name="host"
>value="${nextgate.ms.hl7v2.pixfeed.listenaddr}"/>
>    <property name="port"
>value="${nextgate.ms.hl7v2.pixfeed.listenport}"/>
>    <property name="sync" value="true"/>
>    <property name="codec" ref="hl7codec" />
> </bean>
>
> <camelContext id="nextgate-context-pixpdq-hl7v2"
>xmlns="http://camel.apache.org/schema/spring">
>  
>   <route id="nextgate-route-pixpdq-hl7v2query">
>
>
>
>   <from ref="hl7v2querylistenerEndpoint" />
>. . .
>
>{code}
>
>
>the exception:
>{code}
>[#|2013-01-30T11:55:20.281-0800|SEVERE|glassfish3.1.2|org.apache.catalina.
>core.ContainerBase|_ThreadID=154;_ThreadName=admin-thread-pool-4848(100);|
>ContainerBase.addChild:
>start:
>org.apache.catalina.LifecycleException:
>org.springframework.beans.factory.BeanCreationException: Error creating
>bean
>with name 'hl7v2querylistenerEndpoint' defined in ServletContext resource
>[/WEB-INF/spring/nextgate-context-pixpdqv2.xml]: Cannot resolve reference
>to
>b
>ean 'hl7v2querylistenerConfig' while setting constructor argument; nested
>exception is org.springframework.beans.factory.BeanCreationException:
>Error
>creating bean with name 'hl7v2querylistenerConfig' defined in
>ServletContext
>resource [/WEB-INF/spring/nextgate-import-
>pixpdqv2-unsecure.xml]: Initialization of bean failed; nested exception is
>org.springframework.beans.ConversionNotSupportedException: Failed to
>convert
>property value of type 'java.lang.String' to required type
>'org.apache.mina.filter.codec.ProtocolCodecFactory' for pr
>operty 'codec'; nested exception is java.lang.IllegalStateException:
>Cannot
>convert value of type [java.lang.String] to required type
>[org.apache.mina.filter.codec.ProtocolCodecFactory] for property 'codec':
>no
>matching editors or conversion strategy found
>        at
>org.apache.catalina.core.StandardContext.start(StandardContext.java:5389)
>        at com.sun.enterprise.web.WebModule.start(WebModule.java:498)
>        at
>org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java
>:917)
>        at
>org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
>        at
>org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
>        at
>com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2019)
>        at
>com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1669)
>        at
>com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
>. . .
>{code}
>
>
>any ideas?
>

Hi

I don't see any definition of your codec 'hl7codec' inside the Spring XML
which you reference to using ref="hl7codec".

You could also easily make use of the codec option inside the endpoint URI
itself which you should bind into the Registery first, see the codec
option here:

http://camel.apache.org/mina.html

There's also a Test here, however in Java and not XML but the idea is the
same:

https://svn.apache.org/repos/asf/camel/trunk/components/camel-mina/src/test
/java/org/apache/camel/component/mina/MinaCustomCodecTest.java

For example in Spring XML you would define your codec like:

<bean id="hl7codec"
class="org.apache.mina.filter.codec.textline.TextLineCodecFactory" />

And then inside your route:

<from uri="mina:tcp://localhost:5555?codec=#hl7codec"/>

 

Babak


>
>
>--
>View this message in context:
>http://camel.465427.n5.nabble.com/Configuring-MINA-Server-Endpoint-tp57265
>82.html
>Sent from the Camel - Users mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: Configuring MINA Server Endpoint

peter.berkman
This post was updated on .
Babak,
thank you for all the pointers! It is working great and now I can easily change between plain and SSL configurations! solution:

 	<bean id="hl7codec" class="com.nextgate.ms.component.parser.hl7v2.HL7MLLPCodec">
                    <property name="charset" value="iso-8859-1"/>
             </bean>


	<bean id="hl7v2querylistenerEndpoint"
	      factory-bean="pixpdqv2MinaFactory"
	      factory-method="createEndpoint">
	    <constructor-arg index="0" ref="hl7v2querylistenerConfig"/>
	</bean>

	<bean id="hl7v2feedlistenerEndpoint"
	      factory-bean="pixpdqv2MinaFactory"
	      factory-method="createEndpoint">
	    <constructor-arg index="0" ref="hl7v2feedlistenerConfig"/>
	</bean>

	<bean id="hl7v2querylistenerConfig" class="org.apache.camel.component.mina.MinaConfiguration">
	    <property name="protocol" value="tcp"/>
	    <property name="host" value="${nextgate.ms.hl7v2.pixpdqquery.listenaddr}"/>
	    <property name="port" value="${nextgate.ms.hl7v2.pixpdqquery.listenport}"/>
	    <property name="sync" value="true"/>
	    <property name="codec" ref="hl7codec" />
	</bean>

	<bean id="hl7v2feedlistenerConfig" class="org.apache.camel.component.mina.MinaConfiguration">
	    <property name="protocol" value="tcp"/>
	    <property name="host" value="${nextgate.ms.hl7v2.pixfeed.listenaddr}"/>
	    <property name="port" value="${nextgate.ms.hl7v2.pixfeed.listenport}"/>
	    <property name="sync" value="true"/>
	    <property name="codec" ref="hl7codec" />
	</bean>

	<camelContext id="nextgate-context-pixpdq-hl7v2" xmlns="http://camel.apache.org/schema/spring">
  
  		<route id="nextgate-route-pixpdq-hl7v2query">
  			<from ref="hl7v2querylistenerEndpoint" />

. . .
Reply | Threaded
Open this post in threaded view
|

Re: Configuring MINA Server Endpoint

peter.berkman
forgot to include the SSL configuration.   so, here it is - just swap the two *Config beans with these:


	<bean id="hl7v2querylistenerConfig" class="org.apache.camel.component.mina.MinaConfiguration">
	    <property name="protocol" value="tcp"/>
	    <property name="host" value="${nextgate.ms.hl7v2.pixpdqquery.listenaddr}"/>
	    <property name="port" value="${nextgate.ms.hl7v2.pixpdqquery.listenport}"/>
	    <property name="sync" value="true"/>
	    <property name="allowDefaultCodec" value="false" />
	    <property name="filters" ref="hl7v2filters" />
	</bean>

	<bean id="hl7v2feedlistenerConfig" class="org.apache.camel.component.mina.MinaConfiguration">
	    <property name="protocol" value="tcp"/>
	    <property name="host" value="${nextgate.ms.hl7v2.pixfeed.listenaddr}"/>
	    <property name="port" value="${nextgate.ms.hl7v2.pixfeed.listenport}"/>
	    <property name="sync" value="true"/>
	    <property name="allowDefaultCodec" value="false" />
	    <property name="filters" ref="hl7v2filters" />
	</bean>

	<bean id="hl7v2filters" class="java.util.ArrayList" >
	    <constructor-arg>
	        <list value-type="org.apache.mina.common.IoFilter">
				<bean id="sslFilter" class="org.apache.mina.filter.SSLFilter">
					<constructor-arg ref="sslContext" />
					<property name='useClientMode' value='false' />
				</bean>
				<bean id="codecFilter" class="org.apache.mina.filter.codec.ProtocolCodecFilter">
					<constructor-arg ref="hl7codec" />
				</bean>
	        </list>
	    </constructor-arg>
	</bean>

	<bean id="sslContext" class="org.apache.mina.integration.spring.ssl.SSLContextFactoryBean" >
		<property name="keyManagerFactoryKeyStore">
			<bean class="org.apache.mina.integration.spring.ssl.KeyStoreFactoryBean">
				<property name="resource" value="file:${nextgate.ms.sec.keystore.file}" />
				<property name="password" value="${nextgate.ms.sec.keystore.password}" />
			</bean>
		</property>
		<property name="keyManagerFactoryKeyStorePassword" value="${nextgate.ms.sec.keystore.password}" />        <!-- These won't be suitable if you're not using Sun's JVM -->
		<property name="keyManagerFactoryProvider" value="SunJSSE" />
		<property name="keyManagerFactoryAlgorithm" value="SunX509" />
	</bean>