JBI component - spring load from classpath

I have a JBI binding component that tries to use spring to load in configuration properties from a file bundled in the component jar. I instantiate the bean container in my componentsinit()method

ClassPathResource resource =new ClassPathResource(xmlConfigFile);

beanFactory =new XmlBeanFactory(resource);

and see the following in my glassfish b-33/openesb log file:

Caused by: java.io.FileNotFoundException:class path resource [spring-basic.xml] cannot be opened because it does not exist

at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:137)

at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:351)

... 17 more

The spring-basic.xml file is in the root of my component jar file and I'm not sure what is going on. I guess that that my component classloader is different from what I am expecting, but not sure what to do at this point to move forward.

As an additional piece of info, this same component loads properly in ServiceMix 3.1-incubating SNAPSHOT.

Any light shed on this would be appreciated.

[1279 byte] By [wwiv4a] at [2007-11-26 17:42:00]
# 1

I believe the root of your problem is that your component's runtime class path doesn't include the component install root. The JBI spec dictates that anything required at runtime by the component must be accessible through the class path specified in the <component-class-path> element in jbi.xml. So, you need to add the root directory to the component class path.

Can you post the content of your jbi.xml file?

Mark-S-Whitea at 2007-7-9 0:10:11 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

Mark,

Thank you for your quick reply. I had tried that and a few other variations with no luck, including putting my spring-basic.xml file in the META-INF directory. Below is the jbi.xml that I though would have worked, including the spring file listed in the component-class-path.

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

<jbi xmlns="http://java.sun.com/xml/ns/jbi" version="1.0">

<component type="service-engine">

<identification>

<name>my-binding-component</name>

<description>My Binding Component</description>

</identification>

<component-class-name>com.jeff.MyComponent</component-class-name>

<component-class-path>

<path-element>.</path-element>

<path-element>lib/commons-logging-1.0.4.jar</path-element>

<path-element>lib/soap-2.3.1.jar</path-element>

<path-element>lib/servicemix-core-3.0-incubating.jar</path-element>

<path-element>lib/backport-util-concurrent-2.1.jar</path-element>

<path-element>lib/spring-core-2.0.1.jar</path-element>

<path-element>lib/spring-beans-2.0.1.jar</path-element>

<path-element>spring-basic.xml</path-element>

</component-class-path>

<bootstrap-class-name>org.apache.servicemix.common.BaseBootstrap</bootstrap-class-name>

<bootstrap-class-path>

<path-element>.</path-element>

<path-element>lib/servicemix-common-3.0-incubating.jar</path-element>

<path-element>lib/commons-logging-1.0.4.jar</path-element>

</bootstrap-class-path>

</component>

</jbi>

And I double checked the spring-basic.xml is in the root of the component jar file.

Jeff

wwiv4a at 2007-7-9 0:10:11 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
Hi Jeff,I'm going to try to play with this and see if I can spot a problem.Just one question: is there any chance any of the code in your component or the included jars is messing with the thread context class loader?mark
Mark-S-Whitea at 2007-7-9 0:10:11 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4
I would say there is no chance of interfering with the context class loader. Our code is really straight forward and the spring loading is accomplished using spring-core-2.0.1 and spring-beans-2.0.1.Jeff
wwiv4a at 2007-7-9 0:10:11 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...