After upgrade from Spring Boot 1.5 to 2.1 we get Target bean of type com.sun.proxy.$Proxy is not of type of the persistent entityspring converter not registeringSpring: API producing octet stream but error in JSONcurrent request is not a multipart request(angular 4+spring boot)Trying post data from js to spring boot controllerunable to find valid certification path to requested target in sprint boot applicationGetting bad request when using rest templatejavax.ws.rs.core.MultivaluedMap issueSpring Boot Error getOutputStream() has already been called for this response after forwardorg.springframework.web.util.NestedServletException: Request processing failed (HttpSession issue)Display of list of items in thymeleaf always gives error

What would influence an alien race to map their planet in a way other than the traditional map of the Earth

Is determiner 'a' needed here?

What are examples of EU policies that are beneficial for one EU country, disadvantagious for another?

Why isn't there armor to protect from spells in the Potterverse?

Can a passenger predict that an airline is about to go bankrupt?

How to stop the death waves in my city?

Why does my browser attempt to download pages from http://clhs.lisp.se instead of viewing them normally?

Is there a list of world wide upcoming space events on the web?

Garage door sticks on a bolt

What is Weapon Handling?

What's the hidden joke/meaning behind "Don't drink and park - accidents cause people"?

Why is a road bike faster than a city bike with the same effort? How much faster it can be?

Why Italian monolingual dictionaries usually take complex/archaic examples from books instead of creating simple examples?

Delete n lines skip 1 line script

what organs or modifications would be needed to have hairy fish?

[Cannot read property 'setParams' of null]

Dynamic DataSource for Droplist in Content Editor

I transpose the source code, you transpose the input!

A word that refers to saying something in an attempt to anger or embarrass someone into doing something that they don’t want to do?

How can I become an invalid target for spells that target humanoids?

Why, even after his imprisonment, people keep calling Hannibal Lecter "Doctor"?

Which altitudes are safest for VFR?

As a team leader is it appropriate to bring in fundraiser candy?

Lambda functions with template parameters, not in function parameters



After upgrade from Spring Boot 1.5 to 2.1 we get Target bean of type com.sun.proxy.$Proxy is not of type of the persistent entity


spring converter not registeringSpring: API producing octet stream but error in JSONcurrent request is not a multipart request(angular 4+spring boot)Trying post data from js to spring boot controllerunable to find valid certification path to requested target in sprint boot applicationGetting bad request when using rest templatejavax.ws.rs.core.MultivaluedMap issueSpring Boot Error getOutputStream() has already been called for this response after forwardorg.springframework.web.util.NestedServletException: Request processing failed (HttpSession issue)Display of list of items in thymeleaf always gives error






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















We upgraded from Spring Boot 1.5.13.RELEASE to 2.1.3.RELEASE and now a POST to Spring Data Rest with a projection is failing with this error:



java.lang.IllegalArgumentException: Target bean of type
com.sun.proxy.$Proxy313 is not of type of the persistent entity
(com.*.*.*.BankAccount)!: com.sun.proxy.$Proxy313


This looks very similar to the old ticket: https://jira.spring.io/si/jira.issueviews:issue-html/DATAREST-1213/DATAREST-1213.html



The JUnit test passes:



 @Test
public void shouldCreateEntity() throws Exception
ResultActions resultsActions = mockMvc.perform(post("/bankAccounts".concat("?projection=").concat(BankAccountDto.NAME))
.content(new ObjectMapper().writeValueAsString(generateBankAccount())))
.andExpect(status().isCreated())
.andExpect(header().string("Location", containsString("bankAccounts/")))
.andDo(verify().wiremock(
WireMock.post(WireMock.urlPathMatching("/bankAccounts"))
).stub("create-bankAccount"))
.andDo(document("create-bankAccount"));



But, the POST to Spring Data Rest fails on the server.



 2019-03-28T11:13:13.401-05:00 [RTR/3] [OUT] account-service-qa-example.cfapps.io - [ 2019-03-28T16:13:13.168+0000] 
"POST /bankAccounts?projection=bankAccountDto HTTP/1.1" 500 205 185 "-" "Java/1.8.0_202" "00.00.0.00:57334" "00.00.000.00:61130"
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at java.lang.Thread.run(Thread.java:748)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:679)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.cloudfoundry.router.ClientCertificateMapper.doFilter(ClientCertificateMapper.java:77)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:106)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:117)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at brave.servlet.TracingFilter.doFilter(TracingFilter.java:86)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.cloud.sleuth.instrument.web.ExceptionLoggingFilter.doFilter(ExceptionLoggingFilter.java:50)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:74)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter.doFilter(OAuth2AuthenticationProcessingFilter.java:176)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:90)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at net.rakugakibox.spring.boot.logback.access.LogbackAccessSecurityAttributesSaveFilter.doFilter(LogbackAccessSecurityAttributesSaveFilter.java:28)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.AbstractRequestLoggingFilter.doFilterInternal(AbstractRequestLoggingFilter.java:262)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:800)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:189)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at java.lang.reflect.Method.invoke(Method.java:498)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.RepositoryEntityController.postCollectionResource(RepositoryEntityController.java:272)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.RepositoryEntityController.createAndReturn(RepositoryEntityController.java:486)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.HttpHeadersPreparer.prepareHeaders(HttpHeadersPreparer.java:62)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at java.util.Optional.map(Optional.java:215)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.HttpHeadersPreparer.lambda$prepareHeaders$0(HttpHeadersPreparer.java:62)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.HttpHeadersPreparer.prepareHeaders(HttpHeadersPreparer.java:80)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.support.ETag.from(ETag.java:88)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.support.ETag.getVersionInformation(ETag.java:170)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.mapping.model.BasicPersistentEntity.getPropertyAccessor(BasicPersistentEntity.java:453)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.mapping.model.BasicPersistentEntity.verifyBeanType(BasicPersistentEntity.java:551)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.util.Assert.isInstanceOf(Assert.java:574)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.util.Assert.instanceCheckFailed(Assert.java:655)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] java.lang.IllegalArgumentException:
Target bean of type com.sun.proxy.$Proxy313 is not of type of the persistent entity (com.*****.account.domain.BankAccount)!: com.sun.proxy.$Proxy313
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] 2019-03-28 16:16:39.056 ERROR [account-service,1c845c447ea36328,7e8da14a044d1ab6,true]
[080-exec-6] o.s.d.r.w.RepositoryRestExceptionHandler:168 :
Target bean of type com.sun.proxy.$Proxy313 is not of type of the persistent entity (com.*****.account.domain.BankAccount)!: com.sun.proxy.$Proxy313
2019-03-28T11:16:39.065-05:00 [RTR/6] [OUT] account-service-qa-example.cfapps.io - [ 2019-03-28T16:16:38.856+0000]
"POST /bankAccounts?projection=bankAccountDto HTTP/1.1" 500 205 185 "-" "Java/1.8.0_202" "10.10.66.83:32538" "00.00.000.00:61130"


The call to Spring Data Rest is straightforward and has not changed.



 public Optional<String> createBankAccount(CreateBankAccountDto createBankAccountDto) 
UriComponentsBuilder builder = UriComponentsBuilder
.fromHttpUrl(BANK_ACCOUNTS)
.queryParam(PROJECTION, BankAccountDto.PROJECTION);
try
HttpEntity<CreateBankAccountDto> entity = new HttpEntity<>(createBankAccountDto);
ResponseEntity<BankAccountDto> response = restTemplate
.exchange(builder.build().encode().toUri(), HttpMethod.POST, entity,
BankAccountDto.class);
if (response.getStatusCode().is2xxSuccessful() && response.getBody() != null
&& response.getBody().getId() != null)
return Optional.of(response.getBody().getId());

catch (Exception e)
log.error(e.getMessage());
log.debug(e.getMessage(), e);

return Optional.empty();



Has anybody else experienced this problem after upgrading to Spring Boot 2.










share|improve this question
























  • We eliminated that stack trace by removing the projection query parameter. Now, nothing is being persisted. I've been down this road before with Spring Data Rest. I'm going to bypass Spring Data Rest and throw a @PostMapping on a controller for the create operation.

    – Steve Mitchell
    Mar 28 at 20:52











  • FIXED I stand corrected. Removing the projection from the POST definitely fixed the Spring Data Rest problem New records are being created and returning a 201.

    – Steve Mitchell
    Mar 28 at 22:09

















0















We upgraded from Spring Boot 1.5.13.RELEASE to 2.1.3.RELEASE and now a POST to Spring Data Rest with a projection is failing with this error:



java.lang.IllegalArgumentException: Target bean of type
com.sun.proxy.$Proxy313 is not of type of the persistent entity
(com.*.*.*.BankAccount)!: com.sun.proxy.$Proxy313


This looks very similar to the old ticket: https://jira.spring.io/si/jira.issueviews:issue-html/DATAREST-1213/DATAREST-1213.html



The JUnit test passes:



 @Test
public void shouldCreateEntity() throws Exception
ResultActions resultsActions = mockMvc.perform(post("/bankAccounts".concat("?projection=").concat(BankAccountDto.NAME))
.content(new ObjectMapper().writeValueAsString(generateBankAccount())))
.andExpect(status().isCreated())
.andExpect(header().string("Location", containsString("bankAccounts/")))
.andDo(verify().wiremock(
WireMock.post(WireMock.urlPathMatching("/bankAccounts"))
).stub("create-bankAccount"))
.andDo(document("create-bankAccount"));



But, the POST to Spring Data Rest fails on the server.



 2019-03-28T11:13:13.401-05:00 [RTR/3] [OUT] account-service-qa-example.cfapps.io - [ 2019-03-28T16:13:13.168+0000] 
"POST /bankAccounts?projection=bankAccountDto HTTP/1.1" 500 205 185 "-" "Java/1.8.0_202" "00.00.0.00:57334" "00.00.000.00:61130"
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at java.lang.Thread.run(Thread.java:748)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:679)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.cloudfoundry.router.ClientCertificateMapper.doFilter(ClientCertificateMapper.java:77)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:106)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:117)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at brave.servlet.TracingFilter.doFilter(TracingFilter.java:86)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.cloud.sleuth.instrument.web.ExceptionLoggingFilter.doFilter(ExceptionLoggingFilter.java:50)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:74)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter.doFilter(OAuth2AuthenticationProcessingFilter.java:176)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:90)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at net.rakugakibox.spring.boot.logback.access.LogbackAccessSecurityAttributesSaveFilter.doFilter(LogbackAccessSecurityAttributesSaveFilter.java:28)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.AbstractRequestLoggingFilter.doFilterInternal(AbstractRequestLoggingFilter.java:262)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:800)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:189)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at java.lang.reflect.Method.invoke(Method.java:498)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.RepositoryEntityController.postCollectionResource(RepositoryEntityController.java:272)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.RepositoryEntityController.createAndReturn(RepositoryEntityController.java:486)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.HttpHeadersPreparer.prepareHeaders(HttpHeadersPreparer.java:62)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at java.util.Optional.map(Optional.java:215)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.HttpHeadersPreparer.lambda$prepareHeaders$0(HttpHeadersPreparer.java:62)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.HttpHeadersPreparer.prepareHeaders(HttpHeadersPreparer.java:80)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.support.ETag.from(ETag.java:88)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.support.ETag.getVersionInformation(ETag.java:170)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.mapping.model.BasicPersistentEntity.getPropertyAccessor(BasicPersistentEntity.java:453)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.mapping.model.BasicPersistentEntity.verifyBeanType(BasicPersistentEntity.java:551)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.util.Assert.isInstanceOf(Assert.java:574)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.util.Assert.instanceCheckFailed(Assert.java:655)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] java.lang.IllegalArgumentException:
Target bean of type com.sun.proxy.$Proxy313 is not of type of the persistent entity (com.*****.account.domain.BankAccount)!: com.sun.proxy.$Proxy313
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] 2019-03-28 16:16:39.056 ERROR [account-service,1c845c447ea36328,7e8da14a044d1ab6,true]
[080-exec-6] o.s.d.r.w.RepositoryRestExceptionHandler:168 :
Target bean of type com.sun.proxy.$Proxy313 is not of type of the persistent entity (com.*****.account.domain.BankAccount)!: com.sun.proxy.$Proxy313
2019-03-28T11:16:39.065-05:00 [RTR/6] [OUT] account-service-qa-example.cfapps.io - [ 2019-03-28T16:16:38.856+0000]
"POST /bankAccounts?projection=bankAccountDto HTTP/1.1" 500 205 185 "-" "Java/1.8.0_202" "10.10.66.83:32538" "00.00.000.00:61130"


The call to Spring Data Rest is straightforward and has not changed.



 public Optional<String> createBankAccount(CreateBankAccountDto createBankAccountDto) 
UriComponentsBuilder builder = UriComponentsBuilder
.fromHttpUrl(BANK_ACCOUNTS)
.queryParam(PROJECTION, BankAccountDto.PROJECTION);
try
HttpEntity<CreateBankAccountDto> entity = new HttpEntity<>(createBankAccountDto);
ResponseEntity<BankAccountDto> response = restTemplate
.exchange(builder.build().encode().toUri(), HttpMethod.POST, entity,
BankAccountDto.class);
if (response.getStatusCode().is2xxSuccessful() && response.getBody() != null
&& response.getBody().getId() != null)
return Optional.of(response.getBody().getId());

catch (Exception e)
log.error(e.getMessage());
log.debug(e.getMessage(), e);

return Optional.empty();



Has anybody else experienced this problem after upgrading to Spring Boot 2.










share|improve this question
























  • We eliminated that stack trace by removing the projection query parameter. Now, nothing is being persisted. I've been down this road before with Spring Data Rest. I'm going to bypass Spring Data Rest and throw a @PostMapping on a controller for the create operation.

    – Steve Mitchell
    Mar 28 at 20:52











  • FIXED I stand corrected. Removing the projection from the POST definitely fixed the Spring Data Rest problem New records are being created and returning a 201.

    – Steve Mitchell
    Mar 28 at 22:09













0












0








0








We upgraded from Spring Boot 1.5.13.RELEASE to 2.1.3.RELEASE and now a POST to Spring Data Rest with a projection is failing with this error:



java.lang.IllegalArgumentException: Target bean of type
com.sun.proxy.$Proxy313 is not of type of the persistent entity
(com.*.*.*.BankAccount)!: com.sun.proxy.$Proxy313


This looks very similar to the old ticket: https://jira.spring.io/si/jira.issueviews:issue-html/DATAREST-1213/DATAREST-1213.html



The JUnit test passes:



 @Test
public void shouldCreateEntity() throws Exception
ResultActions resultsActions = mockMvc.perform(post("/bankAccounts".concat("?projection=").concat(BankAccountDto.NAME))
.content(new ObjectMapper().writeValueAsString(generateBankAccount())))
.andExpect(status().isCreated())
.andExpect(header().string("Location", containsString("bankAccounts/")))
.andDo(verify().wiremock(
WireMock.post(WireMock.urlPathMatching("/bankAccounts"))
).stub("create-bankAccount"))
.andDo(document("create-bankAccount"));



But, the POST to Spring Data Rest fails on the server.



 2019-03-28T11:13:13.401-05:00 [RTR/3] [OUT] account-service-qa-example.cfapps.io - [ 2019-03-28T16:13:13.168+0000] 
"POST /bankAccounts?projection=bankAccountDto HTTP/1.1" 500 205 185 "-" "Java/1.8.0_202" "00.00.0.00:57334" "00.00.000.00:61130"
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at java.lang.Thread.run(Thread.java:748)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:679)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.cloudfoundry.router.ClientCertificateMapper.doFilter(ClientCertificateMapper.java:77)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:106)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:117)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at brave.servlet.TracingFilter.doFilter(TracingFilter.java:86)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.cloud.sleuth.instrument.web.ExceptionLoggingFilter.doFilter(ExceptionLoggingFilter.java:50)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:74)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter.doFilter(OAuth2AuthenticationProcessingFilter.java:176)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:90)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at net.rakugakibox.spring.boot.logback.access.LogbackAccessSecurityAttributesSaveFilter.doFilter(LogbackAccessSecurityAttributesSaveFilter.java:28)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.AbstractRequestLoggingFilter.doFilterInternal(AbstractRequestLoggingFilter.java:262)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:800)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:189)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at java.lang.reflect.Method.invoke(Method.java:498)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.RepositoryEntityController.postCollectionResource(RepositoryEntityController.java:272)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.RepositoryEntityController.createAndReturn(RepositoryEntityController.java:486)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.HttpHeadersPreparer.prepareHeaders(HttpHeadersPreparer.java:62)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at java.util.Optional.map(Optional.java:215)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.HttpHeadersPreparer.lambda$prepareHeaders$0(HttpHeadersPreparer.java:62)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.HttpHeadersPreparer.prepareHeaders(HttpHeadersPreparer.java:80)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.support.ETag.from(ETag.java:88)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.support.ETag.getVersionInformation(ETag.java:170)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.mapping.model.BasicPersistentEntity.getPropertyAccessor(BasicPersistentEntity.java:453)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.mapping.model.BasicPersistentEntity.verifyBeanType(BasicPersistentEntity.java:551)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.util.Assert.isInstanceOf(Assert.java:574)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.util.Assert.instanceCheckFailed(Assert.java:655)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] java.lang.IllegalArgumentException:
Target bean of type com.sun.proxy.$Proxy313 is not of type of the persistent entity (com.*****.account.domain.BankAccount)!: com.sun.proxy.$Proxy313
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] 2019-03-28 16:16:39.056 ERROR [account-service,1c845c447ea36328,7e8da14a044d1ab6,true]
[080-exec-6] o.s.d.r.w.RepositoryRestExceptionHandler:168 :
Target bean of type com.sun.proxy.$Proxy313 is not of type of the persistent entity (com.*****.account.domain.BankAccount)!: com.sun.proxy.$Proxy313
2019-03-28T11:16:39.065-05:00 [RTR/6] [OUT] account-service-qa-example.cfapps.io - [ 2019-03-28T16:16:38.856+0000]
"POST /bankAccounts?projection=bankAccountDto HTTP/1.1" 500 205 185 "-" "Java/1.8.0_202" "10.10.66.83:32538" "00.00.000.00:61130"


The call to Spring Data Rest is straightforward and has not changed.



 public Optional<String> createBankAccount(CreateBankAccountDto createBankAccountDto) 
UriComponentsBuilder builder = UriComponentsBuilder
.fromHttpUrl(BANK_ACCOUNTS)
.queryParam(PROJECTION, BankAccountDto.PROJECTION);
try
HttpEntity<CreateBankAccountDto> entity = new HttpEntity<>(createBankAccountDto);
ResponseEntity<BankAccountDto> response = restTemplate
.exchange(builder.build().encode().toUri(), HttpMethod.POST, entity,
BankAccountDto.class);
if (response.getStatusCode().is2xxSuccessful() && response.getBody() != null
&& response.getBody().getId() != null)
return Optional.of(response.getBody().getId());

catch (Exception e)
log.error(e.getMessage());
log.debug(e.getMessage(), e);

return Optional.empty();



Has anybody else experienced this problem after upgrading to Spring Boot 2.










share|improve this question














We upgraded from Spring Boot 1.5.13.RELEASE to 2.1.3.RELEASE and now a POST to Spring Data Rest with a projection is failing with this error:



java.lang.IllegalArgumentException: Target bean of type
com.sun.proxy.$Proxy313 is not of type of the persistent entity
(com.*.*.*.BankAccount)!: com.sun.proxy.$Proxy313


This looks very similar to the old ticket: https://jira.spring.io/si/jira.issueviews:issue-html/DATAREST-1213/DATAREST-1213.html



The JUnit test passes:



 @Test
public void shouldCreateEntity() throws Exception
ResultActions resultsActions = mockMvc.perform(post("/bankAccounts".concat("?projection=").concat(BankAccountDto.NAME))
.content(new ObjectMapper().writeValueAsString(generateBankAccount())))
.andExpect(status().isCreated())
.andExpect(header().string("Location", containsString("bankAccounts/")))
.andDo(verify().wiremock(
WireMock.post(WireMock.urlPathMatching("/bankAccounts"))
).stub("create-bankAccount"))
.andDo(document("create-bankAccount"));



But, the POST to Spring Data Rest fails on the server.



 2019-03-28T11:13:13.401-05:00 [RTR/3] [OUT] account-service-qa-example.cfapps.io - [ 2019-03-28T16:13:13.168+0000] 
"POST /bankAccounts?projection=bankAccountDto HTTP/1.1" 500 205 185 "-" "Java/1.8.0_202" "00.00.0.00:57334" "00.00.000.00:61130"
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at java.lang.Thread.run(Thread.java:748)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:679)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.cloudfoundry.router.ClientCertificateMapper.doFilter(ClientCertificateMapper.java:77)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:106)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:117)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at brave.servlet.TracingFilter.doFilter(TracingFilter.java:86)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.cloud.sleuth.instrument.web.ExceptionLoggingFilter.doFilter(ExceptionLoggingFilter.java:50)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:74)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter.doFilter(OAuth2AuthenticationProcessingFilter.java:176)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:90)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at net.rakugakibox.spring.boot.logback.access.LogbackAccessSecurityAttributesSaveFilter.doFilter(LogbackAccessSecurityAttributesSaveFilter.java:28)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.filter.AbstractRequestLoggingFilter.doFilterInternal(AbstractRequestLoggingFilter.java:262)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:800)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:189)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at java.lang.reflect.Method.invoke(Method.java:498)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.RepositoryEntityController.postCollectionResource(RepositoryEntityController.java:272)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.RepositoryEntityController.createAndReturn(RepositoryEntityController.java:486)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.HttpHeadersPreparer.prepareHeaders(HttpHeadersPreparer.java:62)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at java.util.Optional.map(Optional.java:215)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.HttpHeadersPreparer.lambda$prepareHeaders$0(HttpHeadersPreparer.java:62)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.HttpHeadersPreparer.prepareHeaders(HttpHeadersPreparer.java:80)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.support.ETag.from(ETag.java:88)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.rest.webmvc.support.ETag.getVersionInformation(ETag.java:170)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.mapping.model.BasicPersistentEntity.getPropertyAccessor(BasicPersistentEntity.java:453)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.data.mapping.model.BasicPersistentEntity.verifyBeanType(BasicPersistentEntity.java:551)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.util.Assert.isInstanceOf(Assert.java:574)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.util.Assert.instanceCheckFailed(Assert.java:655)
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] java.lang.IllegalArgumentException:
Target bean of type com.sun.proxy.$Proxy313 is not of type of the persistent entity (com.*****.account.domain.BankAccount)!: com.sun.proxy.$Proxy313
2019-03-28T11:16:39.058-05:00 [APP/PROC/WEB/0] [OUT] 2019-03-28 16:16:39.056 ERROR [account-service,1c845c447ea36328,7e8da14a044d1ab6,true]
[080-exec-6] o.s.d.r.w.RepositoryRestExceptionHandler:168 :
Target bean of type com.sun.proxy.$Proxy313 is not of type of the persistent entity (com.*****.account.domain.BankAccount)!: com.sun.proxy.$Proxy313
2019-03-28T11:16:39.065-05:00 [RTR/6] [OUT] account-service-qa-example.cfapps.io - [ 2019-03-28T16:16:38.856+0000]
"POST /bankAccounts?projection=bankAccountDto HTTP/1.1" 500 205 185 "-" "Java/1.8.0_202" "10.10.66.83:32538" "00.00.000.00:61130"


The call to Spring Data Rest is straightforward and has not changed.



 public Optional<String> createBankAccount(CreateBankAccountDto createBankAccountDto) 
UriComponentsBuilder builder = UriComponentsBuilder
.fromHttpUrl(BANK_ACCOUNTS)
.queryParam(PROJECTION, BankAccountDto.PROJECTION);
try
HttpEntity<CreateBankAccountDto> entity = new HttpEntity<>(createBankAccountDto);
ResponseEntity<BankAccountDto> response = restTemplate
.exchange(builder.build().encode().toUri(), HttpMethod.POST, entity,
BankAccountDto.class);
if (response.getStatusCode().is2xxSuccessful() && response.getBody() != null
&& response.getBody().getId() != null)
return Optional.of(response.getBody().getId());

catch (Exception e)
log.error(e.getMessage());
log.debug(e.getMessage(), e);

return Optional.empty();



Has anybody else experienced this problem after upgrading to Spring Boot 2.







spring-boot spring-data-jpa spring-data-rest






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 28 at 18:54









Steve MitchellSteve Mitchell

431 silver badge6 bronze badges




431 silver badge6 bronze badges















  • We eliminated that stack trace by removing the projection query parameter. Now, nothing is being persisted. I've been down this road before with Spring Data Rest. I'm going to bypass Spring Data Rest and throw a @PostMapping on a controller for the create operation.

    – Steve Mitchell
    Mar 28 at 20:52











  • FIXED I stand corrected. Removing the projection from the POST definitely fixed the Spring Data Rest problem New records are being created and returning a 201.

    – Steve Mitchell
    Mar 28 at 22:09

















  • We eliminated that stack trace by removing the projection query parameter. Now, nothing is being persisted. I've been down this road before with Spring Data Rest. I'm going to bypass Spring Data Rest and throw a @PostMapping on a controller for the create operation.

    – Steve Mitchell
    Mar 28 at 20:52











  • FIXED I stand corrected. Removing the projection from the POST definitely fixed the Spring Data Rest problem New records are being created and returning a 201.

    – Steve Mitchell
    Mar 28 at 22:09
















We eliminated that stack trace by removing the projection query parameter. Now, nothing is being persisted. I've been down this road before with Spring Data Rest. I'm going to bypass Spring Data Rest and throw a @PostMapping on a controller for the create operation.

– Steve Mitchell
Mar 28 at 20:52





We eliminated that stack trace by removing the projection query parameter. Now, nothing is being persisted. I've been down this road before with Spring Data Rest. I'm going to bypass Spring Data Rest and throw a @PostMapping on a controller for the create operation.

– Steve Mitchell
Mar 28 at 20:52













FIXED I stand corrected. Removing the projection from the POST definitely fixed the Spring Data Rest problem New records are being created and returning a 201.

– Steve Mitchell
Mar 28 at 22:09





FIXED I stand corrected. Removing the projection from the POST definitely fixed the Spring Data Rest problem New records are being created and returning a 201.

– Steve Mitchell
Mar 28 at 22:09












0






active

oldest

votes














Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);














draft saved

draft discarded
















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55404966%2fafter-upgrade-from-spring-boot-1-5-to-2-1-we-get-target-bean-of-type-com-sun-pro%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55404966%2fafter-upgrade-from-spring-boot-1-5-to-2-1-we-get-target-bean-of-type-com-sun-pro%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현