I am trying to run Liquibase scripts using CDI on WildFly 8.1.0.Final and I am getting this error:
Unsatisfied dependencies for type ResourceAccessor with qualifiers #LiquibaseType
My POM has these dependencies:
<dependencies>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-cdi</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>com.mattbertolini</groupId>
<artifactId>liquibase-slf4j</artifactId>
<version>1.2.1</version>
</dependency>
</dependencies>
My CDI Bean is as follows:
import javax.annotation.Resource;
import javax.enterprise.inject.Produces;
import javax.sql.DataSource;
import liquibase.integration.cdi.CDILiquibaseConfig;
import liquibase.integration.cdi.annotations.LiquibaseType;
import liquibase.resource.ClassLoaderResourceAccessor;
import liquibase.resource.ResourceAccessor;
public class LiquibaseStarter {
#Produces
#LiquibaseType
public CDILiquibaseConfig createConfig() {
CDILiquibaseConfig config = new CDILiquibaseConfig();
config.setChangeLog("liquibase/parser/core/xml/simpleChangeLog.xml");
return config;
}
#Resource(name="java:jboss/datasources/ExampleDS")
private DataSource ds;
#Produces
#LiquibaseType
public DataSource createDataSource() {
return ds;
}
#Produces
#LiquibaseType
public ResourceAccessor create() {
return new ClassLoaderResourceAccessor(getClass().getClassLoader());
}
}
My project is a simple WAR. What am I doing wrong?
LiquibaseStarter has no bean-defining annotation. Add #Dependent at class-level.
Related
I have a very simple JSF 2.2 ( hibernate 4.3 ) application that has 2 pages.
first page is login.xhtml which is bound to below session bean
import javax.inject.Named;
import java.io.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.enterprise.context.SessionScoped;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
#Named(value = "loginBean")
#SessionScoped
public class LoginBean implements Serializable {
/**
* Creates a new instance of LoginBean
*/
Company company;
private static final long serialVersionUID = 1520318172495977648L;
public String Login() {
CompanyHelper companyHelper = new CompanyHelper();
company = companyHelper.Login(this.loginName, this.password);
if (company != null) {
return "";
} else {
FacesMessage msg = new FacesMessage("Failed", "Wrong Usernames or password.");
msg.setSeverity(FacesMessage.SEVERITY_ERROR);
FacesContext.getCurrentInstance().addMessage(null, msg);
return "";
}
}
}
It just validate the Username and password from the DB and returns the company object
the second page delivery.xhtml which bound to view bean. Inside this bean I have injected the login bean but it returns null every time I use Company object. However, when I go to login.xhtml I found that company object is not null.
Below is the delivery bean.
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.faces.model.SelectItem;
import javax.inject.Named;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
#Named(value = "deliveryBean")
#ViewScoped
public class DeliveryBean implements Serializable {
/**
* Creates a new instance of DeliveryBean
*/
#Inject
private LoginBean loginBean;
#PostConstruct
public void init() {
// returns null pointer exception
Logger.getLogger(LoginBean.class.getName()).log(Level.SEVERE, loginBean.company);
}
public String SendItem() {
// reutn null point exception
String personName=deliverRequest.setDeliverFrom(loginBean.company.getContactPersonName());
return "";
}
}
here is the pom.xml
<dependencies>
<!-- https://mvnrepository.com/artifact/org.primefaces/primefaces -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.1</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.11.Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.40</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12</version>
</dependency>
I am deploying the application on Glassfish 4.1
#Inject
private LoginBean loginBean;
The way injection works is first it creates a proxy object in the loginBean field. CDI doesn't create or lookup a LoginBean instance immediately. Instead it waits until you call a method on the proxy in the loginBean field. CDI calls this a contextual reference - the instance that you'll get depends on the context in which you asked for it.
But you don't call a method:
loginBean.company.toString()
You access the company field directly - CDI can't intercept this. So you get a useless null value from the proxy.
The solution is to not access managed beans' fields directly. Instead make company private and create a getter:
public class LoginBean implements Serializable {
private Company company;
public Company getCompany() {
return company;
}
And call this getter in the DeliveryBean.
I have my Bean:
import java.io.Serializable;
import javax.enterprise.context.SessionScoped;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
import javax.persistence.EntityManager;
import br.com.dropper.web.dao.UsuarioDAO;
import br.com.dropper.web.model.Usuario;
import br.com.dropper.web.util.JpaUtil;
#Named
#SessionScoped
public class LoginBean implements Serializable {
private static final long serialVersionUID = 1L;
#Inject
private FacesContext context;
#Inject
private Usuario usuario;
//TODO: Persistencia e Transacao controladas por EJB
private EntityManager em = new JpaUtil().getEntityManager();
private UsuarioDAO usuarioDAO = new UsuarioDAO(em);
public Usuario getUsuario() {
return usuario;
}
public String autenticar() {
Usuario usuario = usuarioDAO.obterUsuarioPorEmail(this.usuario);
if (usuario == null) {
context.addMessage(null, new FacesMessage("Usuario não encontrado."));
context.getExternalContext().getFlash().setKeepMessages(true);
return "login?faces-redirect=true";
} else {
context.getExternalContext().getSessionMap().put("usuarioLogado", usuario);
return "dashboardImagem.xhtml?faces-redirect=true";
}
}
public String cadastrarUsuario() {
System.out.println("Redirecionando para cadastroUsuario.xhtml");
return "cadastroUsuario.xhtml?faces-redirect=true";
}
public String logout() {
context.getExternalContext().getSessionMap().remove("usuarioLogado");
context.getExternalContext().invalidateSession();
return "login.xhtml?faces-redirect=true";
}
}
And my Factory:
package br.com.dropper.web.factory;
import java.io.Serializable;
import javax.enterprise.inject.Produces;
import javax.faces.context.FacesContext;
import javax.faces.view.ViewScoped;
public class FacesContextFactory implements Serializable{
private static final long serialVersionUID = 1L;
#Produces
#ViewScoped
public FacesContext getFacesContext(){
return FacesContext.getCurrentInstance();
}
}
When i run my application, im getting this exception:
Caused by: org.jboss.weld.exceptions.IllegalProductException: WELD-000053: Producers cannot declare passivating scope and return a non-serializable class: Producer for Producer Method [FacesContext] with qualifiers [#Any #Default] declared as [[BackedAnnotatedMethod] #Produces #ViewScoped public br.com.dropper.web.factory.FacesContextFactory.getFacesContext()] declared on Managed Bean [class br.com.dropper.web.factory.FacesContextFactory] with qualifiers [#Any #Default]
at br.com.dropper.web.factory.FacesContextFactory.getFacesContext(FacesContextFactory.java:16)
And when i change the produces method to #RequestScoped, my FacesContext it's inject only one time, and in my second page xhtml, i get a nullpointer =(
UPDATE: pom
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.dropper</groupId>
<artifactId>dropper-web</artifactId>
<version>0.1</version>
<packaging>war</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- <dependency>
<groupId>dropper-web</groupId>
<artifactId>postgresql</artifactId>
<version>9.4.1212</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/postgresql-9.4.1212.jre6.jar</systemPath>
</dependency> -->
<dependency>
<groupId>dropper-web</groupId>
<artifactId>bootstrap</artifactId>
<version>1.0.10</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/bootstrap-1.0.10.jar</systemPath>
</dependency>
<dependency>
<groupId>dropper-web</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/commons-io-2.5.jar</systemPath>
</dependency>
<dependency>
<groupId>dropper-web</groupId>
<artifactId>cupertino</artifactId>
<version>1.0.10</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/cupertino-1.0.10.jar</systemPath>
</dependency>
<dependency>
<groupId>dropper-web</groupId>
<artifactId>primefaces-6.0</artifactId>
<version>6.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/primefaces-6.0.jar</systemPath>
</dependency>
</dependencies>
<build>
<finalName>dropper-web</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Att
The FacesContext itself is indeed not Serializable. And, more important, it is definitely not #ViewScoped. It's actually shorter than #RequestScoped, but until JSF 2.3 is released which comes with improved CDI support so you could just #Inject FacesContext without having a custom producer, you could less or more safely use #Produces #RequestScoped instead.
#Produces
#RequestScoped
public FacesContext getFacesContext(){
return FacesContext.getCurrentInstance();
}
One case where this would still fail is when you explicitly perform a forward within the same request using RequestDispatcher#forward() or ExternalContext#dispatch(). You will then face java.lang.IllegalStateException at com.sun.faces.context.FacesContextImpl.assertNotReleased. This is however a very rare case and usually only performed in a badly designed (ajax) exception handler. See also a.o. using ExternalContext.dispatch in JSF error handler causes corrupt page rendering.
I am trying few proof of concepts to test it for time series data. I took the sample from spring website and configured it on eclipse.
Below are few details:
Cassandra Version** - 3.0.9
Spring data cassandra version - 1.0.0.RELEASE
DataStax java driver core- cassandra-driver-core-3.1.2
I am executing the below code:
Cluster cluster = Cluster.builder().addContactPoints("127.0.0.1").withPort(9042).build();
Session session = cluster.connect("axiaglobal");
CassandraOperations cassandraOps = new CassandraTemplate(session);
cassandraOps.insert(new Person("1234567890", "David", 40));
and Person.java is below:
#Table
public class Person {
#PrimaryKey
private String id;
private String name;
private int age;
public Person(String id, String name, int age) {
this.id = id;
this.name = name;
this.age = age;
}
public String getId() {
return id;
}
public String getName() {
return name;
}
public int getAge() {
return age;
}
#Override
public String toString() {
return "Person [id=" + id + ", name=" + name + ", age=" + age + "]";
}
}
While exeucting the code, i get the below exception:
Exception in thread "main" java.lang.NoSuchMethodError: com.datastax.driver.core.DataType.asJavaClass()Ljava/lang/Class;
at org.springframework.data.cassandra.mapping.CassandraSimpleTypeHolder.<clinit>(CassandraSimpleTypeHolder.java:62)
at org.springframework.data.cassandra.mapping.BasicCassandraMappingContext.<init>(BasicCassandraMappingContext.java:73)
at org.springframework.data.cassandra.convert.MappingCassandraConverter.<init>(MappingCassandraConverter.java:77)
at org.springframework.data.cassandra.core.CassandraTemplate.<init>(CassandraTemplate.java:75)
at com.axia.global.dao.cassandra.service.CassandraApp.main(CassandraApp.java:26)
Can someone please help me out with the suggestions or pointers?
change pom file as below solved my issue:
<dependency>
<groupId>org.cassandraunit</groupId>
<artifactId>cassandra-unit-spring</artifactId>
<version>3.1.1.0</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.cassandraunit</groupId>
<artifactId>cassandra-unit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.cassandraunit</groupId>
<artifactId>cassandra-unit</artifactId>
<classifier>shaded</classifier>
<version>3.1.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>3.1.1</version>
<optional>true</optional>
<!--<exclusions>-->
<!--<exclusion>-->
<!--<groupId>com.google.guava</groupId>-->
<!--<artifactId>guava</artifactId>-->
<!--</exclusion>-->
<!--</exclusions>-->
</dependency>
I have a JSF application, and everything is working fine, except for calling methods in the ManagedBean that have a object as parameter:
<p:dataTable value="#{sContr.privileges}" var="privilege">
<p:column>
<h:outputText value="#{privilege.name}"/>
</p:column>
<p:column>
<h:outputText value="#{privilege.description}"/>
</p:column>
<p:column>
<h:commandButton action="#{sContr.deletePrivilege(privilege)}" image="somePath"/>
</p:column>
</p:dataTable>
In the sContr:
public void deletePrivilege(Privilege privilege) {
System.out.println("test");
}
All methods, that do not have own defined objects, work (e.g. Maps, Strings, Lists, ...) and accessing the objects and even sub-objects in the xhtml works like a charm.
However, calling this deletePrivilege results in:
javax.servlet.ServletException: javax.el.MethodNotFoundException: [...]privileges.xhtml #31,138 action="#{sContr.deletePrivilege(privilege)}": Method not found: [...]sContrl#604b7816.deletePrivilege(java.util.LinkedHashMap)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
[...]
The objects are defined in another module than the JSF application and are normal java objects (no specific JSF annotations).
So, for some reason, JSF can't auto-convert the LinkedHashMap back to an instance of the class that was used to render the page.
faces-config.xml:
<?xml version='1.0' encoding='UTF-8'?>
<faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
version="2.2">
<managed-bean>
<managed-bean-name>currentDate</managed-bean-name>
<managed-bean-class>java.util.Date</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
</faces-config>
The maven includes for JSF and primefaces:
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.6</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.6</version>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.1</version>
</dependency>
<dependency>
<groupId>org.primefaces.extensions</groupId>
<artifactId>primefaces-extensions</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>all-themes</artifactId>
<version>1.0.10</version>
</dependency>
My object:
#Entity
public class Privilege implements IEntity {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
#Column()
private Long id;
#Column()
private String name;
#Column()
private String description;
public Privilege(String name) {
this.name = name;
}
public Privilege(Long id, String name) {
this.id = id;
this.name = name;
}
public Privilege(Long id, String name, String description) {
this(id, name);
this.description = description;
}
public Privilege() {
}
#Override
public Long getId() {
return id;
}
#Override
public void setId(Long id) {
this.id = id;
}
#Override
public String getName() {
return name;
}
#Override
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(final String description) {
this.description = description;
}
}
Also to clarify: the LinkedHashMap contains the id, the name and the description (so it should have everything to build the correct object)
What could be the problem here? Do I need to define the package somehow in faces-config?
Using: Mojarra 2.2.6, primefaces 5.1, primefaces-extensions 2.1.0
This depends on how you are solving the Privilege so if you are deserializing it some how it may, I had the same issue, I was deserializing Device model from json using jackson
class Device{}
devices = objectMapper.readValue(responseBody, List.class);
and it gave the same error exactly
I solve deserializing like
devices = objectMapper.readValue(responseBody, new TypeReference<>() {});
and it worked perfectly.
I'm new to Spring-data-cassandra. My sample code looks something like this:
Customer.java
#Table
public class Customer {
#PrimaryKey
private String id;
private String firstName;
private String lastName;
#CassandraType(type = Name.BIGINT)
private Long age;
protected Customer() {}
public Customer(String id, String firstName, String lastName, Long age) {
this.firstName = firstName;
this.lastName = lastName;
this.id = id;
this.age = age;
}
public String getId() {
return id;
}
public Long getAge() {
return age;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
#Override
public String toString() {
return String.format(
"Customer[id=%s, firstName='%s', lastName='%s', age=%d]",
id, firstName, lastName, age);
}
}
CustomerRepository.java
public interface CustomerRepository extends CrudRepository<Customer, Long> {
#Query("select * from customer where lastname = :lName")
List<Customer> findByLastName(#Param("lName") String lName);
List<Customer> findAll();
}
Application.java
#SpringBootApplication
public class Application implements CommandLineRunner {
#Autowired
CustomerRepository repository;
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
#Override
public void run(String... strings) throws Exception {
repository.save(new Customer("0", "Jack", "Bauer", 20L));
repository.save(new Customer("1", "Chloe", "O'Brian", 21L));
repository.save(new Customer("2", "Kim", "Bauer", 22L));
repository.save(new Customer("3", "David", "Palmer", 23L));
repository.save(new Customer("4", "Michelle", "Dessler", 24L));
// fetch all customers
System.out.println("Customers found with findAll():");
System.out.println("-------------------------------");
for (Customer customer : repository.findAll()) {
System.out.println(customer);
}
// fetch customers by last name
System.out.println("Customer found with findByLastName('Bauer'):");
System.out.println("--------------------------------------------");
for (Customer bauer : repository.findByLastName("Bauer")) {
System.out.println(bauer);
}
System.out.println("Done.");
}
}
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>mine.samples</groupId>
<artifactId>spring-data-cassandra-test</artifactId>
<version>0.1.0</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.5.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-cassandra</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>javax.transaction-api</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I get the following exception when I try to run the code:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'application': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: mine.samples.CustomerRepository mine.samples.Application.repository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerRepository': Invocation of init method failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: declarative query methods are a todo
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1210)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:957)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:946)
at mine.samples.Application.main(Application.java:15)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: mine.samples.CustomerRepository mine.samples.Application.repository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerRepository': Invocation of init method failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: declarative query methods are a todo
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:561)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
... 16 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerRepository': Invocation of init method failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: declarative query methods are a todo
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1120)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1044)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:533)
... 18 common frames omitted
Caused by: org.springframework.dao.InvalidDataAccessApiUsageException: declarative query methods are a todo
at org.springframework.data.cassandra.repository.support.CassandraRepositoryFactory$CassandraQueryLookupStrategy.resolveQuery(CassandraRepositoryFactory.java:115)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:369)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:192)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:239)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:225)
at org.springframework.data.cassandra.repository.support.CassandraRepositoryFactoryBean.afterPropertiesSet(CassandraRepositoryFactoryBean.java:62)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
... 28 common frames omitted
The gist of the exception is that "declarative query methods are a todo". The documentation is a little unclear on what is and what isn't supported. Could anyone shed light on this? Thanks.
I was importing the wrong #Query in CustomerRepository.java. I fixed it by changing the import to:
import org.springframework.data.cassandra.repository.Query;