Works in test but things are missing when you try to install in another environment?

Have it happened to you? Your ServiceMix/osgi service in test environment is working, but when you try to depoy it to another environment, something is missing…. Ok here is some tips for you.  First, go to you working test environment and run a import -i on your correct installed service (int this case 239):

smx@root> imports -i 239
OPS4J Pax Logging - API (4): org.apache.commons.logging; version=1.1.1
OPS4J Pax Logging - API (4): org.apache.commons.logging; version=1.0.4
Spring Beans (69): org.springframework.beans.factory; version=3.0.7.RELEASE
camel-core (96): org.apache.camel.model; version=2.10.4
camel-core (96): org.apache.camel.builder; version=2.10.4
camel-core (96): org.apache.camel; version=2.10.4
camel-spring (98): org.apache.camel.osgi; version=2.10.4
camel-http (185): org.apache.camel.component.http; version=2.10.4
Apache ServiceMix :: Components :: Shared Libraries :: Common (211): org.apache.servicemix.common.osgi; version=2013.1.0
XPS Utilities (222): se.xps.ssek.smx.xps_utils; version=2.0.0
smx@root>

Ok, now you see what and which ID it’s depending on. For instance “OPS4J Pax Logging – API” with ID 4.
Now, verify that you have all dependencies in our new environment.  You will probably notice that allot is missing. To see everything lower your threshold like this:

list -t 5

A list -l is also most helpful since it tells you “from where” a service where installed. This will hopefully help you figure out whats missing in your new environment and how you installed it.

Camel XML routes specified outside your deployed service

We and our customers wanted to specify routes in XML but outside a deployed service. The benefits is that you can update your routes without any redeploys. Just refresh your service and you are done! The main trick is to create a camel-context.xml where you import another external beans resource file. Here is an example:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:osgi="http://camel.apache.org/schema/osgi"
	xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
	xmlns:ctx="http://www.springframework.org/schema/context"
	xsi:schemaLocation="
	http://www.springframework.org/schema/beans 	http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
	http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
	http://camel.apache.org/schema/osgi http://camel.apache.org/schema/osgi/camel-osgi.xsd
	http://www.springframework.org/schema/osgi-compendium 	http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd
	http://www.springframework.org/schema/context 		http://www.springframework.org/schema/context/spring-context.xsd">

	<import resource="file:/usr/local/xph/conf/mover.xml"/>

</beans>

As you can se, the only thing we do is to import an external file, in our case mover.xml

This is an working example of mover.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:osgi="http://camel.apache.org/schema/osgi"
	xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
	xmlns:ctx="http://www.springframework.org/schema/context"
	xsi:schemaLocation="
	http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
	http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
	http://camel.apache.org/schema/osgi http://camel.apache.org/schema/osgi/camel-osgi.xsd
	http://www.springframework.org/schema/osgi-compendium http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd
	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
">
<osgi:camelContext xmlns="http://camel.apache.org/schema/spring">
<route id="OuboundTest">
	<from uri="sftp://testuser@hostname:/jail/outbound?privateKeyFile=/home/testuser/.ssh/id_rsa_passw&amp;privateKeyFilePassphrase=secretPassword&amp;stepwise=false&amp;delay=20000&amp;delete=true"/>
	<log loggingLevel="INFO" logName="mover" message="About to move ${file:onlyname}"/>
	<to uri="file:///usr/local/outbound.unverified/testuser?readLock=changed&amp;delete=true&amp;moveFailed=/usr/local/testuser/failed/failedToMoveToOutboundWorkdir.${file:onlyname}"/>
	<!-- General exception-->
	<onException>
		<exception>java.lang.Exception</exception>
		<handled>
			<constant>true</constant>
		</handled>
		<log loggingLevel="ERROR" logName="mover" message="General exception dealing with testuser file ${file:onlyname} , exeption ${exception} dumping file to ./error ,will exit...."/>
		<to uri="file:./error"/>
	</onException>
</route>
</osgi:camelContext>
</beans>

Ok, now what? Well, now you can use all the components given to you in camel without any deployment. Get files from SFTP, upload files, transform XML, Schema validate, log and much more. You will still have to load all features if you are using ServiceMix thou…..

XPS blir XPH

Prestandatesterna är i slutfasen för vår nya kommunikationsserver för SSEK 1.1 samt 2.0 specifikationerna. Kommer att marknadsföra som vår XPH Server och ersätter vår tidigare XPS Server. Serviceorienterad och dynamisk i med sina konfigurationsmöjligheter. Kontakta oss så berättar vi gärna mer om våra lösningar.