Java. Lang. Classcastexception: Com. Marklogic. Xcc. Jndi. Contentsourcebeanfactory Cannot Be Cast to Javax. Naming. Spi. Initialcontextfactory]
Im Having an Error While Creating Jndi Datasource in Wso2 Data Services Server, I'm Using the Marklogic Xcc/J Connector as May Jndi Context Class but I Got an...
Im having an error while creating JNDI datasource in WSO2 Data Services Server, I'm using the MarkLogic XCC/J connector as may JNDI Context Class but i got an error..
DS Fault Message: Naming error occurred while trying to retrieve JDBC Connection from JNDI tree. DS Code: UNKNOWN_ERROR Source Data Service:- Name: marklogicserver Location: /marklogicserver.dbs Description: N/A Default Namespace: Nested Exception:- javax.naming.NoInitialContextException: Failed to create InitialContext using factory specified in hash table. [Root exception is java.lang.ClassCastException: com.marklogic.xcc.jndi.ContentSourceBeanFactory cannot be cast to javax.naming.spi.InitialContextFactory] at org.wso2.carbon.dataservices.core.description.config.JNDIConfig.createDataSource(JNDIConfig.java:95) at org.wso2.carbon.dataservices.core.description.config.JNDIConfig.(JNDIConfig.java:49) at org.wso2.carbon.dataservices.core.description.config.ConfigFactory.getJNDIConfig(ConfigFactory.java:98) at org.wso2.carbon.dataservices.core.description.config.ConfigFactory.createConfig(ConfigFactory.java:62) at org.wso2.carbon.dataservices.core.DataServiceFactory.createDataService(DataServiceFactory.java:150) at org.wso2.carbon.dataservices.core.DBDeployer.createDBService(DBDeployer.java:785) at org.wso2.carbon.dataservices.core.DBDeployer.processService(DBDeployer.java:1139) at org.wso2.carbon.dataservices.core.DBDeployer.deploy(DBDeployer.java:195) at org.apache.axis2.deployment.repository.util.DeploymentFileData.deploy(DeploymentFileData.java:136) at org.apache.axis2.deployment.DeploymentEngine.doDeploy(DeploymentEngine.java:807) at org.apache.axis2.deployment.repository.util.WSInfoList.update(WSInfoList.java:144) at org.apache.axis2.deployment.RepositoryListener.update(RepositoryListener.java:377) at org.apache.axis2.deployment.RepositoryListener.checkServices(RepositoryListener.java:254) at org.apache.axis2.deployment.DeploymentEngine.loadServices(DeploymentEngine.java:135) at org.wso2.carbon.core.CarbonAxisConfigurator.deployServices(CarbonAxisConfigurator.java:567)
Here is my configuration file
<data name="marklogicserver" transports="http https local">
<config enableOData="false" id="mlsource">
<property name="jndi_context_class">com.marklogic.xcc.jndi.ContentSourceBeanFactory</property>
<property name="jndi_provider_url"></property>
<property name="jndi_resource_name">marklogic/ContentSource</property>
</config>
<query id="getQuery" useConfig="mlsource">
<sql>let $x := cts:search(fn:collection(""),cts:and-query(("","")))

return $x</sql>
<result element="Documents" rowName="Document">
<element column="Data" name="Data" xsdType="string"/>
</result>
</query>
<operation name="getQueryOperation">
<call-query href="getQuery"/>
</operation>
<resource method="GET" path="getQuery">
<call-query href="getQuery"/>
</resource>
</data>
What wrong with my configuration? Please help
1 Answer
Looks like WSO2 wants something that implements javax.naming.spi.InitialContextFactory, but the ContentSourceFactoryBean only implements javax.naming.spi.ObjectFactory.
I have not tried this, but I imagine you can write an implementation of InitialContextFactory that produces a Context that will ensure that ContentSourceFactoryBean is used as the ObjectFactory implementation.