I have tried about every example to get this working, but I finally need to
turn to the forum for help. Here is my setup:


Local ServiceMix 4.4.0 
JDK 1.6 
Windows 

As per some of the forum posts, I have created a bundle that exposes the
datasource. 

/DSproj/src/main/resources/META-INF/spring/jndi.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://www.springframework.org/schema/osgi";
xsi:schemaLocation="
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd 
http://www.springframework.org/schema/osgi 
http://www.springframework.org/schema/osgi/spring-osgi.xsd";>

<bean id="myDSBean" class="net.sourceforge.jtds.jdbcx.JtdsDataSource">
<property name="databaseName" value="MyDB" />
<property name="password" value="pass" />
<property name="portNumber" value="1433" /> 
<property name="serverName" value="server" />
<property name="user" value="uer" />
</bean> 

<osgi:service id="myDSService" ref="myDSBean"> 
<osgi:interfaces>
<value>javax.sql.DataSource</value>
<value>net.sourceforge.jtds.jdbcx.JtdsDataSource</value>
</osgi:interfaces>
<osgi:service-properties>
<entry key="osgi.jndi.service.name" value="MyDS" />
</osgi:service-properties>
</osgi:service>
</beans>

/DSProj/src/main/resoruces/jndi.properties

java.naming.factory.initial=org.apache.xbean.spring.jndi.SpringInitialContextFactory

I am able to install this bundle and start it successfully in ServiceMix.
Now, I have created a second bundle that contains Hibernate entities and
DAO. I want to expose these DAOs to other service bundles. I create a second
service bundle, which is currently the one having issues.

/EntityProj/src/main/resources/jndi.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";
xsi:schemaLocation="
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd";>

<bean id="jndi" 
class="org.apache.xbean.spring.jndi.SpringInitialContextFactory"
factory-method="makeInitialContext">
</bean> 

</beans>

/EntityProj/src/main/resources/jndi.properties

java.naming.factory.initial=org.apache.xbean.spring.jndi.SpringInitialContextFactory

/EntityProj/src/main/resources/META-INF/spring/my-datasource.xml

<beans xmlns="http://www.springframework.org/schema/beans";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:jee="http://www.springframework.org/schema/jee"; 
xmlns:tx="http://www.springframework.org/schema/tx"; 
xmlns:osgi="http://www.springframework.org/schema/osgi";
xsi:schemaLocation="
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/jee 
http://www.springframework.org/schema/jee/spring-jee-2.5.xsd 
http://www.springframework.org/schema/tx 
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd 
http://www.springframework.org/schema/osgi 
http://www.springframework.org/schema/osgi/spring-osgi.xsd";>

<jee:jndi-lookup id="dataSource" 
jndi-name="osgi:services/javax.sql.DataSource/(osgi.jndi.service.name=MyDS)" 
expected-type="javax.sql.DataSource" />

...

When I install the second project, I am now getting the following exception:

Caused by: javax.naming.NamingException: scheme osgi not recognized
at
org.apache.xbean.spring.jndi.DefaultContext.lookup(DefaultContext.java:131)

My thought right now is that the bundle for DAOs and entities should use a
different initial context implementation over SpringInitialContextFactory,
but wasn't sure if I would run into the exception I got above. 

I am really at a loss here. Any help would be appreciated.

--
View this message in context: 
http://servicemix.396122.n5.nabble.com/JNDI-DataSource-Configuration-Issue-tp5633810p5633810.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Reply via email to