On 2010-7-21, at 下午11:11, yihfeng wrote:
Hello,
We are using ServiceMix 4.2 (with felix engine) to host cxf web
services.
Our java code cannot see the config file
"dataSourceApplicationContext.xml"
when the bundle is deployed to serviceMix. We can execute the same
code in
eclipse without issue (we added the config dir to the classpath in
eclipse)
------------
java code:
------------
ApplicationContext ctx = new
ClassPathXmlApplicationContext
("file:dataSourceApplicationContext.xml");
Hi,
How about use
ApplicationContext ctx = new
ClassPathXmlApplicationContext
("classpath:dataSourceApplicationContext.xml");
instead?
Ensure that dataSourceApplicationContext.xml exist in your bundle jar.
Freeman
Note: if the full qualified path for the config file is used, the
code
works fine.
ApplicationContext ctx = new
ClassPathXmlApplicationContext("file:/Users/dev/workspace/FOS/core/
src/main/resources/dataSourceApplicationContext.xml");
Could anyone show how to define/set the classpath in POM plugin OR
in the
beams.xml to make the config file visible?
Here is the beans.xml and POM plugin.
------------
beans.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:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
<import resource="classpath:META-INF/cxf/osgi/cxf-extension-
osgi.xml" />
<jaxws:endpoint id="fosService"
implementor="edu.gmu.fos.core.ws.impl.FosServiceImpl"
address="/FOSService">
</jaxws:endpoint>
</beans>
--------------
POM plugin:
--------------
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${pom.groupId}.${pom.artifactId}</Bundle-
SymbolicName>
<Export-Package>
org.apache.commons.dbutils;version="1.1",
edu.gmu.fos.core.db;version="${pom.version}",
edu.gmu.fos.core.ws;version="${pom.version}",
edu.gmu.fos.core.ws.impl;version="${pom.version}",
org.springframework.context.support;version="2.5.6"
</Export-Package>
<Bundle-ClassPath>.</Bundle-ClassPath>
<Require-Bundle>
org.apache.servicemix.bundles.commons-dbcp,
org.apache.cxf.bundle
</Require-Bundle>
</instructions>
</configuration>
</plugin>
ANY HELP is appreciated.
--
View this message in context:
http://servicemix.396122.n5.nabble.com/not-able-to-read-config-file-from-java-code-within-a-bundle-tp1727886p1727886.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
--
Freeman Fang
------------------------
Open Source SOA: http://fusesource.com
Apache Servicemix:http://servicemix.apache.org
Apache Cxf: http://cxf.apache.org
Apache Karaf: http://karaf.apache.org
Apache Felix: http://felix.apache.org