我正在使用 WSO2 数据服务服务器 (v3.0.1),我想知道是否可以在 JNDI 中自动注册 custom-datasources.xml 中定义的特定数据源(不使用控制台 mgmt)。
我试图通过这种配置来实现这一点:
<datasource>
<name>IPL_DS_IDB</name>
<description>My custom datasource</description>
<jndiConfig>
<name>IPL_DS_DB</name>
<environment>
<property name="jndi.use.data.source.factory">true</property>
<property name="java.naming.factory.initial">com.sun.jndi.rmi.registry.RegistryContextFactory</property>
<property name="java.naming.provider.url">rmi://localhost:10002</property>
</environment>
</jndiConfig>
<definition type="RDBMS">
<configuration>
<url>jdbc:mysql://192.168.1.5:3306/idb</url>
<username>wso2user_idb</username>
<password>XXXXXXX</password>
<driverClassName>com.mysql.jdbc.Driver</driverClassName>
<maxActive>50</maxActive>
<maxWait>60000</maxWait>
<testOnBorrow>true</testOnBorrow>
<validationQuery>SELECT 1</validationQuery>
<validationInterval>30000</validationInterval>
</configuration>
</definition>
</datasource>
但是当我使用这种配置启动数据服务服务器时,我遇到了这个异常:
TID: [0] [DSS] [2013-07-17 12:00:27,671] ERROR {org.wso2.carbon.ndatasource.core.DataSourceRepository} - Error in registering data source: IPL_DS_IDB - RegistryContext: object to bind must be Remote, Reference, or Referenceable {org.wso2.carbon.ndatasource.core.DataSourceRepository}
java.lang.IllegalArgumentException: RegistryContext: object to bind must be Remote, Reference, or Referenceable
at com.sun.jndi.rmi.registry.RegistryContext.encodeObject(RegistryContext.java:439)
at com.sun.jndi.rmi.registry.RegistryContext.rebind(RegistryContext.java:157)
at com.sun.jndi.rmi.registry.RegistryContext.rebind(RegistryContext.java:164)
at org.wso2.carbon.context.internal.CarbonContextDataHolder$CarbonInitialJNDIContext.rebind(CarbonContextDataHolder.java:1046)
at javax.naming.InitialContext.rebind(InitialContext.java:427)
at org.wso2.carbon.ndatasource.core.DataSourceRepository.registerJNDI(DataSourceRepository.java:260)
at org.wso2.carbon.ndatasource.core.DataSourceRepository.registerDataSource(DataSourceRepository.java:360)
at org.wso2.carbon.ndatasource.core.DataSourceRepository.addDataSource(DataSourceRepository.java:474)
at org.wso2.carbon.ndatasource.core.DataSourceManager.initSystemDataSource(DataSourceManager.java:182)
at org.wso2.carbon.ndatasource.core.DataSourceManager.initSystemDataSources(DataSourceManager.java:161)
at org.wso2.carbon.ndatasource.core.internal.DataSourceServiceComponent.initSystemDataSources(DataSourceServiceComponent.java:166)
at org.wso2.carbon.ndatasource.core.internal.DataSourceServiceComponent.setSecretCallbackHandlerService(DataSourceServiceComponent.java:152)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.equinox.internal.ds.model.ComponentReference.bind(ComponentReference.java:367)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.bindReference(ServiceComponentProp.java:430)
有人可以帮忙吗?