spring boot jpa trying to model an existing database - jpa

I have a database that I'm trying to model. There are 3 tables, table cycles with a one to many to table cyclesensors and a one to many to table sensors. I'm trying to get the latest cycle data and this is the query that I found to work:
Select c.id, cs.cycles, s.* from BizWareUser.Sensor s Inner Join BizWareUser.cyclesensor cs on s.SensorDataCol = cs.id
Inner Join BizWareUser.cycles c on c.id = cs.cycles
Where c.id IN (Select max(id) from BizWareUser.cycles cs)
When I use it in hql, I receive this error:
Could not write JSON: HHH000142:
I would like to have the data modeled in such a way for react to parse it properly:
cycles{
cyclesensors : [
cyclesensor:{
sensors : [
sensor : {
}
]
}
]
}
I'm very new to spring boot but I was hoping to do this without a explicitly writing the query. Below are my models:
Cycles:
#Entity
#Data
#Table(name="cycles", catalog="bizware_asp_test", schema="BizWareUser")
public class Cycles {
#Id
#GeneratedValue(strategy= GenerationType.AUTO)
#Column(name="id")
private Long id;
#Column(name="event_time")
private Timestamp event_time;
#Column(name="recipe")
private Short recipe;
#Column(name="cycle_duration")
private Short cycle_duration;
#Column(name="gondola")
private Short gondola;
#Column(name="part_index")
private Short part_index;
#Column(name="part_name")
private String part_name;
#Column(name="shift_count")
private Short shift_count;
#Column(name="pour_time")
private Short pour_time;
#Column(name="shift2")
private String shift2;
#Column(name="iron_temp")
private Short iron_temp;
#Column(name="alarm")
private Integer alarm;
#Column(name="pour_weight")
private Short pour_weight;
#Column(name="target_weight")
private Short target_weight;
#Column(name="pour_operator_id")
private String pour_operator_id;
#Column(name="cluster_weight")
private Short cluster_weight;
#Column(name="furnace")
private Character furnace;
#Column(name="heat")
private Character heat;
#Column(name="tap")
private Character tap;
#Column(name="recipe_A")
private Short recipe_A;
#Column(name="recipe_B")
private Short recipe_B;
#Column(name="partname_A")
private String partname_A;
#Column(name="partname_B")
private String partname_B;
#Column(name="fadetime")
private Integer fadetime;
#OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "cycles")
#JsonManagedReference
private Set<CycleSensor> cycleSensors = new HashSet<>();
CycleSensor:
#Entity
#Data
#Table(name="cyclesensor", catalog="bizware_asp_test", schema="BizWareUser")
public class CycleSensor {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
#Column(name="id")
private Integer Id;
#ManyToOne(fetch = FetchType.LAZY)
#JoinColumn(name = "cycles", nullable = false)
#JsonBackReference
private Cycles cycles;
#Column(name="compactor")
private String compactor;
#OneToMany
#JoinColumn(name="Id")
private Set<Sensor> sensors;
private CycleSensor(){}
Sensor:
#Entity
#Data
#Table(name="Sensor", catalog="bizware_asp_test", schema="BizWareUser")
public class Sensor {
#Id
#GeneratedValue(strategy= GenerationType.AUTO)
#Column(name="Id")
private Integer Id;
#Column(name="Channel")
private Integer Channel;
#Column(name="DateTime")
private Timestamp DateTime;
#Column(name="Unit")
private String Unit;
#Column(name="Peak")
private Float Peak;
#Column(name="Phase")
private Float Phase;
#Column(name="Amplitude")
private Float Amplitude;
#ManyToOne
#JoinColumn(name="SensorDataCol")
private CycleSensor CycleSensor;
CycleRepository:
#Repository
public interface CyclesRepository extends CrudRepository<Cycles, Long> {
#Query("Select s, cs, c from Sensor s Join s.CycleSensor as cs Join cs.cycles as c Where c.id IN (Select max(id) from Cycles)")
List<Cycles> findTop1ByOrderByIdDesc();
}
SensorRepository:
#Repository
public interface SensorRepository extends CrudRepository<Sensor, Long> {
#Query("Select s, cs, c from Sensor s Join s.CycleSensor as cs Join cs.cycles as c Where c.id IN (Select max(id) from Cycles)")
List<Sensor> findTop1ByOrderByIdDesc();
}
When I access from the cycles controller, I receive this:
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to
muellerspring.compactionsystemmonitor.Cycles at
muellerspring.compactionsystemmonitor.CyclesController.index(CyclesController.java:16)
~[classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method) ~[na:1.8.0_151] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
~[na:1.8.0_151] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~[na:1.8.0_151] at java.lang.reflect.Method.invoke(Method.java:498)
~[na:1.8.0_151] at
org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE] at
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE] at
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
~[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE] at
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
~[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE] at
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
~[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE] at
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
~[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE] at
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
~[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE] at
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
~[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE] at
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
~[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE] at
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
~[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE] at
javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
~[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
~[spring-webmvc-4.3.13.RELEASE.jar:4.3.13.RELEASE] at
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
~[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
~[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
~[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
~[tomcat-embed-websocket-8.5.23.jar:8.5.23] at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
~[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
~[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE] at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE] at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
~[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
~[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:108)
~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE] at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE] at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
~[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
~[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE] at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE] at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
~[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
~[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE] at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE] at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
~[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
~[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
~[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
[tomcat-embed-core-8.5.23.jar:8.5.23] at
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
[tomcat-embed-core-8.5.23.jar:8.5.23] at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[na:1.8.0_151] at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[na:1.8.0_151] at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
[tomcat-embed-core-8.5.23.jar:8.5.23] at
java.lang.Thread.run(Thread.java:748) [na:1.8.0_151]
When I run from the sensors controller, I get this.
Could not write JSON: HHH000142: Javassist Enhancement failed:
muellerspring.compactionsystemmonitor.Cycles; nested exception is
com.fasterxml.jackson.databind.JsonMappingException: HHH000142:
Javassist Enhancement failed:
muellerspring.compactionsystemmonitor.Cycles (through reference chain:
java.util.ArrayList[0]->muellerspring.compactionsystemmonitor.Sensor["cycleSensor"]->muellerspring.compactionsystemmonitor.CycleSensor["sensors"])
CyclesController
#RestController
public class CyclesController {
#Autowired
private CyclesRepository cyclesRepository;
#RequestMapping(value="/cycles", method=RequestMethod.GET)
public Cycles index(){
List<Cycles> cycles = cyclesRepository.findTop1ByOrderByIdDesc();
return cycles.get(0);
}
#RequestMapping(value="/cycles/count", method=RequestMethod.GET)
public Long Count(){
return cyclesRepository.count();
}
}
Sensor Controller:
#RestController
public class SensorController {
#Autowired
private SensorRepository sensorRepository;
#RequestMapping(value="/sensors", method=RequestMethod.GET)
public List<Sensor> index(){
List<Sensor> sensors = sensorRepository.findTop1ByOrderByIdDesc();
return sensors;
}
}

Related

(SpringBoot, JPA, Mysql) Error configuring logic to store user

Used : Mysql, JPA, SpringBoot
The following is the information I requested in Json format.
{
"id" : "abc#naver.com",
"password" : "abc1234",
"name" : "hi",
"phoneNumber" : "01012341234",
"ssn" : "0000000000000",
"cityName" : "seoul",
"townName" : "shinjeongdong",
"streetName" : "teheranro-22",
"zipCode" : "55950",
"dateils" : "5 floor"
}
Failed to configure logic to receive values through 'UserInfoDto' using PostMapping and store values in the 'Users' table.
I don't know what's wrong...
'Users' Entity
package My_Project.integration.entity;
import My_Project.integration.entity.Dto.UserInfoDto;
import lombok.*;
import javax.persistence.*;
import java.awt.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
#Entity
#Getter
#NoArgsConstructor
#AllArgsConstructor
#Setter
#Table(uniqueConstraints = {#UniqueConstraint(columnNames = {"ssn","phone_number"})})
public class Users {
#Column(name = "id", length = 40, updatable = false, nullable = false)
#Id
private String id;
#Column(name = "password", length = 20, nullable = false)
private String password;
#Column(name = "name", length = 25, nullable = false)
private String name;
#Column(name = "phone_number", length = 12, nullable = false)
private String phoneNumber;
#Column(name = "ssn", length = 13, nullable = false, updatable = false)
private String ssn;
#Embedded
private Address address;
#Column(name = "point")
private Long point;
#OneToMany(mappedBy = "postedUser")
private List<PostInfo> uploadedPost = new ArrayList<>();
#OneToMany(mappedBy = "userId")
private List<PointHistory> pointHistories = new ArrayList<>();
#Embedded
private Dates dates;
public Users(UserInfoDto userInfoDto){
this.setId(userInfoDto.getId());
this.setPassword(userInfoDto.getPassword());
this.setPhoneNumber(userInfoDto.getPhoneNumber());
this.setSsn(userInfoDto.getSsn());
this.setPoint(0L);
Address address = new Address(
userInfoDto.getCityName(),
userInfoDto.getTownName(),
userInfoDto.getStreetName(),
userInfoDto.getZipCode(),
userInfoDto.getDetailsCode()
);
this.setAddress(address);
List<PostInfo> postInfoList = new ArrayList<>();
List<PointHistory> pointHistoryList = new ArrayList<>();
this.setUploadedPost(postInfoList);
this.setPointHistories(pointHistoryList);
Dates dates = new Dates(LocalDateTime.now(), LocalDateTime.now());
this.setDates(dates);
}
}
It's Entity 'Address', an embedded entity in 'Users'.
package My_Project.integration.entity;
import lombok.AllArgsConstructor;
import lombok.Getter;
import javax.persistence.Column;
import javax.persistence.Embeddable;
#Embeddable
#Getter
#AllArgsConstructor
public class Address {
#Column(name = "city_name", nullable = false) //도시명
private String cityName;
#Column(name = "town_name", length = 20) //동명
private String townName;
#Column(name = "street_name", length = 20, nullable = false) //도로명
private String streetName;
#Column(name = "zip_code", length = 20) // 우편번호
private String zipCode;
#Column(name = "details",length = 20) //상세주소
private String detailsCode;
protected Address() {
}
}
This is the Dto to use instead of the 'Users' entity.
package My_Project.integration.entity.Dto;
import My_Project.integration.entity.PointHistory;
import My_Project.integration.entity.PostInfo;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
#Setter
#Getter
public class UserInfoDto {
private String id;
private String password;
private String name;
private String phoneNumber;
private String ssn;
private String cityName;
private String townName;
private String streetName;
private String zipCode;
private String detailsCode;
private Long point;
public UserInfoDto(String id, String password, String name, String phoneNumber, String ssn, String cityName, String townName, String streetName, String zipCode, String detailsCode, Long point) {
this.id = id;
this.password = password;
this.name = name;
this.phoneNumber = phoneNumber;
this.ssn = ssn;
this.cityName = cityName;
this.townName = townName;
this.streetName = streetName;
this.zipCode = zipCode;
this.detailsCode = detailsCode;
this.point = point;
}
public UserInfoDto() {
}
}
package My_Project.integration.controller;
import My_Project.integration.entity.*;
import My_Project.integration.entity.Dto.UserInfoDto;
import My_Project.integration.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
#Controller
#RequiredArgsConstructor
public class SignupPageController {
#Autowired private UserService userService;
#PostMapping("/signup_execute")
public String signUp(UserInfoDto userInfoDto) {
try {
Users users = new Users(userInfoDto);
userService.addUsers(users);
} catch (Exception e){
e.printStackTrace();
return "redirect:/errorpage";
}
return "redirect:/";
}
}
package My_Project.integration.service;
import My_Project.integration.entity.Users;
import My_Project.integration.repository.UsersRepository;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.bytebuddy.implementation.bytecode.Throw;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
#Service
#RequiredArgsConstructor
#Getter
public class UserService {
#Autowired
private UsersRepository usersRepository;
#Transactional
public Users addUsers(Users users) throws Exception{
if (!usersRepository.duplicateCheck(users)) {
throw new Exception("중복된 값이 검출되었습니다.");
} else {
usersRepository.save(users);
System.out.println("Users 엔티티를 저장하였습니다.");
return users;
}
}
}
package My_Project.integration.repository.UserCustom.Impl;
import My_Project.integration.entity.Users;
import My_Project.integration.repository.UserCustom.UserCustomRepository;
import lombok.RequiredArgsConstructor;
import net.bytebuddy.implementation.bytecode.Throw;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.swing.text.html.Option;
import java.util.List;
import java.util.Optional;
#RequiredArgsConstructor
public class UserCustomRepositoryImpl implements UserCustomRepository {
private final EntityManager em;
#Override
public boolean duplicateCheck(Users users) {
Query query1 = em.createQuery("select u from Users u where u.id = :name",Users.class)
.setParameter("name",users.getId());
List resultList1 = query1.getResultList();
if(!resultList1.isEmpty()) return false;
Query query2 = em.createQuery("select u from Users u where u.phoneNumber= :name",Users.class)
.setParameter("name",users.getPhoneNumber());
List resultList2 = query2.getResultList();
if(!resultList2.isEmpty()) return false;
Query query3 = em.createQuery("select u from Users u where u.ssn = :name",Users.class)
.setParameter("name",users.getSsn());
List resultList3 = query3.getResultList();
if(!resultList3.isEmpty()) return false;
return true;
}
}
It's error content....
org.springframework.orm.jpa.JpaSystemException: ids for this class must be manually assigned before calling save(): My_Project.integration.entity.Users; nested exception is org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): My_Project.integration.entity.Users
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:331)
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:233)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:551)
at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:61)
at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:242)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:152)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:174)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
at jdk.proxy4/jdk.proxy4.$Proxy109.save(Unknown Source)
at My_Project.integration.service.UserService.addUsers(UserService.java:26)
at My_Project.integration.service.UserService$$FastClassBySpringCGLIB$$636d190f.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708)
at My_Project.integration.service.UserService$$EnhancerBySpringCGLIB$$7615f959.addUsers(<generated>)
at My_Project.integration.controller.SignupPageController.signUp(SignupPageController.java:24)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1071)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:964)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:696)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:779)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1789)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): My_Project.integration.entity.Users
at org.hibernate.id.Assigned.generate(Assigned.java:33)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:115)
at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:185)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:128)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:55)
at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:107)
at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:756)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:742)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:362)
at jdk.proxy4/jdk.proxy4.$Proxy105.persist(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:311)
at jdk.proxy4/jdk.proxy4.$Proxy105.persist(Unknown Source)
at org.springframework.data.jpa.repository.support.SimpleJpaRepository.save(SimpleJpaRepository.java:666)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.data.repository.core.support.RepositoryMethodInvoker$RepositoryFragmentMethodInvoker.lambda$new$0(RepositoryMethodInvoker.java:289)
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:137)
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:121)
at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:530)
at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:286)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:640)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:164)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:139)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:81)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
... 71 more
Successful data storage was expected, but it was not.

spring data jpa not saving entity with #idClass

on postgresql I have a partitioned table like this
CREATE TABLE measurements
(
id bigserial NOT NULL,
measurement_timestamp timestamp without time zone,
measurement_value numeric(100,15),
....
CONSTRAINT measurements_pk PRIMARY KEY (id,measurement_timestamp)
)
partition BY range (measurement_timestamp);
my implementation of the entity class with the composite key is
#Entity
#Getter
#Setter
#ToString
#EqualsAndHashCode
#Table(name = "measurements")
#IdClass(MeasurementEntityPK.class)
public class MeasurementEntity {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
#Id
#Column(name = "measurement_timestamp")
#Temporal(TemporalType.TIMESTAMP)
private Date measurementTimestamp;
#Column(name = "measurement_value")
private BigDecimal value;
......
}
while the implementation of the IdClass is this one
#Getter
#Setter
#EqualsAndHashCode
#NoArgsConstructor
#AllArgsConstructor
public class MeasurementEntityPK implements Serializable {
private static final long serialVersionUID = -1833086811518641500L;
private Long id;
private Date measurementTimestamp;
}
I'm using springdata jpa and my repository is
#Repository
public interface MeasurementRepository extends JpaRepository<MeasurementEntity, MeasurementEntityPK> {
#Override
Optional<MeasurementEntity> findById(MeasurementEntityPK measurementEntityPK);
#Override
List<MeasurementEntity> findAllById(Iterable<MeasurementEntityPK> iterable);
}
When i try to save a new entity or batch save a list of new entities i got the following exception
2019-12-18 17:48:33.864 ERROR 23332 --- [nio-8080-exec-1] i.e.a.c.i.IngestionRestController : org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.lang.Long]: No default constructor found; nested exception is java.lang.NoSuchMethodException: java.lang.Long.<init>()
org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.lang.Long]: No default constructor found; nested exception is java.lang.NoSuchMethodException: java.lang.Long.<init>()
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:129) ~[spring-beans-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.beans.AbstractNestablePropertyAccessor.<init>(AbstractNestablePropertyAccessor.java:131) ~[spring-beans-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.beans.BeanWrapperImpl.<init>(BeanWrapperImpl.java:111) ~[spring-beans-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.data.util.DirectFieldAccessFallbackBeanWrapper.<init>(DirectFieldAccessFallbackBeanWrapper.java:40) ~[spring-data-commons-2.1.11.RELEASE.jar:2.1.11.RELEASE]
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation$IdentifierDerivingDirectFieldAccessFallbackBeanWrapper.<init>(JpaMetamodelEntityInformation.java:325) ~[spring-data-jpa-2.1.11.RELEASE.jar:2.1.11.RELEASE]
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.getId(JpaMetamodelEntityInformation.java:155) ~[spring-data-jpa-2.1.11.RELEASE.jar:2.1.11.RELEASE]
at org.springframework.data.repository.core.support.AbstractEntityInformation.isNew(AbstractEntityInformation.java:42) ~[spring-data-commons-2.1.11.RELEASE.jar:2.1.11.RELEASE]
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.isNew(JpaMetamodelEntityInformation.java:231) ~[spring-data-jpa-2.1.11.RELEASE.jar:2.1.11.RELEASE]
at org.springframework.data.jpa.repository.support.SimpleJpaRepository.save(SimpleJpaRepository.java:534) ~[spring-data-jpa-2.1.11.RELEASE.jar:2.1.11.RELEASE]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:359) ~[spring-data-commons-2.1.11.RELEASE.jar:2.1.11.RELEASE]
at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:200) ~[spring-data-commons-2.1.11.RELEASE.jar:2.1.11.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:644) ~[spring-data-commons-2.1.11.RELEASE.jar:2.1.11.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:608) ~[spring-data-commons-2.1.11.RELEASE.jar:2.1.11.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$invoke$3(RepositoryFactorySupport.java:595) ~[spring-data-commons-2.1.11.RELEASE.jar:2.1.11.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:595) ~[spring-data-commons-2.1.11.RELEASE.jar:2.1.11.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59) ~[spring-data-commons-2.1.11.RELEASE.jar:2.1.11.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:295) ~[spring-tx-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98) ~[spring-tx-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) ~[spring-tx-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:144) ~[spring-data-jpa-2.1.11.RELEASE.jar:2.1.11.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$ExposeRepositoryInvocationInterceptor.invoke(CrudMethodMetadataPostProcessor.java:364) ~[spring-data-jpa-2.1.11.RELEASE.jar:2.1.11.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93) ~[spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61) ~[spring-data-commons-2.1.11.RELEASE.jar:2.1.11.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at com.sun.proxy.$Proxy106.save(Unknown Source) ~[na:na]
at it.eng.arpacal.service.MeasurementService.saveAll(MeasurementService.java:79) ~[classes/:na]
at it.eng.arpacal.service.MeasurementService$$FastClassBySpringCGLIB$$553f6107.invoke(<generated>) ~[classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:750) ~[spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:295) ~[spring-tx-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98) ~[spring-tx-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689) ~[spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at it.eng.arpacal.service.MeasurementService$$EnhancerBySpringCGLIB$$fe8de70c.saveAll(<generated>) ~[classes/:na]
at it.eng.arpacal.manager.GridManager.ingestCSV(GridManager.java:200) ~[classes/:na]
at it.eng.arpacal.manager.GridManager$$FastClassBySpringCGLIB$$8c2ab491.invoke(<generated>) ~[classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:685) ~[spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at it.eng.arpacal.manager.GridManager$$EnhancerBySpringCGLIB$$cd5367ea.ingestCSV(<generated>) ~[classes/:na]
at it.eng.arpacal.controller.ingestion.IngestionRestController.ingestData(IngestionRestController.java:46) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:893) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:798) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:634) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.26.jar:9.0.26]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:94) ~[spring-web-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1589) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.26.jar:9.0.26]
at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
Caused by: java.lang.NoSuchMethodException: java.lang.Long.<init>()
at java.base/java.lang.Class.getConstructor0(Class.java:3350) ~[na:na]
at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2554) ~[na:na]
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:122) ~[spring-beans-5.1.10.RELEASE.jar:5.1.10.RELEASE]
... 107 common frames omitted
i cannot understand what's wrong in my implementation.
If i use a String instead of Long with #GeneratedValue it works... but i would like to use the Long with the generated vale got from a db sequence
Any help?

Null pointer exception when calling JPA named query

I know there are many questions like this here but I've looked at tons and still haven't been able to solve my problem.
I am trying call a named query. I have the following:
#Stateless
public class ClientCFacade extends AbstractFacade<ClientC> {
#PersistenceContext(unitName = "the_database")
private EntityManager em;
#Override
protected EntityManager getEntityManager() {
return em;
}
public ClientCFacade() {
super(ClientC.class);
}
public List<ClientC> findByClientId(Integer clientId) {
try {
List<ClientC> clientCsList = em.createNamedQuery(ClientCs.FIND_BY_CLIENT_ID, ClientC.class).
setParameter("clientId", clientId)
.getResultList();
return clientCsList;
} catch (NoResultException ex) {
return null;
}
}
and
#Entity
#Table(name = "clients")
#NamedQueries({
#NamedQuery(name = ClientCs.FIND_BY_CLIENT_ID,
query = "select cc" +
"from " +
"ClientCs cc " +
"WHERE " +
"cc.clientId= :clientId")
})
public class ClientCs implements Serializable {
private static final long serialVersionUID = 1L;
public static final String FIND_BY_CLIENT_ID = "ClientCs.findByClientId";
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
#Column(name = "id")
private Integer id;
#Column(name = "client_id", nullable = false)
private Integer clientId;
with all the getters and setters.
And I call it like:
List<ClientC> Cs = clientCFacade.findByClientId(1234);
My error is:
java.lang.NullPointerException
at the.package.name.ClientCFacade.findByClientId(ClientCFacade.java:56)
at the.package.name.service.ApiService.runTransaction(ApiService.java:413)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185)
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:745)
Any help is seriously appreciated.
You're setting a parameter which doesn't exist in your named query.
Replace id with clientId in the method public List<ClientC> findByClientId(String clientId)
It should look like this:
List<ClientC> clientCsList = em.createNamedQuery(ClientCs.FIND_BY_CLIENT_ID, ClientC.class).
setParameter("clientId", clientId)
.getResultList();

jpa select new with embedded key throws exception

I am getting an exception when trying to run the following named query
#NamedQuery(name = "software.listAssemblies", query = "SELECT distinct NEW com.blackbox.dao.AssemblyToBootloaderDTO(s.id.assemblyId, s.filename) FROM Software s where s.id.platformId = :platformId and s.id.txaddress = :txaddress and s.filetype = 'SBL';")
If I remove the reference to the AssemblyToBootloaderDTO so the query reads
#NamedQuery(name = "software.listAssemblies", query = "SELECT distinct s.id.assemblyId, s.filename FROM Software s where s.id.platformId = :platformId and s.id.txaddress = :txaddress and s.filetype = 'SBL';")
then the query runs successfully returning a list of object[] as expected.
I have several named queries in my app that create DTO objects via SELECT NEW that run without a problem, but this is the first one I've tried where I'm using a field from an embedded key in the DTO so I'm guessing that I'm missing some syntax here. What do I need to do to get the mapping to the DTO class work?
#Entity
#Table(name="software")
#NamedQueries({
#NamedQuery(name = "software.listBootLoaders", query = "SELECT distinct s.filename FROM Software s where s.id.platformId = :platformId and s.id.txaddress = :txaddress and s.filetype = 'SBL';"),
#NamedQuery(name = "software.listAssemblies", query = "SELECT distinct NEW com.blackbox.dao.AssemblyToBootloaderDTO(s.id.assemblyId, s.filename) FROM Software s where s.id.platformId = :platformId and s.id.txaddress = :txaddress and s.filetype = 'SBL';")
})
public class Software implements Serializable {
private static final long serialVersionUID = 1L;
#EmbeddedId
private SoftwarePK id;
#Column(name="fileName", length=32)
private String filename;
#Column(name="fileType", length=8)
private String filetype;
#Column(name="predecessor", length=64)
private String predecessor;
#Column(name="successor", length=64)
private String successor;
//bi-directional many-to-one association to Hardware
#ManyToOne(fetch=FetchType.LAZY)
#JoinColumns({
#JoinColumn(name="assemblyId", referencedColumnName="assemblyId", nullable=false, insertable=false, updatable=false),
#JoinColumn(name="busId", referencedColumnName="busId", nullable=false, insertable=false, updatable=false),
#JoinColumn(name="hardwareId", referencedColumnName="hardwareId", nullable=false, insertable=false, updatable=false),
#JoinColumn(name="platformId", referencedColumnName="platformId", nullable=false, insertable=false, updatable=false),
#JoinColumn(name="txAddress", referencedColumnName="txAddress", nullable=false, insertable=false, updatable=false)
})
private Hardware hardware;
public Software() {
}
public SoftwarePK getId() {
return this.id;
}
public void setId(SoftwarePK id) {
this.id = id;
}
... getters/setters omitted
The embedded key;
#Embeddable
public class SoftwarePK implements Serializable {
//default serial version id, required for serializable classes.
private static final long serialVersionUID = 1L;
#Column(name="platformId",unique=true, nullable=false)
private int platformId;
#Column(name="busId", unique=true, nullable=false)
private int busid;
#Column(name="txAddress", unique=true, nullable=false, length=3)
private String txaddress;
#Column(name="assemblyId",unique=true, nullable=false, length=64)
private String assemblyId;
#Column(name="hardwareId",unique=true, nullable=false, length=64)
private String hardwareId;
#Column(name="sequence",unique=true, nullable=false)
private int sequence;
#Column(name="softwareId",unique=true, nullable=false, length=64)
private String softwareId;
public SoftwarePK() {
}
getters/setters omitted.
The DTO;
public class AssemblyToBootloaderDTO {
private String assemblyId;
private String softwareBootloaderId;
public AssemblyToBootloaderDTO(String assemblyId,
String softwareBootloaderId) {
this.assemblyId = assemblyId;
this.softwareBootloaderId = softwareBootloaderId;
}
public String getAssemblyId() {
return assemblyId;
}
public String getSoftwareBootloaderId() {
return softwareBootloaderId;
}
}
and the exception;
Exception [EclipseLink-6052] (Eclipse Persistence Services - 2.1.3.v20110304-r9073): org.eclipse.persistence.exceptions.QueryException
Exception Description: An outer join (getAllowingNull or anyOfAllowingNone) is only valid for OneToOne, OneToMany, ManyToMany, AggregateCollection and DirectCollection Mappings, and cannot be used for the mapping [org.eclipse.persistence.mappings.DirectToFieldMapping[assemblyId-->software.assemblyId]].
org.eclipse.persistence.exceptions.QueryException.outerJoinIsOnlyValidForOneToOneMappings(QueryException.java:924)
org.eclipse.persistence.internal.expressions.QueryKeyExpression.validateNode(QueryKeyExpression.java:863)
org.eclipse.persistence.expressions.Expression.normalize(Expression.java:3009)
org.eclipse.persistence.internal.expressions.DataExpression.normalize(DataExpression.java:342)
org.eclipse.persistence.internal.expressions.QueryKeyExpression.normalize(QueryKeyExpression.java:612)
org.eclipse.persistence.internal.expressions.QueryKeyExpression.normalize(QueryKeyExpression.java:599)
org.eclipse.persistence.internal.expressions.SQLSelectStatement.normalize(SQLSelectStatement.java:1311)
org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.buildReportQuerySelectStatement(ExpressionQueryMechanism.java:560)
org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.buildReportQuerySelectStatement(ExpressionQueryMechanism.java:506)
org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.prepareReportQuerySelectAllRows(ExpressionQueryMechanism.java:1527)
org.eclipse.persistence.queries.ReportQuery.prepareSelectAllRows(ReportQuery.java:1298)
org.eclipse.persistence.queries.ReadAllQuery.prepare(ReadAllQuery.java:625)
org.eclipse.persistence.queries.ReportQuery.prepare(ReportQuery.java:1047)
org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:509)
org.eclipse.persistence.queries.ObjectLevelReadQuery.checkPrepare(ObjectLevelReadQuery.java:820)
org.eclipse.persistence.queries.DatabaseQuery.prepareCall(DatabaseQuery.java:1588)
org.eclipse.persistence.internal.jpa.EJBQueryImpl.getDatabaseQueryInternal(EJBQueryImpl.java:568)
org.eclipse.persistence.internal.jpa.EntityManagerImpl.createNamedQuery(EntityManagerImpl.java:1001)
com.blackbox.dao.JpaSoftwareDao.listAssemblies(JpaSoftwareDao.java:168)
com.blackbox.services.Services.getAssemblyNames(Services.java:571)
com.blackbox.genesis.ccfeditor.services.NanocomService.buildSource(NanocomService.java:48)
com.blackbox.genesis.actions.ccfedit.DownloadCCForNanocom.execute(DownloadCCForNanocom.java:35)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
com.blackbox.x.interceptors.LicenseInterceptor.intercept(LicenseInterceptor.java:75)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.blackbox.x.interceptors.Log4jMDCInterceptor.intercept(Log4jMDCInterceptor.java:51)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.blackbox.x.interceptors.RedirectMessageInterceptor.doIntercept(RedirectMessageInterceptor.java:78)
com.blackbox.x.interceptors.RedirectMessageInterceptor.intercept(RedirectMessageInterceptor.java:63)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter.doFilter(StrutsExecuteFilter.java:88)
com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter.doFilter(StrutsPrepareFilter.java:82)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
Seems to be a jpa/implementation bug, I am running eclipselink 2.3 and get the same issue.
As alternative, remove #Embeddable and #EmbeddedId and use #IdClass on entity level instead with #Id on your key fields i.e:
#Table(name = "MY_TABLE")
#IdClass(value=MyTableId.class)
public class MyTableEntity implements Serializable {
private static final long serialVersionUID = 1000L;
public static class MyTableId implements Serializable {
private static final long serialVersionUID = 1000L;
private Integer keyFieldOne;
private String keyFieldTwo;
public MyTableId() {
super();
}
public MyTableId(Integer keyFieldOne, String keyFieldTwo) {
this.keyFieldOne = keyFieldOne;
this.keyFieldTwo = keyFieldTwo;
}
#Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
MyTableId myTableId = (MyTableId)obj;
return Objects.equal(keyFieldOne, myTableId.keyFieldOne) && Objects.equal(keyFieldTwo, myTableId.keyFieldTwo);
}
#Override
public int hashCode() {
return Objects.hashCode(keyFieldOne, keyFieldTwo);
}
}
#Id
#Column(name = "KEY_FIELD_ONE", nullable = false)
private Integer keyFieldOne;
#Id
#Column(name = "KEY_FIELD_TWO", nullable = false, length = 8)
private String keyFieldTwo;
...
}
Note I used google guava for hash code and equals overrides
Seems to be an issue with the join inside the constructor element.
Try the latest/2.4 release, I would guess this has been fixed. If still not luck, please log a bug.

JPA javax.persistence.metamodel.ListAttribute

I am running a JPA test and I keep getting the error at the end of this post. I have no idea why I'm getting this error, however, I do not get this error when testing in JUnit. I know this is probably a generic message and a broad question but if there's a simple answer, I would appreciate it.
Here are my 3 class files:
package menu.entity;
import static javax.persistence.CascadeType.ALL;
import java.io.Serializable;
import javax.persistence.*;
import java.math.BigDecimal;
import java.util.List;
#IdClass(menu.entity.FeatureKey.class)
#Entity
#Table(name="FEATURES")
public class Feature implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#Column(name="PROD_ID",
nullable = false,
insertable = false,
updatable = false,
precision=22)
private BigDecimal prodId;
#Id
#Column(name="FEATURE",
nullable = false,
insertable = false,
updatable = false,
precision=22)
private BigDecimal feature;
#Column(name="FEATURE_NAME", length=50)
private String featureName;
#Column(name="FEATURE_PATH", length=100)
private String featurePath;
#OneToMany(cascade=ALL, mappedBy="featureObj")
private List<Function> functions;
#ManyToOne
#JoinColumns({
#JoinColumn(name="PROD_ID", referencedColumnName="PROD_ID")
})
private Product product;
public Feature() {
}
public BigDecimal getFeature() {
return this.feature;
}
public void setFeature(BigDecimal feature) {
this.feature = feature;
}
public String getFeatureName() {
return this.featureName;
}
public void setFeatureName(String featureName) {
this.featureName = featureName;
}
public String getFeaturePath() {
return this.featurePath;
}
public void setFeaturePath(String featurePath) {
this.featurePath = featurePath;
}
public BigDecimal getProdId() {
return this.prodId;
}
public void setProdId(BigDecimal prodId) {
this.prodId = prodId;
}
public Product getProduct() {
return product;
}
public void setProduct(Product product) {
this.product = product;
}
public List<Function> getFunctions() {
return functions;
}
public void setFunctions(List<Function> functions) {
this.functions = functions;
}
}
package menu.entity;
import java.math.BigDecimal;
import javax.annotation.Generated;
import javax.persistence.metamodel.ListAttribute;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;
#Generated(value="Dali", date="2012-10-01T17:03:26.750-0400")
#StaticMetamodel(Feature.class)
public class Feature_ {
public static volatile SingularAttribute<Feature, BigDecimal> prodId;
public static volatile SingularAttribute<Feature, BigDecimal> feature;
public static volatile SingularAttribute<Feature, String> featureName;
public static volatile SingularAttribute<Feature, String> featurePath;
public static volatile ListAttribute<Feature, Function> functions;
public static volatile SingularAttribute<Feature, Product> product;
}
package menu.entity;
import static javax.persistence.CascadeType.ALL;
import java.io.Serializable;
import javax.persistence.*;
import java.math.BigDecimal;
import java.util.List;
#IdClass(menu.entity.FunctionKey.class)
#Entity
#Table(name="FUNCTIONS")
public class Function implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#Column(name="PROD_ID",
nullable = false,
insertable = false,
updatable = false,
precision=22)
private BigDecimal prodId;
#Id
#Column(name="FEATURE",
nullable = false,
insertable = false,
updatable = false,
precision=22)
private BigDecimal feature;
#Id
#Column(name="FUNC",
nullable = false,
insertable = false,
updatable = false,
precision=22)
private BigDecimal func;
#Column(name="FUNC_NAME", length=50)
private String funcName;
#Column(name="FUNC_PATH", length=80)
private String funcPath;
#OneToMany(cascade=ALL, mappedBy="function")
private List<Task> tasks;
#ManyToOne
#JoinColumns({
#JoinColumn(name="PROD_ID", referencedColumnName="PROD_ID"),
#JoinColumn(name="FEATURE", referencedColumnName="FEATURE")
})
private Feature featureObj;
public Function() {
}
public BigDecimal getFeature() {
return this.feature;
}
public void setFeature(BigDecimal feature) {
this.feature = feature;
}
public BigDecimal getFunc() {
return func;
}
public void setFunc(BigDecimal func) {
this.func = func;
}
public String getFuncName() {
return this.funcName;
}
public void setFuncName(String funcName) {
this.funcName = funcName;
}
public String getFuncPath() {
return this.funcPath;
}
public void setFuncPath(String funcPath) {
this.funcPath = funcPath;
}
public BigDecimal getProdId() {
return this.prodId;
}
public void setProdId(BigDecimal prodId) {
this.prodId = prodId;
}
public Feature getFeatureObj() {
return featureObj;
}
public void setFeatureObj(Feature featureObj) {
this.featureObj = featureObj;
}
public List<Task> getTasks() {
return tasks;
}
public void setTasks(List<Task> tasks) {
this.tasks = tasks;
}
}
Regards,
Paul
Here is the full stack trace:
java.lang.IllegalArgumentException: Attribute "functions" of any not
found in menu.entity.Feature at
org.apache.openjpa.persistence.meta.AbstractManagedType.notFoundException(AbstractManagedType.java:734)
at
org.apache.openjpa.persistence.meta.AbstractManagedType.getAttribute(AbstractManagedType.java:237)
at
org.apache.openjpa.persistence.meta.AbstractManagedType.getAttribute(AbstractManagedType.java:461)
at
org.apache.openjpa.persistence.meta.MetamodelImpl.populate(MetamodelImpl.java:311)
at
org.apache.openjpa.persistence.meta.MetamodelImpl.instantiate(MetamodelImpl.java:257)
at
org.apache.openjpa.persistence.meta.MetamodelImpl.find(MetamodelImpl.java:226)
at
org.apache.openjpa.persistence.meta.MetamodelImpl.(MetamodelImpl.java:91)
at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.getMetamodel(EntityManagerFactoryImpl.java:346)
at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.getCriteriaBuilder(EntityManagerFactoryImpl.java:333)
at
org.apache.openjpa.persistence.EntityManagerImpl.getCriteriaBuilder(EntityManagerImpl.java:1649)
at
org.apache.openjpa.persistence.EntityManagerImpl.getCriteriaBuilder(EntityManagerImpl.java:101)
at menu.ejb.RequestBean.init(RequestBean.java:60) at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597) at
org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:267)
at
org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
at
org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
at
org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:263)
at
org.jboss.weld.introspector.jlr.WeldMethodImpl.invoke(WeldMethodImpl.java:174)
at
org.jboss.weld.bean.AbstractClassBean.defaultPostConstruct(AbstractClassBean.java:398)
at
org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.postConstruct(ManagedBean.java:174)
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:294) at
org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:68)
at
org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:599)
at
org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:665)
at
org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:136)
at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:686) at
org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:695)
at
org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1$1.proceed(ManagedBean.java:161)
at
org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48)
at
org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1.work(ManagedBean.java:157)
at
org.jboss.weld.bean.ManagedBean$FixInjectionPoint.run(ManagedBean.java:131)
at
org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.inject(ManagedBean.java:153)
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:293) at
org.jboss.weld.context.AbstractContext.get(AbstractContext.java:103)
at
org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:90)
at
org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:79)
at
menu.web.MenuManager$Proxy$_$$WeldClientProxy.getMenuItemsS(MenuManager$Proxy$$$_WeldClientProxy.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597) at
javax.el.BeanELResolver.getValue(BeanELResolver.java:87) at
com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at
com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at org.apache.el.parser.AstValue.getValue(AstValue.java:169) at
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
at
org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
at
com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIOutput.getValue(UIOutput.java:169) at
com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
at
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
at
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
at
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
at
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
at
javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
at
javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
at
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662) Oct 2, 2012 12:50:22 PM
com.sun.faces.application.view.FaceletViewHandlingStrategy
handleRenderException SEVERE: Error Rendering View[/menu.xhtml]
javax.el.ELException: /menu.xhtml #26,51
value="#{menuManager.menuItemsS}": Error reading 'menuItemsS' on type
menu.web.MenuManager$Proxy$_$$_WeldClientProxy at
com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:114)
at
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIOutput.getValue(UIOutput.java:169) at
com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
at
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
at
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
at
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
at
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
at
javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
at
javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
at
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662) Caused by:
org.jboss.weld.exceptions.WeldException: WELD-000049 Unable to invoke
[method] #PostConstruct private menu.ejb.RequestBean.init() on
menu.ejb.RequestBean#19ca9ff at
org.jboss.weld.bean.AbstractClassBean.defaultPostConstruct(AbstractClassBean.java:400)
at
org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.postConstruct(ManagedBean.java:174)
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:294) at
org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:68)
at
org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:599)
at
org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:665)
at
org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:136)
at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:686) at
org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:695)
at
org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1$1.proceed(ManagedBean.java:161)
at
org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48)
at
org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1.work(ManagedBean.java:157)
at
org.jboss.weld.bean.ManagedBean$FixInjectionPoint.run(ManagedBean.java:131)
at
org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.inject(ManagedBean.java:153)
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:293) at
org.jboss.weld.context.AbstractContext.get(AbstractContext.java:103)
at
org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:90)
at
org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:79)
at
menu.web.MenuManager$Proxy$_$$WeldClientProxy.getMenuItemsS(MenuManager$Proxy$$$_WeldClientProxy.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597) at
javax.el.BeanELResolver.getValue(BeanELResolver.java:87) at
com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:176)
at
com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at org.apache.el.parser.AstValue.getValue(AstValue.java:169) at
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
at
org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
at
com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
... 34 more Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597) at
org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:267)
at
org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
at
org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
at
org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:263)
at
org.jboss.weld.introspector.jlr.WeldMethodImpl.invoke(WeldMethodImpl.java:174)
at
org.jboss.weld.bean.AbstractClassBean.defaultPostConstruct(AbstractClassBean.java:398)
... 63 more Caused by: java.lang.RuntimeException: public static
volatile javax.persistence.metamodel.ListAttribute
menu.entity.Feature.functions at
org.apache.openjpa.persistence.meta.MetamodelImpl.populate(MetamodelImpl.java:330)
at
org.apache.openjpa.persistence.meta.MetamodelImpl.instantiate(MetamodelImpl.java:257)
at
org.apache.openjpa.persistence.meta.MetamodelImpl.find(MetamodelImpl.java:226)
at
org.apache.openjpa.persistence.meta.MetamodelImpl.(MetamodelImpl.java:91)
at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.getMetamodel(EntityManagerFactoryImpl.java:346)
at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.getCriteriaBuilder(EntityManagerFactoryImpl.java:333)
at
org.apache.openjpa.persistence.EntityManagerImpl.getCriteriaBuilder(EntityManagerImpl.java:1649)
at
org.apache.openjpa.persistence.EntityManagerImpl.getCriteriaBuilder(EntityManagerImpl.java:101)
at menu.ejb.RequestBean.init(RequestBean.java:60) ... 73 more Oct 2,
2012 12:50:22 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [Faces Servlet] in context with
path [/jsfCDITest] threw exception [WELD-000049 Unable to invoke
[method] #PostConstruct private menu.ejb.RequestBean.init() on
menu.ejb.RequestBean#19ca9ff] with root cause
java.lang.RuntimeException: public static volatile
javax.persistence.metamodel.ListAttribute
menu.entity.Feature_.functions at
org.apache.openjpa.persistence.meta.MetamodelImpl.populate(MetamodelImpl.java:330)
at
org.apache.openjpa.persistence.meta.MetamodelImpl.instantiate(MetamodelImpl.java:257)
at
org.apache.openjpa.persistence.meta.MetamodelImpl.find(MetamodelImpl.java:226)
at
org.apache.openjpa.persistence.meta.MetamodelImpl.(MetamodelImpl.java:91)
at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.getMetamodel(EntityManagerFactoryImpl.java:346)
at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.getCriteriaBuilder(EntityManagerFactoryImpl.java:333)
at
org.apache.openjpa.persistence.EntityManagerImpl.getCriteriaBuilder(EntityManagerImpl.java:1649)
at
org.apache.openjpa.persistence.EntityManagerImpl.getCriteriaBuilder(EntityManagerImpl.java:101)
at menu.ejb.RequestBean.init(RequestBean.java:60) at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597) at
org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:267)
at
org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
at
org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
at
org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:263)
at
org.jboss.weld.introspector.jlr.WeldMethodImpl.invoke(WeldMethodImpl.java:174)
at
org.jboss.weld.bean.AbstractClassBean.defaultPostConstruct(AbstractClassBean.java:398)
at
org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.postConstruct(ManagedBean.java:174)
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:294) at
org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:68)
at
org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:599)
at
org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:665)
at
org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:136)
at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:686) at
org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:695)
at
org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1$1.proceed(ManagedBean.java:161)
at
org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48)
at
org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1.work(ManagedBean.java:157)
at
org.jboss.weld.bean.ManagedBean$FixInjectionPoint.run(ManagedBean.java:131)
at
org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.inject(ManagedBean.java:153)
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:293) at
org.jboss.weld.context.AbstractContext.get(AbstractContext.java:103)
at
org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:90)
at
org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:79)
at
menu.web.MenuManager$Proxy$_$$WeldClientProxy.getMenuItemsS(MenuManager$Proxy$$$_WeldClientProxy.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597) at
javax.el.BeanELResolver.getValue(BeanELResolver.java:87) at
com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at
com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at org.apache.el.parser.AstValue.getValue(AstValue.java:169) at
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
at
org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
at
com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIOutput.getValue(UIOutput.java:169) at
com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
at
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
at
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
at
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
at
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
at
javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
at
javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
at
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
I believe that RuntimeException is thrown because another exception occurred. That other exception's stack trace should be printed to the console.