Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

For a standalone JNDI provider, we do recommend using our own Spring based JNDI provider which is the default in the stand alone ServiceMix server.

This is provided in xbean-spring-common (currently version 2.4) and, a bonus, is not confined to ServiceMix either. It can be used for unit testing in your dev environment and more.

To use it, add the following jndi.properties file to your classpath

Code Block
none
none
java.naming.factory.initial = org.servicemixapache.xbean.jbispring.jndi.SpringInitialContextFactory

...

Where the value is any valid Spring resource string such as a file://foo/bar.xmlImage Removed or a URL such as http://acme.com/whatnot.xmlImage Removed. or classpath:jndi-entries.xml.

. The default value is assumed to be classpath://jndi.xml.

When InitialContext is called upon, the JndiProvider will respond.

For the JNDI entries you need, Then you can create a regular Spring XML configuration file to create with a JNDI context bean (called jndi), which by default is located in a file called jndi.xml on the classpath Wiki Markup{snippet:id=jndi|lang=xml|url=http://cvs.servicemix.codehaus.org/*checkout*/servicemix/base/src/main/release/conf/jndi.xml?rev=HEAD}

Code Block

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
  <bean id="jndi" class="org.apache.xbean.spring.jndi.DefaultContext">
    <property name="entries">
      <map>
        <entry key="java:comp/env/jdbc/myDatabase">
			<bean class="org.springframework.jdbc.datasource.DriverManagerDataSource"
				destroy-method="close" singleton="false">
				<property name="driverClassName" value="com.sybase.jdbc3.jdbc.SybDataSource"/>
				<property name="url" value="jdbc:sybase:Tds:sybase-server:5000/MyDatabase"/>
				<property name="username" value="db-username"/>
				<property name="password" value="myS3cr3tpassword"/>
			</bean>
        </entry>
      </map>
    </property>
  </bean>
</beans>

.