0

I use wso2 dss to insert data into a cassandra table. for exemple this table : CREATE TABLE logs.test (id int,code int, PRIMARY KEY (id));

Inside wso2 dss, I defined code column with default value like this : #{NULL}

When I Try the dss service like this without given the code parameter:

<p:test xmlns:p="http://ws.wso2.org/dataservice">
<xs:id xmlns:xs="http://ws.wso2.org/dataservice">1</xs:id>
</p:test>

I get this error :

   <axis2ns56:source_data_service>
        <axis2ns56:data_service_name>Cassandra</axis2ns56:data_service_name>
        <axis2ns56:description>N/A</axis2ns56:description>
        <axis2ns56:location>\Cassandra.dbs</axis2ns56:location>
        <axis2ns56:default_namespace>http://ws.wso2.org/dataservice</axis2ns56:default_namespace>
     </axis2ns56:source_data_service>
     <axis2ns56:ds_code>UNKNOWN_ERROR</axis2ns56:ds_code>
     <axis2ns56:nested_exception>java.lang.NumberFormatException: null</axis2ns56:nested_exception>

Nested Exception:- java.lang.NumberFormatException: For input string: "null"

Best regards, Nicolas

Nicolas
  • 117
  • 1
  • 10

3 Answers3

0

Would it be possible to get the source of the dataservice? Did you try with the following payload

<p:test xmlns:p="http://ws.wso2.org/dataservice">
  <p:id>1</p:id>
  <p:code>2</p:code>
</p:test>
Nicolas
  • 482
  • 4
  • 16
  • hello, yes it work, when I put code value in the payload, like your code, but I don't want to give all parameter inside the payload, that's why I defined a default value. insert test (id,code) values (:id,:code) – Nicolas May 24 '18 at 07:30
  • and what happens if you submit a code in the query? is it working or not? – Nicolas May 24 '18 at 07:33
0

So I guess your issue is in this part

<param defaultValue="#{NULL}" name="code" sqlType="INTEGER"/>. 

I do not know your use case but if I remember well it's not so nice to insert null values in Cassandra because it create tombstones. You could as well have a second query that simply inserts the id like

insert test (id) values (:id).

The execption sound to be raised by dss not cassandra, looks like it is not able to set a null value for integer field

Nicolas
  • 482
  • 4
  • 16
  • the problem that, I can recieve a payload with the code parameter or not. I tried with the same code with sqlserver database, and it works well. – Nicolas May 24 '18 at 07:42
  • and is this cassandra query working : insert test (id,code) values (1,null) if you do it directly ? – Nicolas May 24 '18 at 07:45
  • Another interesting test could be to set the code as a string and try this : I've the feeling that the issue is with the null concept of a number in cassandra driver (or something like this) – Nicolas May 24 '18 at 07:48
  • it work with insert test (id,code) values (1,null). I change with String parameter and it work for null value, but when I give an integer value I have this error : com.datastax.driver.core.exceptions.CodecNotFoundException: Codec not found for requested operation: [int <-> java.lang.String – Nicolas May 24 '18 at 07:57
0

I find a workaround, I use the jdbc cassandra instead of com.datatasax driver. And it work well. The only problem is that I just can call only one node for the connection and not the cluster. I hope the problem will be resolve soon and I will use the Dss Cassandra datasource connection again.

Thks for your help

Nicolas
  • 117
  • 1
  • 10