web-dev-qa-db-fra.com

Comment résoudre des définitions de getter conflictuelles pour une propriété à jackson

J'ai des cours de modèle. 

public interface Product extends Serializable {
    public Sku getDefaultSku();

   public void setDefaultSku(Sku defaultSku);
}

public interface Sku extends Serializable {
     public Boolean isTaxable();

    public Boolean getTaxable();

    public void setTaxable(Boolean taxable);
}

public interface PremiumProduct extends Product {
   public Long getProductCode();

   public void setProductCode(Long productCode);
}

Les implémentations de produit et de sku ne peuvent pas être modifiées. J'étends seulement du produit. Après cela, je transfère un objet JSON depuis un contrôleur MVC à ressort. Ma méthode de contrôleur est 

@RequestMapping(value="/productDetail", method=RequestMethod.GET)
    public @ResponseBody Product getCustomerName(@RequestParam String productUrl) throws Exception {

      Product product = catalogService.findProductByURI(productUrl);      

                return product;
    }

J'ai des exceptions suivantes.

<h2>HTTP ERROR 500</h2>
<p>Problem accessing /productDetail. Reason:
<pre>    Conflicting getter definitions for property "taxable":

org.broadleafcommerce.core.catalog.domain.SkuImpl#getTaxable(0 params) vs org.broadleafcommerce.core.catalog.domain.SkuImpl#isTaxable(0 params)
(through reference chain: com.yoma.product.PremiumProductImpl["defaultSku"])</pre></p>

<h3>Caused by:</h3>
<pre>org.codehaus.jackson.map.JsonMappingException: Conflicting getter definitions for property "taxable":
org.broadleafcommerce.core.catalog.domain.SkuImpl#getTaxable(0 params) vs
org.broadleafcommerce.core.catalog.domain.SkuImpl#isTaxable(0 params)
(through reference chain: com.yoma.product.PremiumProductImpl["defaultSku"])
   at org.codehaus.jackson.map.ser.StdSerializerProvider._createAndCacheUntypedSerializer(StdSerializerProvider.Java:740)
   at org.codehaus.jackson.map.ser.StdSerializerProvider.findValueSerializer(StdSerializerProvider.Java:344)
   at org.codehaus.jackson.map.ser.impl.PropertySerializerMap.findAndAddSerializer(PropertySerializerMap.Java:39)
   at org.codehaus.jackson.map.ser.BeanPropertyWriter._findAndAddDynamic(BeanPropertyWriter.Java:463)

   at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:441)
   at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:150)
   at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.Java:112)
   at org.codehaus.jackson.map.ser.StdSerializerProvider._serializeValue(StdSerializerProvider.Java:610)
   at org.codehaus.jackson.map.ser.StdSerializerProvider.serializeValue(StdSerializerProvider.Java:256)
   at org.codehaus.jackson.map.ObjectMapper._configAndWriteValue(ObjectMapper.Java:2566)
   at org.codehaus.jackson.map.ObjectMapper.writeValueAsString(ObjectMapper.Java:2088)
   at com.yoma.controller.catalog.ProductController.getCustomerName(ProductController.Java:69)
   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.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.Java:213)
   at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.Java:126)
   at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.Java:96)
   at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.Java:617)
   at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.Java:578)
   at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.Java:80)
   at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.Java:923)
   at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.Java:852)
   at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.Java:882)
   at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.Java:778)
   at javax.servlet.http.HttpServlet.service(HttpServlet.Java:735)
   at javax.servlet.http.HttpServlet.service(HttpServlet.Java:848)
   at org.Eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.Java:643)
   at org.Eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.Java:1331)
   at org.broadleafcommerce.cms.web.URLHandlerFilter.doFilterInternal(URLHandlerFilter.Java:74)
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.Java:76)
   at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.Java:346)
   at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.Java:259)
   at org.Eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.Java:1302)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:311)
   at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.Java:116)
   at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.Java:83)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.Java:113)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.broadleafcommerce.profile.web.core.security.SessionFixationProtectionFilter.doFilter(SessionFixationProtectionFilter.Java:90)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.Java:113)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.broadleafcommerce.core.web.order.security.CartStateFilter.doFilter(CartStateFilter.Java:86)

   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.broadleafcommerce.profile.web.core.security.CustomerStateFilter.doFilter(CustomerStateFilter.Java:147)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.Java:54)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.Java:45)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.Java:182)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.broadleafcommerce.common.security.handler.CsrfFilter.doFilter(CsrfFilter.Java:83)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.Java:105)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.Java:87)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.springframework.security.web.access.channel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.Java:144)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.Java:173)
   at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.Java:346)
   at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.Java:259)
   at org.Eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.Java:1302)
   at org.broadleafcommerce.common.web.BroadleafRequestFilter.doFilterInternal(BroadleafRequestFilter.Java:146)
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.Java:76)
   at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.Java:346)
   at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.Java:259)
   at org.Eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.Java:1302)
   at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.Java:147)
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.Java:76)
   at org.Eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.Java:1302)
   at org.Eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.Java:448)
   at org.Eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.Java:131)
   at org.Eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.Java:524)
   at org.Eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.Java:231)
   at org.Eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.Java:1067)
   at org.Eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.Java:377)
   at org.Eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.Java:192)
   at org.Eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.Java:1001)
   at org.Eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.Java:129)
   at org.Eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.Java:250)
   at org.Eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.Java:149)
   at org.Eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.Java:111)
   at org.Eclipse.jetty.server.Server.handle(Server.Java:360)
   at org.Eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.Java:454)
   at org.Eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.Java:890)

   at org.Eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.Java:944)
   at org.Eclipse.jetty.http.HttpParser.parseNext(HttpParser.Java:630)
   at org.Eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.Java:230)
   at org.Eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.Java:77)
   at org.Eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.Java:622)
   at org.Eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.Java:46)
   at org.Eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.Java:603)
   at org.Eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.Java:538)
   at Java.lang.Thread.run(Thread.Java:619)
Caused by: Java.lang.IllegalArgumentException: Conflicting getter definitions for property "taxable":
org.broadleafcommerce.core.catalog.domain.SkuImpl#getTaxable(0 params) vs
org.broadleafcommerce.core.catalog.domain.SkuImpl#isTaxable(0 params)
   at org.codehaus.jackson.map.introspect.POJOPropertyBuilder.getGetter(POJOPropertyBuilder.Java:162)

   at org.codehaus.jackson.map.introspect.POJOPropertyBuilder.getAccessor(POJOPropertyBuilder.Java:111)
   at org.codehaus.jackson.map.ser.BeanSerializerFactory.removeIgnorableTypes(BeanSerializerFactory.Java:701)
   at org.codehaus.jackson.map.ser.BeanSerializerFactory.findBeanProperties(BeanSerializerFactory.Java:558)
   at org.codehaus.jackson.map.ser.BeanSerializerFactory.constructBeanSerializer(BeanSerializerFactory.Java:430)
   at org.codehaus.jackson.map.ser.BeanSerializerFactory.findBeanSerializer(BeanSerializerFactory.Java:343)
   at org.codehaus.jackson.map.ser.BeanSerializerFactory.createSerializer(BeanSerializerFactory.Java:287)
   at org.codehaus.jackson.map.ser.StdSerializerProvider._createUntypedSerializer(StdSerializerProvider.Java:782)
   at org.codehaus.jackson.map.ser.StdSerializerProvider._createAndCacheUntypedSerializer(StdSerializerProvider.Java:735)
   ... 98 more
</pre>
<h3>Caused by:</h3><pre>Java.lang.IllegalArgumentException: Conflicting getter definitions for property "taxable": org.broadleafcommerce.core.catalog.domain.SkuImpl#getTaxable(0 params) vs org.broadleafcommerce.core.catalog.domain.SkuImpl#isTaxable(0 params)
   at org.codehaus.jackson.map.introspect.POJOPropertyBuilder.getGetter(POJOPropertyBuilder.Java:162)

   at org.codehaus.jackson.map.introspect.POJOPropertyBuilder.getAccessor(POJOPropertyBuilder.Java:111)
   at org.codehaus.jackson.map.ser.BeanSerializerFactory.removeIgnorableTypes(BeanSerializerFactory.Java:701)
   at org.codehaus.jackson.map.ser.BeanSerializerFactory.findBeanProperties(BeanSerializerFactory.Java:558)
   at org.codehaus.jackson.map.ser.BeanSerializerFactory.constructBeanSerializer(BeanSerializerFactory.Java:430)
   at org.codehaus.jackson.map.ser.BeanSerializerFactory.findBeanSerializer(BeanSerializerFactory.Java:343)
   at org.codehaus.jackson.map.ser.BeanSerializerFactory.createSerializer(BeanSerializerFactory.Java:287)
   at org.codehaus.jackson.map.ser.StdSerializerProvider._createUntypedSerializer(StdSerializerProvider.Java:782)
   at org.codehaus.jackson.map.ser.StdSerializerProvider._createAndCacheUntypedSerializer(StdSerializerProvider.Java:735)
   at org.codehaus.jackson.map.ser.StdSerializerProvider.findValueSerializer(StdSerializerProvider.Java:344)
   at org.codehaus.jackson.map.ser.impl.PropertySerializerMap.findAndAddSerializer(PropertySerializerMap.Java:39)
   at org.codehaus.jackson.map.ser.BeanPropertyWriter._findAndAddDynamic(BeanPropertyWriter.Java:463)

   at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.Java:441)
   at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.Java:150)
   at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.Java:112)
   at org.codehaus.jackson.map.ser.StdSerializerProvider._serializeValue(StdSerializerProvider.Java:610)
   at org.codehaus.jackson.map.ser.StdSerializerProvider.serializeValue(StdSerializerProvider.Java:256)
   at org.codehaus.jackson.map.ObjectMapper._configAndWriteValue(ObjectMapper.Java:2566)
   at org.codehaus.jackson.map.ObjectMapper.writeValueAsString(ObjectMapper.Java:2088)
   at com.yoma.controller.catalog.ProductController.getCustomerName(ProductController.Java:69)
   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.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.Java:213)
   at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.Java:126)
   at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.Java:96)
   at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.Java:617)
   at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.Java:578)
   at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.Java:80)
   at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.Java:923)
   at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.Java:852)
   at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.Java:882)
   at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.Java:778)
   at javax.servlet.http.HttpServlet.service(HttpServlet.Java:735)
   at javax.servlet.http.HttpServlet.service(HttpServlet.Java:848)
   at org.Eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.Java:643)
   at org.Eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.Java:1331)
   at org.broadleafcommerce.cms.web.URLHandlerFilter.doFilterInternal(URLHandlerFilter.Java:74)
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.Java:76)
   at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.Java:346)
   at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.Java:259)
   at org.Eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.Java:1302)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:311)
   at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.Java:116)
   at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.Java:83)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.Java:113)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.broadleafcommerce.profile.web.core.security.SessionFixationProtectionFilter.doFilter(SessionFixationProtectionFilter.Java:90)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.Java:113)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.broadleafcommerce.core.web.order.security.CartStateFilter.doFilter(CartStateFilter.Java:86)

   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.broadleafcommerce.profile.web.core.security.CustomerStateFilter.doFilter(CustomerStateFilter.Java:147)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.Java:54)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.Java:45)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.Java:182)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.broadleafcommerce.common.security.handler.CsrfFilter.doFilter(CsrfFilter.Java:83)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.Java:105)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.Java:87)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.springframework.security.web.access.channel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.Java:144)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:323)
   at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.Java:173)
   at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.Java:346)
   at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.Java:259)
   at org.Eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.Java:1302)
   at org.broadleafcommerce.common.web.BroadleafRequestFilter.doFilterInternal(BroadleafRequestFilter.Java:146)
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.Java:76)
   at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.Java:346)
   at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.Java:259)
   at org.Eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.Java:1302)
   at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.Java:147)
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.Java:76)
   at org.Eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.Java:1302)
   at org.Eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.Java:448)
   at org.Eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.Java:131)
   at org.Eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.Java:524)
   at org.Eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.Java:231)
   at org.Eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.Java:1067)
   at org.Eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.Java:377)
   at org.Eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.Java:192)
   at org.Eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.Java:1001)
   at org.Eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.Java:129)
   at org.Eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.Java:250)
   at org.Eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.Java:149)
   at org.Eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.Java:111)
   at org.Eclipse.jetty.server.Server.handle(Server.Java:360)
   at org.Eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.Java:454)
   at org.Eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.Java:890)

   at org.Eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.Java:944)
   at org.Eclipse.jetty.http.HttpParser.parseNext(HttpParser.Java:630)
   at org.Eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.Java:230)
   at org.Eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.Java:77)
   at org.Eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.Java:622)
   at org.Eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.Java:46)
   at org.Eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.Java:603)
   at org.Eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.Java:538)
   at Java.lang.Thread.run(Thread.Java:619)
</pre>

Alors, comment puis-je obtenir mon JSON de mon contrôleur.

13
Kre Toni

Vous pouvez essayer d'ignorer isTaxable() par exemple pour résoudre le conflit:

@JsonIgnore
public Boolean isTaxable();
27

Mon problème est ok en suivant la solution selon la réponse du programmeur Bruce.

J'ai écrit MixIn class,

abstract class IgnoreSetValueMixIn {    
  @JsonIgnore public abstract Boolean getTaxable();
  @JsonIgnore public abstract Boolean isTaxable();
  @JsonManagedReference  public abstract Sku getDefaultSku();
  @JsonBackReference public abstract Product getDefaultProduct();
}

Dans le contrôleur,

@RequestMapping(value="/productDetail", method=RequestMethod.GET)
    public @ResponseBody String getCustomerName(@RequestParam String productUrl, HttpServletResponse response) throws Exception {
    ObjectMapper mapper = new ObjectMapper();

            mapper.getSerializationConfig().addMixInAnnotations(Sku.class, IgnoreSetValueMixIn.class);
            mapper.getSerializationConfig().addMixInAnnotations(SkuImpl.class, IgnoreSetValueMixIn.class);

return mapper.writeValueAsString(product);
}
8
Kre Toni

Les implémentations de produit et de sku ne peuvent pas être modifiées.

Jackson Mix-In Annotations à la rescousse!

6
Programmer Bruce

Vous pouvez aussi essayer Genson lib. Pour l'activer au printemps, vous devez enregistrer le convertisseur de messages et tout devrait fonctionner.

<mvc:annotation-driven>
  <mvc:message-converters>
    <bean class="com.owlike.genson.ext.spring.GensonMessageConverter"/>
  </mvc:message-converters>
</mvc:annotation-driven>
1
eugen

Pour le problème similaire que j'ai essayé avec @JsonIgnore , Un message d'erreur appelé Com.fasterxml.jackson.databind.JsonMappingException: aucun sérialiseur trouvé pour la classe org.citi.facility.GetterMethodsObject et aucune propriété découverte. pour créer BeanSerializer (pour éviter toute exception, désactivez SerializationFeature.FAIL_ON_EMPTY_BEANS)).

mon code simpel est 

class GetterMethodsObject 
{
    public int getId(){
        return 10;
    }
    @JsonIgnore
    public boolean isId(){
        return true;
    }
}
0
user3435827