2013-02-05 54 views
10

私はいくつかのモデルクラスを持っています。解決方法jacksonのプロパティのゲッター定義が矛盾しています

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); 
} 

製品とSkuの実装を変更することはできません。私はProductからのみ拡張します。その後、Spring MVCコントローラからJSONオブジェクトを転送します。 マイコントローラのメソッドは

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

     Product product = catalogService.findProductByURI(productUrl);  

       return product; 
    } 

です。次の例外があります。

<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> 

私のコントローラからJSONを取得するにはどうすればよいですか。

答えて

26

あなたは紛争を解決するために、たとえばisTaxable()を無視しようとすることができます:

@JsonIgnore 
public Boolean isTaxable(); 
+0

です! – Rugal

+1

ソースにアクセスできない場合はどうなりますか?第三者libのオブジェクトのように。 –

+1

その場合、GSONのlibを使用することができますhttp://code.google.com/p/google-gson/ –

6

製品およびSKUの実装はmodifieすることはできません。

Jackson Mix-In Annotationsレスキュー!

+0

私はMix-in annotaitonsソリューションで大丈夫です。 –

1

また、Genson libを試すこともできます。春にそれを有効にするには、メッセージコンバータを登録する必要があります。

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

私の問題は、Programmer Bruceの回答に従って解決してください。

私はそれが com.fasterxml.jackson.databindようなエラーメッセージを与え@JsonIgnore と試み同様の問題について

0
@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); 
} 

、コントローラで

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

、ミックスインクラスを書きました。 JsonMappingException:org.citi.facility.GetterMethodsObjectクラスのシリアライザが見つかりません。BeanSerializerを作成するためのプロパティが見つかりません(例外を回避するため、SerializationFeature.FAIL_ON_EMPTY_BEANSを無効にしてください)。

私simpelコードは、それが私の問題を解決し

class GetterMethodsObject 
{ 
    public int getId(){ 
     return 10; 
    } 
    @JsonIgnore 
    public boolean isId(){ 
     return true; 
    } 
} 
関連する問題