3

I have a java class

import com.datastax.oss.driver.api.mapper.annotations.Dao;
import com.datastax.oss.driver.api.mapper.annotations.Delete;
import com.datastax.oss.driver.api.mapper.annotations.Insert;
import com.datastax.oss.driver.api.mapper.annotations.Select;

@Dao
public interface ProductDao {
  @Select
  Product findById(UUID productId);

  @Insert
  void save(Product product);

  @Delete
  void delete(Product product);
}

For which I would like to use for cassandra record fetching. I was trying the doc - https://github.com/datastax/java-driver/tree/4.x/manual/mapper when I try building it with maven I get an NPE

ProductDao.java:[10,8] Unexpected error while writing generated code: java.lang.NullPointerException
[ERROR]     at com.datastax.oss.driver.internal.mapper.processor.util.HierarchyScanner.traverseHierarchy(HierarchyScanner.java:169)
[ERROR]     at com.datastax.oss.driver.internal.mapper.processor.util.HierarchyScanner.resolveHierarchyScanStrategy(HierarchyScanner.java:97)
[ERROR]     at com.datastax.oss.driver.internal.mapper.processor.util.HierarchyScanner.resolveTypeHierarchy(HierarchyScanner.java:81)
[ERROR]     at com.datastax.oss.driver.internal.mapper.processor.entity.DefaultEntityFactory.getDefinition(DefaultEntityFactory.java:80)
[ERROR]     at com.datastax.oss.driver.internal.mapper.processor.dao.DaoSelectMethodGenerator.generate(DaoSelectMethodGenerator.java:98)
[ERROR]     at java.util.Optional.flatMap(Optional.java:241)
[ERROR]     at com.datastax.oss.driver.internal.mapper.processor.dao.DaoImplementationGenerator.getContents(DaoImplementationGenerator.java:331)
[ERROR]     at com.datastax.oss.driver.internal.mapper.processor.SingleFileCodeGenerator.generate(SingleFileCodeGenerator.java:43)
[ERROR]     at com.datastax.oss.driver.internal.mapper.processor.MapperProcessor.processAnnotatedTypes(MapperProcessor.java:125)
[ERROR]     at com.datastax.oss.driver.internal.mapper.processor.MapperProcessor.process(MapperProcessor.java:90)
[ERROR]     at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:802)
[ERROR]     at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:713)
[ERROR]     at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
[ERROR]     at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1043)
[ERROR]     at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1184)
[ERROR]     at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
[ERROR]     at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
[ERROR]     at com.sun.tools.javac.main.Main.compile(Main.java:523)
[ERROR]     at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
[ERROR]     at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
[ERROR]     at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:126)
[ERROR]     at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:174)
[ERROR]     at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:943)
[ERROR]     at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:137)
[ERROR]     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
[ERROR]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
[ERROR]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
[ERROR]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
[ERROR]     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
[ERROR]     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
[ERROR]     at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
[ERROR]     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[ERROR]     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
[ERROR]     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
[ERROR]     at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
[ERROR]     at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
[ERROR]     at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
[ERROR]     at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]     at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR]     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
[ERROR]     at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
[ERROR]     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
[ERROR]     at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)

Not able to root cause the error, any help is apprecitated.

1
  • what is the driver version? also, please put your pom.xml with relevant parts of the configuration Commented Jul 18, 2020 at 15:03

1 Answer 1

2

This line in the stack trace and upwards starting from -

[ERROR]     at com.datastax.oss.driver.internal.mapper.processor.entity.DefaultEntityFactory.getDefinition(DefaultEntityFactory.java:80)

Indicated to me that it was an issue on the entity class, not the Dao itself. With that in mind, I could replicate this stack trace by removing the @Entity annotation on the class that the Dao was to return, in your case that would be Product.

My expectation is that the Product class is not annotated correctly, we would need the code added from that class to further diagnose / confirm.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.