Search code examples
amazon-web-servicescassandraamazon-dynamodbwso2

WSO2 DSS - Cassandra / DynamoDb - Retrieving Item


we are implementing a solution in which we use our WSO2 DSS. We don't want get rid of it, as many actors in our organization use its exposed interfaces. Underneath we are planning to migrate to Cassandra or DynamoDB, all deployed on AWS. We are facing a blocking issue, as we are able to connect. We are forced to use the Amazon SDK in which we have to use a joda-time library version newer than v.2 When we try to retreive an item we have the next exception.

java.lang.NoSuchMethodError: org.joda.time.format.DateTimeFormatter.withZoneUTC()Lorg/joda/time/format/DateTimeFormatter

So We guess it's because WSO2 uses a different version of this library.


WSO2 v.3.2.1
joda-time v.2.8.1


Solution

  • I have the same problem, but I've done some tests and I think it doesn't really a joda-time library problem.

    I have compiled a assembled jar with all dependencies and get it works, at least once.

    On pom.xml file configuration:

    <build>
        <plugins>
           ...
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>
        </plugins>
    </build>
    

    And compile the jar with:

    mvn assembly:assembly
    

    I copied the jar on $WSO_INSTALATION_DIR/repository/components/lib and start the wso2 server and it works!

    But now I'm having problems to make changes on my datasource's code and redeploy it.

    If I copy again the .jar on lib, there aren't my last changes on datasource's code and if I delete the jar from lib/ and dropin/ folders I get the following error:

    java.lang.ClassCastException: org.wso2.dss.connectors.dynamodb.DynamoDBDataSource cannot be cast to org.wso2.carbon.dataservices.core.custom.datasource.CustomQueryBasedDS
    
        at org.wso2.carbon.dataservices.core.description.config.InlineCustomQueryBasedDSConfig.<init>(InlineCustomQueryBasedDSConfig.java:66)
        at org.wso2.carbon.dataservices.core.description.config.ConfigFactory.getCustomQueryConfig(ConfigFactory.java:143)
        at org.wso2.carbon.dataservices.core.description.config.ConfigFactory.createConfig(ConfigFactory.java:73)
        at org.wso2.carbon.dataservices.core.DataServiceFactory.createDataService(DataServiceFactory.java:137)
        at org.wso2.carbon.dataservices.core.DBDeployer.createDBService(DBDeployer.java:764)
        at org.wso2.carbon.dataservices.core.DBDeployer.processService(DBDeployer.java:1127)
        at org.wso2.carbon.dataservices.core.DBDeployer.deploy(DBDeployer.java:178)
        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.loadServices(CarbonAxisConfigurator.java:464)
        at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:95)
        at org.wso2.carbon.core.CarbonConfigurationContextFactory.createNewConfigurationContext(CarbonConfigurationContextFactory.java:65)
        at org.wso2.carbon.core.init.CarbonServerManager.initializeCarbon(CarbonServerManager.java:398)
        at org.wso2.carbon.core.init.CarbonServerManager.start(CarbonServerManager.java:219)
        at org.wso2.carbon.core.internal.CarbonCoreServiceComponent.activate(CarbonCoreServiceComponent.java:77)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260)
        at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
        at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:347)
        at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
        at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
        at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
        at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
        at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
        at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
        at org.eclipse.equinox.http.servlet.internal.Activator.registerHttpService(Activator.java:81)
        at org.eclipse.equinox.http.servlet.internal.Activator.addProxyServlet(Activator.java:60)
        at org.eclipse.equinox.http.servlet.internal.ProxyServlet.init(ProxyServlet.java:40)
        at org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.init(DelegationServlet.java:38)
        at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1267)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1186)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1081)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
    Caused by: java.lang.ClassCastException: org.wso2.dss.connectors.dynamodb.DynamoDBDataSource cannot be cast to org.wso2.carbon.dataservices.core.custom.datasource.CustomQueryBasedDS
        at org.wso2.carbon.dataservices.core.description.config.InlineCustomQueryBasedDSConfig.<init>(InlineCustomQueryBasedDSConfig.java:48)
        ... 54 more
    

    I hope that this tip can you help to solve this problem and I will continue trying it to find a complete solution.

    EDITED: I discovered that it works fine if you copy the both jars on lib directory, the assembled jar and the no dependencies jar.