简体   繁体   中英

Getting a guava error while trying to connect to Cassandra in a managed bean

It says i need guava's version to be over 16, but I'm using guava 19. I even did mvn dependency:tree to check if something else is using guava, but there's only that version.

@Named(value = "glicoseChart")
@Dependent
public class GlicoseChart implements Serializable{

private LineChartModel glicoseModel;
public LongTermPersistence longTerm;

@PostConstruct
public void init() {
    createLineModels();
}

public LineChartModel getGlicoseModel() {
    return glicoseModel;
}

private void createLineModels() {     
    glicoseModel = initLinearModel();
}

private LineChartModel initLinearModel() 
{
    LineChartModel model = new LineChartModel();

longTerm = new LongTermPersistence();

// VVVVVVVVVVVVV
longTerm.connectB();

It gives an error trying to connect. And the connection code:

 public void connectB()
 {
   this.cluster = Cluster.builder()
           .addContactPoint("127.0.0.1")
           .withPort(9042)
           .build();
   session = cluster.connect();
}

It gives an error trying to build the cluster. However, if I try to connect in another class, and not in the managed bean, it works just fine.

However, inside the managed bean, i get this error:

Caused by: com.datastax.driver.core.exceptions.DriverInternalError: Detected incompatible version of Guava in the classpath. You need 16.0.1 or higher. at com.datastax.driver.core.GuavaCompatibility.selectImplementation(GuavaCompatibility.java:138) at com.datastax.driver.core.GuavaCompatibility.(GuavaCompatibility.java:52)

The thing is, i'm using guava-19.0, and it's saying im using 16 below, which is not true, since I can use that piece of code in another class' main. I'm using cassandra 3 btw.

You should use the same guava version as your cassandra-driver-core dependency, to be safe. Eg cassandra-driver-core 3.0.0 uses guava 16.0.1

See https://mvnrepository.com/artifact/com.datastax.cassandra/cassandra-driver-core

The error message only guesses your guava version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM