java.lang.ClassNotFoundException: javax.validation.ValidatorFactory - spring

I am doing spring validation with hibernate-validator-5.2.2.Final jar.When I add validation-api-1.1.0.Final jar file in my class path then this exception is occur:
WARNING: Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDetailsService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.database.dao.UsersDAO com.layers.configuration.MyUsersDetailsService.userDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userdao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.database.dao.UserDaoImplementation.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in com.layers.configuration.SpringConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.hibernate.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: javax/validation/ValidatorFactory
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:835)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4727)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
My model class is :
public class Users implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = -8605158460377236476L;
private int UId;
#Size(min=3, max=15)
#NotNull
private String userName;
#NotNull
#Size(min = 4, max = 15)
private String userPassword;
#NotNull
#Size(min=3, max=20)
private String firstName;
#NotNull
#Size(min=3, max=20)
private String lastName;
#JsonIgnore
private List<UsersRoles> usersRoleNames;
public Users() {
}
public Users(int UId) {
this.UId = UId;
}
public Users(int UId, String userName, String userPassword, String firstName, String lastName,
List<UsersRoles> usersRoleNames) {
this.UId = UId;
this.userName = userName;
this.userPassword = userPassword;
this.firstName = firstName;
this.lastName = lastName;
this.usersRoleNames = usersRoleNames;
}
#Id #GeneratedValue(strategy=GenerationType.IDENTITY)
#Column(name = "u_id", unique = true, nullable = false)
public int getUId() {
return this.UId;
}
public void setUId(int UId) {
this.UId = UId;
}
#Column(name = "user_name")
public String getUserName() {
return this.userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
#Column(name = "user_password")
public String getUserPassword() {
return this.userPassword;
}
public void setUserPassword(String userPassword) {
this.userPassword = userPassword;
}
#Column(name = "first_name")
public String getFirstName() {
return this.firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
#Column(name = "last_name")
public String getLastName() {
return this.lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
#OneToMany(fetch = FetchType.LAZY, mappedBy = "usersTable")
public List<UsersRoles> getUsersRoleNames() {
return this.usersRoleNames;
}
public void setUsersRoleNames(List<UsersRoles> usersRoleNames) {
this.usersRoleNames = usersRoleNames;
}
}
My controller:
#RequestMapping(value = "/saveuser", method = RequestMethod.POST)
public #ResponseBody String Save(/*#Valid Users user, BindingResult result,*/HttpServletRequest request, Model model,
#RequestParam(required = false) Boolean reverseBeforeSave) {
if (result.hasErrors() || user.getUserName() == null || user.getUserPassword() == null
|| user.getUId() == 0 || user.getFirstName() == null || user.getLastName() == null) {
return "error";
}
else
{
String userName = request.getParameter("username");
String password = request.getParameter("password");
String firstName = request.getParameter("first_name");
String lastName = request.getParameter("last_name");
System.out.println("save method");
String[] roleNames = request.getParameterValues("roles");
userService.saveUserandRoles(userName, password, firstName, lastName, roleNames);
return "success";
//}
}
Please let me know what is the problem and how to fix it, I have read various tutorials and errors about this problem but not able to understand.

Add below dependency in pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>

Related

Spring boot #query show parameter table

I just want to show first name and last name to this project
and I have this entity class and repository
but error is
#Entity
public class Customer {
private int id;
private String firstname;
private String lastname;
private String city;
private String country;
private String phone;
private Collection<Orders> ordersById;
#Id
#Column(name = "id")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
#Basic
#Column(name = "firstname")
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
#Basic
#Column(name = "lastname")
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
#Basic
#Column(name = "city")
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
#Basic
#Column(name = "country")
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
#Basic
#Column(name = "phone")
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
#OneToMany(mappedBy = "customerByCustomerId",fetch = FetchType.LAZY)
public Collection<Orders> getOrdersById() {
return ordersById;
}
public void setOrdersById(Collection<Orders> ordersById) {
this.ordersById = ordersById;
}
and my repository is :
#Repository
public interface CustomerRepo extends JpaRepository<Customer, Integer> {
#Query(value = "SELECT firstname, lastname from Customer",nativeQuery = true)
List<Customer> findAllCustomer();
}
but I have this error for use this Query
I use MS DATABASE SQL Server
ERROR is :
SQL Error: 0, SQLState: S1093
The column name id is not valid.
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: could not execute query; nested exception is org.hibernate.exception.GenericJDBCException: could not execute query] with root cause
Hibernate:
SELECT
firstname,
lastname
from
Customer
2020-09-25 23:13:23.634 WARN 7712 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: S1093
2020-09-25 23:13:23.634 ERROR 7712 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : The column name id is not valid.
2020-09-25 23:13:23.672 ERROR 7712 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: could not execute query; nested exception is org.hibernate.exception.GenericJDBCException: could not execute query] with root cause
You need to add mapping , so add this class
public class CustomerResult{
private String firstname;
private String lastname;
public CustomerResult(String surname, String lastname){
this.firstname = firstname;
this.lastname = lastname;
}
// getters / setters
}
And add this in your repository
#Query("select NEW com.yourpackageClass.CustomerResult(
o.customer.firstname, o.customer.lastname)
from Customer as o")
List< CustomerResult> findAllCustomer();
Hope useful

Convert String to LocalDateTime

I have an error in registration of tasks because the time must be converted from String to LocalDateTime and I don't know how to convert.
Below is my Task class:
#Entity
#Table(name = "task", schema = "public")
public class Task {
#Id
#GeneratedValue
private Long id;
#NotEmpty
private String date;
#NotEmpty
private LocalDateTime startTime;
#NotEmpty
private LocalDateTime stopTime;
#NotEmpty
#Column(length = 1000)
private String description;
#ManyToOne
#JoinColumn(name = "USER_EMAIL")
private User user;
public Task() {
}
public Task(String date, LocalDateTime startTime, LocalDateTime stopTime, String description, User user) {
this.date = date;
this.startTime = startTime;
this.stopTime = stopTime;
this.description = description;
this.user = user;
}
public Task(String date, LocalDateTime startTime, LocalDateTime stopTime, String description) {
this.date = date;
this.startTime = startTime;
this.stopTime = stopTime;
this.description = description;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public LocalDateTime getStartTime() {
return startTime;
}
public void setStartTime(LocalDateTime startTime) {
this.startTime = startTime;
}
public LocalDateTime getStopTime() {
return stopTime;
}
public void setStopTime(LocalDateTime stopTime) {
this.stopTime = stopTime;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
}
In TaskController class I have that function to register Tasks in the database:
#PostMapping("/addTask")
public String addTask(#Valid Task task,
BindingResult bindingResult,
HttpSession session,
#RequestParam("datetime")
#DateTimeFormat(pattern = "dd.MM.yyyy HH:mm:ss.SSSZ") LocalDateTime dateAndTime) {
if (bindingResult.hasErrors()){
return "views/taskForm";
}
String email = (String) session.getAttribute("email");
taskService.addTask(task, userService.findOne(email));
return "redirect:/users";
}
And in TaskService is the function for adding tasks in TaskController:
public void addTask(Task task, User user) {
task.setUser(user);
taskRepository.save(task);
}
Please can someone resolve this error:
Failed to convert property value of type java.lang.String to required
type java.time.LocalDateTime for property startTime; nested exception
is org.springframework.core.convert.ConversionFailedException: Failed
to convert from type [java.lang.String] to type
[#org.hibernate.validator.constraints.NotEmpty
java.time.LocalDateTime] for value 09:00; nested exception is
java.lang.IllegalArgumentException: Parse attempt failed for value
[09:00]
and this:
Failed to convert property value of type java.lang.String to required
type java.time.LocalDateTime for property stopTime; nested exception
is org.springframework.core.convert.ConversionFailedException: Failed
to convert from type [java.lang.String] to type
[#org.hibernate.validator.constraints.NotEmpty
java.time.LocalDateTime] for value 18:00; nested exception is
java.lang.IllegalArgumentException: Parse attempt failed for value
[18:00]
I have spent many days and I cannot resolve this.
Thanks in advance!
You can write a converter to convert from a String to LocalDateTime and vice versa.
#Converter(autoApply = true)
public class LocalDateTimeConverter implements AttributeConverter<LocalDateTime, String> {
private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
#Override
public String convertToDatabaseColumn(LocalDateTime locDate) {
return (locDate == null ? null : formatter.format(locDate));
}
#Override
public LocalDateTime convertToEntityAttribute(String dateValue) {
return (dateValue == null ? null : LocalDateTime.parse(dateValue, formatter));
}
}
If you want to define a converter for each variable use
#Convert(converter = LocalDateTimeConverter.class)
private LocalDateTime stopTime;
Use below to convert the time from String to LocalDateTime, but make sure you are getting the time in String form.
String str = "2018-12-10 12:30";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
LocalDateTime dateTime = LocalDateTime.parse(str, formatter);

Dynamic type caste Spring pathvariable

I am planning to create one simple Spring Rest Service Project with JPA which will fetch the details from the database based on the entity name and entity id given in path variables.
consider following code.
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ds.dao.EntityDAO;
import com.ds.entities.Employees;
import javax.persistence.Entity;
#Controller
#RequestMapping("/")
public class DynaRestController {
#Autowired
EntityDAO entityDAO;
#RequestMapping(value = "{entityName}/{enityId}",method = RequestMethod.GET)
public #ResponseBody Object getEntity(#PathVariable("entityName") String entityName,#PathVariable("enityId") Object id) {
return entityDAO.getEntityById(entityName, id);
}
}
Entity DAO Class
public class EntityDAO {
#Autowired
EntityManager entityManager;
public Object getEntityById(String entityName, Object id) {
EntityType<?> entityType = getEntityByName(entityName);
Object idcasted = entityType.getIdType().getJavaType().cast(id);
System.out.println(idcasted.getClass().getName());
Object entity = entityManager.find(entityType.getJavaType(), idcasted);
System.out.println("Entity.. Name .." + entityName);
// Employees entity = session.load(Employees.class, id);
return entity;
}
private EntityType<?> getEntityByName(String name) {
Set<EntityType<?>> entities = entityManager.getMetamodel().getEntities();
for (Iterator<EntityType<?>> iterator = entities.iterator(); iterator.hasNext();) {
EntityType<?> entityType = (EntityType<?>) iterator.next();
if (entityType.getName().equals(name))
return entityType;
}
return null;
}
}
Employees Class
#Configurable
#Entity
#Table(name = "employees", catalog = "employees")
public class Employees implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private int empNo;
private Date birthDate;
private String firstName;
private String lastName;
private String gender;
private Date hireDate;
private Set<Titles> titleses = new HashSet<Titles>(0);
private Set<Salaries> salarieses = new HashSet<Salaries>(0);
private Set<DeptEmp> deptEmps = new HashSet<DeptEmp>(0);
private Set<DeptManager> deptManagers = new HashSet<DeptManager>(0);
public Employees() {
}
public Employees(int empNo, Date birthDate, String firstName, String lastName, String gender, Date hireDate) {
this.empNo = empNo;
this.birthDate = birthDate;
this.firstName = firstName;
this.lastName = lastName;
this.gender = gender;
this.hireDate = hireDate;
}
public Employees(int empNo, Date birthDate, String firstName, String lastName, String gender, Date hireDate,
Set<Titles> titleses, Set<Salaries> salarieses, Set<DeptEmp> deptEmps, Set<DeptManager> deptManagers) {
this.empNo = empNo;
this.birthDate = birthDate;
this.firstName = firstName;
this.lastName = lastName;
this.gender = gender;
this.hireDate = hireDate;
this.titleses = titleses;
this.salarieses = salarieses;
this.deptEmps = deptEmps;
this.deptManagers = deptManagers;
}
#Id
#Column(name = "emp_no", unique = true, nullable = false)
public int getEmpNo() {
return this.empNo;
}
public void setEmpNo(int empNo) {
this.empNo = empNo;
}
#Temporal(TemporalType.DATE)
#Column(name = "birth_date", nullable = false, length = 10)
public Date getBirthDate() {
return this.birthDate;
}
public void setBirthDate(Date birthDate) {
this.birthDate = birthDate;
}
#Column(name = "first_name", nullable = false, length = 14)
public String getFirstName() {
return this.firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
#Column(name = "last_name", nullable = false, length = 16)
public String getLastName() {
return this.lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
#Column(name = "gender", nullable = false, length = 2)
public String getGender() {
return this.gender;
}
public void setGender(String gender) {
this.gender = gender;
}
#Temporal(TemporalType.DATE)
#Column(name = "hire_date", nullable = false, length = 10)
public Date getHireDate() {
return this.hireDate;
}
public void setHireDate(Date hireDate) {
this.hireDate = hireDate;
}
#OneToMany(fetch = FetchType.LAZY, mappedBy = "employees")
public Set<Titles> getTitleses() {
return this.titleses;
}
public void setTitleses(Set<Titles> titleses) {
this.titleses = titleses;
}
#OneToMany(fetch = FetchType.LAZY, mappedBy = "employees")
public Set<Salaries> getSalarieses() {
return this.salarieses;
}
public void setSalarieses(Set<Salaries> salarieses) {
this.salarieses = salarieses;
}
#OneToMany(fetch = FetchType.LAZY, mappedBy = "employees")
#JsonBackReference
public Set<DeptEmp> getDeptEmps() {
return this.deptEmps;
}
public void setDeptEmps(Set<DeptEmp> deptEmps) {
this.deptEmps = deptEmps;
}
#OneToMany(fetch = FetchType.LAZY, mappedBy = "employees")
public Set<DeptManager> getDeptManagers() {
return this.deptManagers;
}
public void setDeptManagers(Set<DeptManager> deptManagers) {
this.deptManagers = deptManagers;
}
}
When i am dynamically casting the path variable by using following code
Object idcasted = entityType.getIdType().getJavaType().cast(id);
Object entity = entityManager.find(entityType.getJavaType(), idcasted);
it is throwing ClassCastExpcetion
java.lang.ClassCastException: Cannot cast java.lang.String to int
at java.lang.Class.cast(Class.java:3369) ~[na:1.8.0_112]
at com.techm.att.ds.dao.EntityDAO.getEntityById(EntityDAO.java:33) ~[classes/:na]
at com.techm.att.ds.dao.EntityDAO$$FastClassBySpringCGLIB$$8e64d745.invoke() ~[classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738) ~[spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136) ~[spring-tx-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
any Help will be highly appriciated..
I write you a simple example regarding the comments.
This is the same behavior. Your RestController gets actually a string:
public static void main(String[] args) {
Object myString = "myString";
System.out.println(myString.getClass()); // class java.lang.String
int.class.cast(myString);
}
The cast method checks the instanceof your given value and it fails:
public T cast(Object obj) {
if (obj != null && !isInstance(obj))
throw new ClassCastException(cannotCastMsg(obj));
return (T) obj;
}

Err: mappedBy reference an unknown target entity property:

I dont know where actually im going wrong can someone help to get rid of this error.
#Entity
#Table(name="nifty", catalog="portfolio")
#JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id",scope=NiftyDTO.class)
#JsonIgnoreProperties({"latestData","data"})
public class NiftyDTO implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#Column(name="niftyid")
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
#Column(name="time")
private String time;
#Column(name="trdVolumesumMil")
private String trdVolumesumMil;
#Column(name="declines")
private int declines;
#Column(name="trdValueSum")
private String trdValueSum;
#Column(name="trdValueSumMil")
private String trdValueSumMil;
#Column(name="unchanged")
private int unchanged;
#Column(name="trdVolumesum")
private String trdVolumesum;
#Column(name="advances")
private int advances;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getTrdVolumesumMil() {
return trdVolumesumMil;
}
public void setTrdVolumesumMil(String trdVolumesumMil) {
this.trdVolumesumMil = trdVolumesumMil;
}
public int getDeclines() {
return declines;
}
public void setDeclines(int declines) {
this.declines = declines;
}
public String getTrdValueSum() {
return trdValueSum;
}
public void setTrdValueSum(String trdValueSum) {
this.trdValueSum = trdValueSum;
}
public String getTrdValueSumMil() {
return trdValueSumMil;
}
public void setTrdValueSumMil(String trdValueSumMil) {
this.trdValueSumMil = trdValueSumMil;
}
public int getUnchanged() {
return unchanged;
}
public void setUnchanged(int unchanged) {
this.unchanged = unchanged;
}
public String getTrdVolumesum() {
return trdVolumesum;
}
public void setTrdVolumesum(String trdVolumesum) {
this.trdVolumesum = trdVolumesum;
}
public int getAdvances() {
return advances;
}
public void setAdvances(int advances) {
this.advances = advances;
}
public NiftyDTO() {
super();
}
#OneToMany(mappedBy = "nifty", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Set<NiftyDataDTO> niftyDataDTO;
public Set<NiftyDataDTO> getNiftyDataDTO() {
return niftyDataDTO;
}
public void setNiftyDataDTO(Set<NiftyDataDTO> niftyDataDTO) {
this.niftyDataDTO = niftyDataDTO;
}
public NiftyDTO(Long id, String trdVolumesumMil, String time, int declines, String trdValueSum, String trdValueSumMil, int unchanged, String trdVolumesum, int advances, Set<NiftyDataDTO> niftyDatumDTOS) {
this.id = id;
this.trdVolumesumMil = trdVolumesumMil;
this.time = time;
this.declines = declines;
this.trdValueSum = trdValueSum;
this.trdValueSumMil = trdValueSumMil;
this.unchanged = unchanged;
this.trdVolumesum = trdVolumesum;
this.advances = advances;
this.niftyDataDTO = niftyDataDTO;
}
}
This is my another class
#Entity
#Table(name="NiftyDataDTO", catalog="portfolio")
#JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id", scope=NiftyDataDTO.class)
#JsonIgnoreProperties({"ptsC","per","trdVol","trdVolM","ntP","mVal","wkhi","wklo","wkhicm_adj","wklocm_adj","xDt","cAct","previousClose","dayEndClose","yPC","mPC"})
public class NiftyDataDTO implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#Column(name = "dataId")
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
#Column(name="symbol", nullable = false)
private String symbol;
#Column(name="open")
private float open;
#Column(name="high")
private float high;
#Column(name="low")
private float low;
#Column(name = "itp")
private float itp;
#XmlTransient
#ManyToOne(optional = true ,fetch = FetchType.LAZY)
#JoinColumn(name = "niftyid", referencedColumnName = "niftyid")
private NiftyDTO niftyDTO;
#JsonIgnore
public NiftyDTO getNiftyDTO() { return niftyDTO;}
public NiftyDataDTO(Long id, String symbol, float open, float high, float low, float itp, NiftyDTO niftyDTO) {
super();
this.id = id;
this.symbol = symbol;
this.open = open;
this.high = high;
this.low = low;
this.itp = itp;
this.niftyDTO = niftyDTO;
}
//Getter And Setter
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getSymbol() {
return symbol;
}
public void setSymbol(String symbol) {
this.symbol = symbol;
}
public float getOpen() {
return open;
}
public void setOpen(float open) {
this.open = open;
}
public float getHigh() {
return high;
}
public void setHigh(float high) {
this.high = high;
}
public float getLow() {
return low;
}
public void setLow(float low) {
this.low = low;
}
public float getItp() {
return itp;
}
public void setItp(float itp) {
this.itp = itp;
}
public void setNiftyDTO(NiftyDTO niftyDTO) {
this.niftyDTO = niftyDTO;
}
public NiftyDataDTO() {
super();
// TODO Auto-generated constructor stub
}
}
Stack Trace:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1582) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1054) ~[spring-context-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:829) ~[spring-context-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:760) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:360) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:306) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
at com.socgen.portfolio.PMSApplication.main(PMSApplication.java:17) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_92]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_92]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_92]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_92]
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) [idea_rt.jar:na]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit:
default] Unable to build Hibernate SessionFactory
atorg.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1249) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.access$600(EntityManagerFactoryBuilderImpl.java:120) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:860) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) ~[spring-orm-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:340) ~[spring-orm-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:319) ~[spring-orm-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1641) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
... 21 common frames omitted
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown
target entity property: com.socgen.portfolio.domain.NiftyDataDTO.nifty in com.socgen.portfolio.domain.NiftyDTO.niftyDataDTO
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:769) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:729) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:70) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1697) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1426) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1846) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:857) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
... 29 common frames omitted
2017-06-08 14:38:03.305 WARN 142244 --- [ main] o.s.boot.SpringApplication : Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' is defined)
Process finished with exit code 1
mappedby must have a valid property name as value:
#OneToMany(mappedBy = "niftyDTO", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Set<NiftyDataDTO> niftyDataDTO;

Spring Data missing property error when initialising the SOLR repository

I'm relatively new to spring. I'm trying to set up the spring-data-solr package. I'm using this customer class for both the JPA persistence with hibernate, and for writing to SOLR via the SOLR Data adapter. It hasn't worked yet.
When I start the server I get this error in the log:
Caused by: org.springframework.beans.factory.BeanCreationException:
Could not autowire field: private com.ideafactory.mvc.customers.model.CustomerRepository com.ideafactory.mvc.customers.admin.AddressController.customerRepository;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerRepository': Invocation of init method failed;
nested exception is org.springframework.data.mapping.PropertyReferenceException: No property flush found for type Customer!
Originally, it was saying no property "save" found on customer, so I did a test and just added a property called save. Then if I add flush, it says no property "delete" found. But it doesn't seem right to just keep adding these properties onto my domain class. I seem to be missing something on this Customer class to support the SOLR repository (maybe).
Also if I disable the #EnableSOLRRepositories annotation on my configuration class, the error doesn't happen, so it's definitely a problem related to the SOLR repository configuration.
Does anyone have any idea what the problem might be?
The class is below:
package com.ideafactory.mvc.customers.model;
import org.hibernate.annotations.Type;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
#Entity(name = "customer")
#Table(name = "customers")
public class Customer implements UserDetails {
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
#Basic
#Column(nullable = false)
private String preferredName;
#Basic
#Column(nullable = false)
private String firstName;
#Basic
#NotEmpty
private String lastName;
#Basic
#Column(unique = true)
#NotEmpty
#Email
private String email;
#Basic
#Column(nullable = false)
private String password;
#Basic
#Column(nullable = true)
private Date dateOfBirth;
#Basic
#Column(nullable = true)
private String bio;
#Basic
#Column(nullable = true)
private String website;
#Basic
#Column(nullable = true)
private Date lastLogin;
#Basic
#Column(nullable = true)
private Date lastLogout;
#Enumerated(EnumType.STRING)
private CustomerStatus status;
#Basic
#Column(nullable = false)
private Date createdAt;
#Basic
#Column(nullable = false)
private Date lastModified;
#Type(type = "org.hibernate.type.NumericBooleanType")
private boolean requiresReset;
#Type(type="org.hibernate.type.NumericBooleanType")
private boolean subscriber;
#Enumerated(EnumType.STRING)
private Gender gender;
#Basic
private String phoneNumber;
#OneToMany(fetch = FetchType.EAGER, mappedBy = "customer")
private List<Address> addressBook;
public String getPreferredName() {
return preferredName;
}
public void setPreferredName(String preferredName) {
this.preferredName = preferredName;
}
public boolean isSubscriber() {
return subscriber;
}
public void setSubscriber(boolean subscriber) {
this.subscriber = subscriber;
}
public boolean isRequiresReset() {
return requiresReset;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getLastModified() {
return lastModified;
}
public void setLastModified(Date lastModified) {
this.lastModified = lastModified;
}
public boolean getRequiresReset() {
return requiresReset;
}
public void setRequiresReset(boolean requiresReset) {
this.requiresReset = requiresReset;
}
#ManyToMany
#JoinTable(
name="customer_roles",
joinColumns={#JoinColumn(name="customerId", referencedColumnName="id")},
inverseJoinColumns={#JoinColumn(name="roleId", referencedColumnName="id")})
private List<Role> roles;
#Transient
public boolean isPersisted() {
return (this.id != null);
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String name) {
this.firstName = name;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public void setPassword(String password)
{
this.password = password;
}
#Override
public Collection<? extends GrantedAuthority> getAuthorities() {
Collection<GrantedAuthority> authorities = new ArrayList<>();
List<Role> userRoles = this.getRoles();
if(userRoles != null)
{
for (Role role : userRoles) {
SimpleGrantedAuthority authority = new SimpleGrantedAuthority(role.getRoleName());
authorities.add(authority);
}
}
return authorities;
}
#Override
public String getUsername()
{
return getEmail();
}
#Override
public String getPassword()
{
return this.password;
}
#Override
public boolean isAccountNonExpired()
{
return true;
}
#Override
public boolean isAccountNonLocked()
{
return true;
}
#Override
public boolean isCredentialsNonExpired()
{
return true;
}
#Override
public boolean isEnabled()
{
return true;
}
public List<Role> getRoles() {
return roles;
}
public void setRoles(List<Role> roles) {
this.roles = roles;
}
#PrePersist
void createdAt() {
this.createdAt = this.lastModified = new Date();
}
#PreUpdate
void updatedAt() {
this.createdAt = new Date();
}
public Date getDateOfBirth() {
return dateOfBirth;
}
public void setDateOfBirth(Date dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}
public String getBio() {
return bio;
}
public void setBio(String bio) {
this.bio = bio;
}
public String getWebsite() {
return website;
}
public void setWebsite(String website) {
this.website = website;
}
public Date getLastLogin() {
return lastLogin;
}
public void setLastLogin(Date lastLogin) {
this.lastLogin = lastLogin;
}
public Date getLastLogout() {
return lastLogout;
}
public void setLastLogout(Date lastLogout) {
this.lastLogout = lastLogout;
}
public CustomerStatus getStatus() {
return status;
}
public void setStatus(CustomerStatus status) {
this.status = status;
}
public Gender getGender() {
return gender;
}
public void setGender(Gender gender) {
this.gender = gender;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public List<Address> getAddressBook() {
return addressBook;
}
public void setAddressBook(List<Address> addressBook) {
this.addressBook = addressBook;
}
}
This was all I had for the eCustomer Repository. Am I supposed to implement an extension class?
package com.ideafactory.mvc.customers.model;
import org.springframework.data.solr.repository.SolrCrudRepository;
/**
* This is the SOLR repository handler
*/
public interface CustomerSolrCrudRepositoryImpl extends SolrCrudRepository<Customer, String> {
}
************ Update Below ***************
I've narrowed the problem down a little. I downloaded the source code for the spring jpa and stuck a debug point on the SolrRepositoryFactory class. So this is bizarre, but it's trying to resolve the named queries from my hibernate JPA repository using SOLR. So at the point the exception happens, it's trying to initialise what looks like a named query against SOLR. In my CustomerRepository (the Hibernate one) I've got findByEmail(String email).
What am I missing here? Why would the Solr repository initialisation be doing anything with my Hibernate customer repository definition?
/**
* Created on 30/06/2014.
*/
public interface CustomerRepository extends JpaRepository<Customer, Long> {
public List<Customer> findByEmail(String emailAddress);
public Address findOneByAddressBookId(Long addressId);
}
SOLR Config:
/**
* This class initialises the SOLR repositories.
*/
#Configuration
#EnableSolrRepositories(value = "com.ideafactory", multicoreSupport = true)
public class SolrConfig {
private static final String PROPERTY_NAME_SOLR_SERVER_URL = "solr.server.url";
#Resource
private Environment environment;
#Bean
public SolrServerFactory solrServerFactory() {
return new MulticoreSolrServerFactory(new HttpSolrServer(
environment.getRequiredProperty(PROPERTY_NAME_SOLR_SERVER_URL)));
}
#Bean
public SolrOperations solrTemplate1() {
SolrTemplate solrTemplate = new SolrTemplate(solrServerFactory());
solrTemplate.setSolrCore("core1");
return solrTemplate;
}
#Bean
public SolrOperations solrTemplate2() {
SolrTemplate solrTemplate = new SolrTemplate(solrServerFactory());
solrTemplate.setSolrCore("core2");
return solrTemplate;
}
#Bean
public SolrServer solrServer() throws MalformedURLException, IllegalStateException {
return new HttpSolrServer(environment.getRequiredProperty(PROPERTY_NAME_SOLR_SERVER_URL));
}
}
The stack trace follows.
17:34:39.966 ERROR org.springframework.web.context.ContextLoader 318 initWebApplicationContext - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'addressController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.ideafactory.mvc.customers.model.CustomerRepository com.ideafactory.mvc.customers.admin.AddressController.customerRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerRepository': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property save found for type Customer!
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292) ~[AutowiredAnnotationBeanPostProcessor.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185) ~[AbstractAutowireCapableBeanFactory.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) ~[AbstractAutowireCapableBeanFactory.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) ~[AbstractAutowireCapableBeanFactory.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) ~[AbstractBeanFactory$1.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[DefaultSingletonBeanRegistry.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) ~[AbstractBeanFactory.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) ~[AbstractBeanFactory.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:700) ~[DefaultListableBeanFactory.class:4.0.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760) ~[AbstractApplicationContext.class:4.0.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) ~[AbstractApplicationContext.class:4.0.0.RELEASE]
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:381) ~[ContextLoader.class:4.0.0.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:293) [ContextLoader.class:4.0.0.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) [ContextLoaderListener.class:4.0.0.RELEASE]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4758) [catalina.jar:8.0.9]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5184) [catalina.jar:8.0.9]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:8.0.9]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724) [catalina.jar:8.0.9]
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700) [catalina.jar:8.0.9]
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714) [catalina.jar:8.0.9]
at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1588) [catalina.jar:8.0.9]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_45]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_45]
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) [tomcat-coyote.jar:8.0.9]
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [?:1.7.0_45]
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) [?:1.7.0_45]
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:463) [catalina.jar:8.0.9]
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:413) [catalina.jar:8.0.9]
28-Jul-2014 17:34:39.975 SEVERE [RMI TCP Connection(4)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal Error listenerStart
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_45]
28-Jul-2014 17:34:39.976 SEVERE [RMI TCP Connection(4)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_45]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_45]
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) [tomcat-coyote.jar:8.0.9]
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [?:1.7.0_45]
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) [?:1.7.0_45]
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1487) [?:1.7.0_45]
at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:97) [?:1.7.0_45]
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1328) [?:1.7.0_45]
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1420) [?:1.7.0_45]
at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:848) [?:1.7.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_45]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_45]
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322) [?:1.7.0_45]
at sun.rmi.transport.Transport$1.run(Transport.java:177) [?:1.7.0_45]
at sun.rmi.transport.Transport$1.run(Transport.java:174) [?:1.7.0_45]
at java.security.AccessController.doPrivileged(Native Method) [?:1.7.0_45]
at sun.rmi.transport.Transport.serviceCall(Transport.java:173) [?:1.7.0_45]
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556) [?:1.7.0_45]
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811) [?:1.7.0_45]
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670) [?:1.7.0_45]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.7.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.7.0_45]
at java.lang.Thread.run(Thread.java:744) [?:1.7.0_45]
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.ideafactory.mvc.customers.model.CustomerRepository com.ideafactory.mvc.customers.admin.AddressController.customerRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerRepository': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property save found for type Customer!
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508) ~[AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.class:4.0.0.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) ~[InjectionMetadata.class:4.0.0.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289) ~[AutowiredAnnotationBeanPostProcessor.class:4.0.0.RELEASE]
... 56 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerRepository': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property save found for type Customer!
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553) ~[AbstractAutowireCapableBeanFactory.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) ~[AbstractAutowireCapableBeanFactory.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) ~[AbstractAutowireCapableBeanFactory.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) ~[AbstractBeanFactory$1.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[DefaultSingletonBeanRegistry.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) ~[AbstractBeanFactory.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) ~[AbstractBeanFactory.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1014) ~[DefaultListableBeanFactory.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:957) ~[DefaultListableBeanFactory.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:855) ~[DefaultListableBeanFactory.class:4.0.0.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480) ~[AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.class:4.0.0.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) ~[InjectionMetadata.class:4.0.0.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289) ~[AutowiredAnnotationBeanPostProcessor.class:4.0.0.RELEASE]
... 56 more
28-Jul-2014 17:34:39.980 WARNING [RMI TCP Connection(4)-127.0.0.1] org.apache.catalina.loader.WebappClassLoader.clearReferencesJdbc The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property save found for type Customer!
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:75) ~[PropertyPath.class:?]
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327) ~[PropertyPath.class:?]
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:307) ~[PropertyPath.class:?]
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:270) ~[PropertyPath.class:?]
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:241) ~[PropertyPath.class:?]
at org.springframework.data.repository.query.parser.Part.<init>(Part.java:76) ~[Part.class:?]
at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:213) ~[PartTree$OrPart.class:?]
at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:321) ~[PartTree$Predicate.class:?]
at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:301) ~[PartTree$Predicate.class:?]
at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:82) ~[PartTree.class:?]
at org.springframework.data.solr.repository.query.PartTreeSolrQuery.<init>(PartTreeSolrQuery.java:36) ~[PartTreeSolrQuery.class:?]
at org.springframework.data.solr.repository.support.SolrRepositoryFactory$SolrQueryLookupStrategy.resolveQuery(SolrRepositoryFactory.java:130) ~[SolrRepositoryFactory$SolrQueryLookupStrategy.class:?]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:320) ~[RepositoryFactorySupport$QueryExecutorMethodInterceptor.class:?]
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:169) ~[RepositoryFactorySupport.class:?]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:224) ~[RepositoryFactoryBeanSupport.class:?]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:210) ~[RepositoryFactoryBeanSupport.class:?]
at org.springframework.data.solr.repository.support.SolrRepositoryFactoryBean.afterPropertiesSet(SolrRepositoryFactoryBean.java:66) ~[SolrRepositoryFactoryBean.class:?]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612) ~[AbstractAutowireCapableBeanFactory.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549) ~[AbstractAutowireCapableBeanFactory.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) ~[AbstractAutowireCapableBeanFactory.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) ~[AbstractAutowireCapableBeanFactory.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) ~[AbstractBeanFactory$1.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[DefaultSingletonBeanRegistry.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) ~[AbstractBeanFactory.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) ~[AbstractBeanFactory.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1014) ~[DefaultListableBeanFactory.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:957) ~[DefaultListableBeanFactory.class:4.0.0.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:855) ~[DefaultListableBeanFactory.class:4.0.0.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480) ~[AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.class:4.0.0.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) ~[InjectionMetadata.class:4.0.0.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289) ~[AutowiredAnnotationBeanPostProcessor.class:4.0.0.RELEASE]
... 56 more
Ok for reference in case anyone needs it. I don't think I've quite fixed it, or understand why it was happening. But I've worked around this by separating the JPA repositories and SOLR repositories into separate packages, and in the annotation for each explicitly setting the full package directory.
I guess it could just be me not understanding how the repository initialisers work in Spring. So I just changed it to these values and it seems to have at least resolved the first issue:
e.g
#EnableJpaRepositories(basePackages="com.ideafactory.mvc.repositories.jpa")
#EnableSolrRepositories(value = "com.ideafactory.mvc.repositories.solr", multicoreSupport = true)

Resources