PLANNED MAINTENANCE

Hello, DataStax Community!

We want to make you aware of a few operational updates which will be carried out on the site. We are working hard to streamline the login process to integrate with other DataStax resources. As such, you will soon be prompted to update your password. Please note that your username will remain the same.

As we work to improve your user experience, please be aware that login to the DataStax Community will be unavailable for a few hours on:

  • Wednesday, July 15 16:00 PDT | 19:00 EDT | 20:00 BRT
  • Thursday, July 16 00:00 BST | 01:00 CEST | 04:30 IST | 07:00 CST | 09:00 AEST

For more info, check out the FAQ page. Thank you for being a valued member of our community.


question

uppal.samar_175105 avatar image
uppal.samar_175105 asked ·

cassandra java driver annotation processing

Hello, I am using the Java driver 4.1.0. Also, am using the java-driver-mapper-processor & java-driver-mapper-runtime dependencies to use the object mapping functionality.

However, when I annotate with @mapper, this page says https://docs.datastax.com/en/developer/java-driver/4.1/manual/mapper/ that i need to do annotation processing to generate the mapper object.

In intellij i checked the use annotation processing and set the path to the processor jar. However, the annotations are not processed

How do I get access to the InventoryMapperBuilder object and hence the InventoryMapper object if the annotations are not processed.

Am stuck here, will really appreciate any help

btw, am using sbt with play

so no maven, gradle etc

driverjava
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

olivier.michallat_30685 avatar image
olivier.michallat_30685 answered ·

I'm not familiar with SBT, but from what I can find online it doesn't have native support for Java annotation processors. You'll need to write a custom task to invoke javac with the processor options; this StackOverflow question looks like a good starting point.

Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

uppal.samar_175105 avatar image
uppal.samar_175105 answered ·

Thanks Olivier, that got me going. Essentially, in the javac options I am using -processorPath and specifying the full path to my processor jar:

/Users/samarjit.uppal/.ivy2/cache/com.datastax.oss/java-driver-mapper-processor/jars/java-driver-mapper-processor-4.1.0.jar


The javac command is essentially the following; am only doing the annotation processing (no compiling):

javac -classpath ... -proc:only -processorpath /Users/samarjit.uppal/.ivy2/cache/com.datastax.oss/java-driver-mapper-processor/jars/java-driver-mapper-processor-4.1.0.jar  -XprintRounds -s /Users/samarjit.uppal/projects/paymentinterfaceservice/target/generated_sources repository.impl.IPaymentMapper repository.impl.IPaymentRequestDao

I can also see that my classpath has the mapper-runtime jar:

/Users/samarjit.uppal/.ivy2/cache/com.datastax.oss/java-driver-mapper-runtime/bundles/java-driver-mapper-runtime-4.1.0.jar

However, when the processor begins to do its work, it cant seem to find the defined annotations in the runtime jar.

Here is the exception:

An annotation processor threw an uncaught exception.
Consult the following stack trace for details.
java.lang.NoClassDefFoundError: com/datastax/oss/driver/api/mapper/annotations/Entity
    at com.datastax.oss.driver.internal.mapper.processor.MapperProcessor.getSupportedAnnotationTypes(MapperProcessor.java:133)

Why is the mapper unable to locate the annotation package when its in the classpath?



Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.