Okay, I just replaced the servicemix-2.0-SNAPSHOT.jar (I downloaded it from the repository last night, but I don't know what the date on it was) with the one that was placed in the repository at "02-Nov-2005 06:03" and my unit-test works. And...voila!...my own sample code works with clustering as well.
Many many thanks... Craig Guillaume Nodet wrote:
Then this must be the snapshot that is outdated. I'll upload a new one within an hour. In the mean time you can try with the exploded jars (servicemix-core-2.0-SNAPSHOT.jar, servicemix-jbi, servicemix-components). They are more up to date.Cheers, Guillaume Nodet Craig Walls wrote:Okay, I gave this a shot...I took the chunk of code you gave below and turned it into a unit-test. The TestCase I'm using is as follows:package com.habuma.sm.example; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import javax.jbi.messaging.MessageExchange; import javax.jbi.messaging.NormalizedMessage; import junit.framework.TestCase; import org.servicemix.jbi.jaxp.StringSource; import org.servicemix.jbi.messaging.InOnlyImpl; public class ServiceMixTest extends TestCase { public void testContentDelivery() { try { MessageExchange me = new InOnlyImpl("exchangeId"); NormalizedMessage msg = me.createMessage(); me.setMessage(msg, "in"); msg.setContent(new StringSource("<hello>world</hello>")); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(me); oos.close();ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());ObjectInputStream ois = new ObjectInputStream(bais); Object out = ois.readObject(); assertNotNull("OUT EXCHANGE IS NULL", out);assertNotNull("OUT EXCHANGE'S IN MESSAGE IS NULL", ((MessageExchange) out).getMessage("in")); assertNotNull("THE IN MESSAGE'S CONTENT IS NULL", ((MessageExchange) out).getMessage("in").getContent());} catch (Exception e) { fail("Exception thrown: " + e); } } } The test fails on the line that says "THE IN MESSAGE'S CONTENT IS NULL".As for my classpath, I'm certain that I have the servicemix-2.0-SNAPSHOT.jar (and no other servicemix JAR). In fact, here are all of the JARs in my classpath...basically everything in the ServiceMix 1.1 lib directory, plus activeluster-1.1-SNAPSHOT.jar, plus all of the JARs you recommended with the servicemix-2.0-SNAPSHOT.jar.activation.jar activecluster-1.1-SNAPSHOT.jar activemq-3.2.jar activemq-ra-3.2.jar ant-1.6.jar backport-util-concurrent-2.0_01_pd.jar commons-beanutils-1.7.0.jar commons-collections-3.1.jar commons-logging-1.0.3.jar commons-pool-1.2.jar concurrent-1.3.4.jar geronimo-spec-j2ee-connector-1.5-rc4.jar geronimo-spec-j2ee-management-1.0-rc4.jar geronimo-spec-jms-1.1-rc4.jar geronimo-spec-jta-1.0.1B-rc4.jar groovy-all-1.0-jsr-02.jar jaxp-1.3.jar jencks-all-1.1.jar jsr-223-1.0-pr.jar junit.jar lingo-1.0-M1.jar mx4j-2.1.1.jar mx4j-impl-2.1.1.jar mx4j-jmx-2.1.1.jar mx4j-remote-2.1.1.jar mx4j-tools-2.1.1.jar servicemix-2.0-SNAPSHOT.jar spring-1.2.5.jar stax-api-1.0.jar stax-utils-snapshot-20040917.jar wstx-asl-2.0.jar xalan-2.6.0.jar xbean-spring-2.0-SNAPSHOT.jar xercesImpl-2.6.2.jar xmlParserAPIs-2.6.2.jarAny ideas? Could there be some other JAR that I'm missing or have the wrong version of?Thanks, Craig Guillaume Nodet wrote:Some basic questions, but ... Have you removed from the classpath the old version of servicemix ? Do you use the latest snapshot ?If you answer yes to the two questions, could you please test if the MessageExchangeare correctly serialized / deserialized. Using the following code: MessageExchange me = new InOnlyImpl("exchangeId"); NormalizedMessage msg = me.createMessage(); me.setMessage(msg, "in"); msg.setContent(new StringSource("<hello>world</hello>")); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(me); oos.close();ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());ObjectInputStream ois = new ObjectInputStream(bais); Object out = ois.readObject();System.out.println(((MessageExchange) out).getMessage("in").getContent());Could you check that the out object has a content ?If no, then one of the two previous questions is not correct ;) as this works perfectly for me.Cheers, Guillaume Nodet Craig Walls wrote:Incidentally...after all of that...I still can't seem to get the content sent across container boundaries. In summary, here's what I did:1. Placed the 2.0 SNAPSHOT and those other 3 JARs in my classpath.2. Moved up to Java 5 to avoid the invalid class version error when compiling3. Started up the services container.4. Rolled my own XmlWebApplicationContext that instantiates itself with the XBeanProcessor.5. Deployed the web client.From all indications, the content that I'm setting on the client side of the exchange never makes it to the service-side. Properties make the trip, but the content does not.Any clues? Craig Walls wrote:Okay, I moved up to Java 1.5 and have the service-side of my example working with the 2.0 SNAPSHOT. I'm loading the container myself in Spring code that is similar to the code in org.servicemix.Main:List processors = Arrays.asList(new Object[] { new XBeanProcessor() });new ClassPathXmlApplicationContext( "com/habuma/pig/service/service-container.xml", processors);But I run into a wrinkle with the client-side...You see, the client side of my example is web-based. Previously (with version 1.1), I had this in my web.xml file:<servlet> <servlet-name>pig</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><load-on-startup>1</load-on-startup> <init-param> <param-name>contextClass</param-name><param-value>org.servicemix.jbi.config.XmlWebApplicationContext</param-value></init-param> </servlet>Now that I'm at 2.0, I figured that I should probably be using the XBean version of XmlWebApplicationContext...not a problem...<init-param> <param-name>contextClass</param-name><param-value>org.xbean.spring.context.XmlWebApplicationContext</param-value></init-param>But here's the problem...using "1.1 compatibility" I need to be able to set an XBeanProcessor on XmlWebApplicationContext, similar to what I did on the service side. Except that I don't instantiate XmlWebApplicationContext. DispatcherServlet has that honor. Therefore, there's no clear way to set the XBeanProcessor and so the XmlWebApplicationContext doesn't know how to parse the ServiceMix-specific context.There are a few options:* My client's container doesn't have any of its own components, so Isuppose that I could use standard Spring XML to configure thecontainer. But if I decide to add a service to that container thenthings get ugly. * I could go put the appropriate property file in META-INF and declare an xmlns in my XML to handle the ServiceMix-specific stuff. But in my opinion the fact that ServiceMix is using XBeanshould be as transparent to me as possible. Having to tweak my XMLto explicitly say that I'm using ServiceMix tags via XBean seems kinda dirty to me. * Perhaps a custom ServiceMix-specific DispatcherServlet could be written that handles the creation of XmlWebApplicationContext appropriately. * Or perhaps (and maybe even better), the ServiceMix version of XmlWebApplicationContext could extend the XBean version and properly register the XBeanProcessor. This means I'd have to change web.xml back to use the old ServiceMix-specific XmlWebApplicationContext...but that's okay with me.What advice is there for me? Any ideas on how to deal with this? I favor the last option...here's what I've got that seems to do the trick:package org.servicemix.jbi.config; import java.util.Arrays; import org.servicemix.jbi.config.spring.XBeanProcessor;public class XmlWebApplicationContext extends org.xbean.spring.context.XmlWebApplicationContext {public XmlWebApplicationContext() { super(Arrays.asList(new Object[] { new XBeanProcessor() })); } } Guillaume Nodet wrote:Hi All !A snapshot of ServiceMix 2.0 has been deployed at http://dist.codehaus.org/servicemix/jars/servicemix-2.0-SNAPSHOT.jar It includes a number of bug fixes, especially on cluster flow (for Craig) and sendSync on pub/sub (for George).To use it on a 1.x distribution, you will need to put the jar at the place of the old one (do not forget to remove the old one from the classpath). It works the same way, and you can access the compatibility mode in the following way :..\..\bin\servicemix -v1 servicemix.xmlYou will certainly encouter a number of ClassNotFoundException. You will need to add the following jars to the classpath:http://dist.codehaus.org/xbean/jars/xbean-spring-2.0-SNAPSHOT.jarhttp://www.ibiblio.org/maven/springframework/jars/spring-1.2.5.jar http://www.ibiblio.org/maven/backport-util-concurrent/jars/backport-util-concurrent-2.0_01_pd.jarDo not forget to remove the old spring jar from the classpath too. Enjoy ! Cheers, Guillaume Nodet
