Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

kallmekunal_131749 avatar image
kallmekunal_131749 asked ·

CassandraMapperBuilder classes not getting generated while running individual jUnit

I have somewhat below code for my mapper interface:

@Mapper
public interface CassandraMapper {

    @DaoFactory
    AccountAccessors accountDao();

    @DaoFactory
    ServerAccessor ServerDao();

    @DaoFactory
    RuleAccessor ruleDao();

    @DaoFactory
    RegistrationAccessor registrationDao();

    @DaoFactory
    DeletionAccessor deletionDao();

    @DaoFactory
    EventForwardingAccessor eventForwardingDao();

    @DaoFactory
    Serverchallenge serverChallengeDao();

    @DaoFactory
    MetricDetialAccessor metricDetailDao();

    static MapperBuilder<CassandraMapper> builder(CqlSession session) {
        return new CassandraMapperBuilder(session);
    }
}

there are few junits written on top of this and all the junits are working fine.

But when i individually run the junit it gives me compilation error like :

com\gemalto\smds\cft\unittests\database\CassandraMapper.java:36:20
java: cannot find symbol
symbol: class CassandraMapperBuilder
location: interface packagepath.CassandraMapper

Please help.

Seems when junits are run individually CassandraMapperBuilder class is not getting generated in intellij

java driver
1 comment
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.

When i am saying i am individually running junit..maven compiles the sources and during that it looks into the above class and could not fine the mapperbuilder in builder method and hence comes the compilation error.while on mvn clean install seems it gets the class somehow....it is probably related to settings in intellij but what i do not know.Please help.

[Converted answer to a comment]

0 Likes 0 ·
Cedrick Lunven avatar image
Cedrick Lunven answered ·

Hi,


The classes like `@Mapper` are generated by something call an annotation processor that will run at compilation/packaging.


Build will not fail. Now, maybe, when you execute a single Junit IntelliJ will not rebuild the project.

Here are some insights. You can setup IntelliJ to build automatically when you execute a test. You can also try to enforce the mapper to run at compile time try to add


<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>${java.version}</release>
<source>${java.version}</source>
<target>${java.version}</target>
<annotationProcessorPaths>
<path>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-mapper-processor</artifactId>
<version>${cassandra.driver.oss.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>


Also this project might some use for you https://github.com/DataStax-Examples/java-cassandra-driver-from3x-to4x/tree/master/example-4x


Have a great day


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.

Erick Ramirez avatar image
Erick Ramirez answered ·

I haven't encountered this problem before so I'm not sure what is going on. But as you stated, I also suspect that this is environmental and specific to your configuration.

I'm going to ask around to see if anyone can provide some clues. Cheers!

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.