java.lang.IllegalArgumentException: A CQL blob string must start with "0x"

DataStax JIRA | Robert Stupp | 1 year ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    While working on [CASSANDRA-11064|https://issues.apache.org/jira/browse/CASSANDRA-11064], I discovered that (Dynamic)CompositeTypes are parsed in the driver as blobs, but the correct CQL representation for these types is a string literal. Example: {code} cqlsh:foo> create table bar (id int PRIMARY KEY , dyn 'DynamicCompositeType(s => UTF8Type, i => Int32Type)'); cqlsh:foo> insert into bar (id, dyn) VALUES ( 1, 's@foo:i@32'); cqlsh:foo> insert into bar (id, dyn) values (2, 0x123456); ServerError: <ErrorMessage code=0000 [Server error] message="java.lang.IllegalArgumentException: Invalid component representation: 0x123456"> {code} The exception is thrown in {{org.apache.cassandra.db.marshal.DynamicCompositeType.DynamicParsedComparator#DynamicParsedComparator}} which expects a string literal. This will lead to issues if one really uses (Dynamic)CompositeType as an initcond for UDAs, since the driver then throws an exception. {code} ERROR 06:21:50 Error parsing schema from Cassandra system tables: the schema in Cluster#getMetadata() will appear incomplete or stale java.lang.IllegalArgumentException: A CQL blob string must start with "0x" at com.datastax.driver.core.utils.Bytes.fromHexString(Bytes.java:161) ~[cassandra-driver-core-3.0.0-SNAPSHOT-4c4456e-shaded.jar:na] at com.datastax.driver.core.TypeCodec$CustomCodec.parse(TypeCodec.java:998) ~[cassandra-driver-core-3.0.0-SNAPSHOT-4c4456e-shaded.jar:na] at com.datastax.driver.core.TypeCodec$CustomCodec.parse(TypeCodec.java:989) ~[cassandra-driver-core-3.0.0-SNAPSHOT-4c4456e-shaded.jar:na] at com.datastax.driver.core.AggregateMetadata.build(AggregateMetadata.java:104) ~[cassandra-driver-core-3.0.0-SNAPSHOT-4c4456e-shaded.jar:na] at com.datastax.driver.core.SchemaParser.buildAggregates(SchemaParser.java:223) ~[cassandra-driver-core-3.0.0-SNAPSHOT-4c4456e-shaded.jar:na] at com.datastax.driver.core.SchemaParser.refresh(SchemaParser.java:101) ~[cassandra-driver-core-3.0.0-SNAPSHOT-4c4456e-shaded.jar:na] at com.datastax.driver.core.ControlConnection.refreshSchema(ControlConnection.java:341) [cassandra-driver-core-3.0.0-SNAPSHOT-4c4456e-shaded.jar:na] at com.datastax.driver.core.ControlConnection.refreshSchema(ControlConnection.java:306) [cassandra-driver-core-3.0.0-SNAPSHOT-4c4456e-shaded.jar:na] at com.datastax.driver.core.Cluster$Manager$SchemaRefreshRequestDeliveryCallback$1.runMayThrow(Cluster.java:2538) [cassandra-driver-core-3.0.0-SNAPSHOT-4c4456e-shaded.jar:na] at com.datastax.driver.core.ExceptionCatchingRunnable.run(ExceptionCatchingRunnable.java:32) [cassandra-driver-core-3.0.0-SNAPSHOT-4c4456e-shaded.jar:na] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_66] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_66] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_66] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_66] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_66] {code}

    DataStax JIRA | 1 year ago | Robert Stupp
    java.lang.IllegalArgumentException: A CQL blob string must start with "0x"

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      A CQL blob string must start with "0x"

      at com.datastax.driver.core.utils.Bytes.fromHexString()
    2. DataStax Java Driver for Apache Cassandra - Core
      ExceptionCatchingRunnable.run
      1. com.datastax.driver.core.utils.Bytes.fromHexString(Bytes.java:161)[cassandra-driver-core-3.0.0-SNAPSHOT-4c4456e-shaded.jar:na]
      2. com.datastax.driver.core.TypeCodec$CustomCodec.parse(TypeCodec.java:998)[cassandra-driver-core-3.0.0-SNAPSHOT-4c4456e-shaded.jar:na]
      3. com.datastax.driver.core.TypeCodec$CustomCodec.parse(TypeCodec.java:989)[cassandra-driver-core-3.0.0-SNAPSHOT-4c4456e-shaded.jar:na]
      4. com.datastax.driver.core.AggregateMetadata.build(AggregateMetadata.java:104)[cassandra-driver-core-3.0.0-SNAPSHOT-4c4456e-shaded.jar:na]
      5. com.datastax.driver.core.SchemaParser.buildAggregates(SchemaParser.java:223)[cassandra-driver-core-3.0.0-SNAPSHOT-4c4456e-shaded.jar:na]
      6. com.datastax.driver.core.SchemaParser.refresh(SchemaParser.java:101)[cassandra-driver-core-3.0.0-SNAPSHOT-4c4456e-shaded.jar:na]
      7. com.datastax.driver.core.ControlConnection.refreshSchema(ControlConnection.java:341)[cassandra-driver-core-3.0.0-SNAPSHOT-4c4456e-shaded.jar:na]
      8. com.datastax.driver.core.ControlConnection.refreshSchema(ControlConnection.java:306)[cassandra-driver-core-3.0.0-SNAPSHOT-4c4456e-shaded.jar:na]
      9. com.datastax.driver.core.Cluster$Manager$SchemaRefreshRequestDeliveryCallback$1.runMayThrow(Cluster.java:2538)[cassandra-driver-core-3.0.0-SNAPSHOT-4c4456e-shaded.jar:na]
      10. com.datastax.driver.core.ExceptionCatchingRunnable.run(ExceptionCatchingRunnable.java:32)[cassandra-driver-core-3.0.0-SNAPSHOT-4c4456e-shaded.jar:na]
      10 frames
    3. Java RT
      Thread.run
      1. java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[na:1.8.0_66]
      2. java.util.concurrent.FutureTask.run(FutureTask.java:266)[na:1.8.0_66]
      3. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[na:1.8.0_66]
      4. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[na:1.8.0_66]
      5. java.lang.Thread.run(Thread.java:745)[na:1.8.0_66]
      5 frames