- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在一个项目的代码中。当我尝试将对象 RRREC
类型转换为 RR_REC
类型时出现错误。
RRREC
类:
public class RRREC{
protected String owner;
protected RRINFRATYPE infraType;
// getter and setter
}
RR_REC 类:
public class RR_REC{
protected String localOwner;
protected RR_INFRA_TYPE localInfraType;
// getter and setter
}
RRINFRATYPE
类:
public enum RRINFRATYPE {
V_6_ADDRESS("V6ADDRESS"),
OBJECT("OBJECT"),
ZONE("ZONE"),
V_4_REVERSEZONE("V4REVERSEZONE"),
V_6_REVERSEZONE("V6REVERSEZONE"),
NODE("NODE"),
ALL("ALL");
private final String value;
RRINFRATYPE(String v) {
value = v;
}
public String value() {
return value;
}
public static RRINFRATYPE fromValue(String v) {
for (RRINFRATYPE c: RRINFRATYPE.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}
}
RR_INFRA_TYPE
:
public class RR_INFRA_TYPE{
protected String localRR_INFRA_TYPE;
private static java.util.HashMap _table_ = new java.util.HashMap();
// Constructor
protected RR_INFRA_TYPE(String value, boolean isRegisterValue) {
localRR_INFRA_TYPE = value;
if (isRegisterValue) {
_table_.put(localRR_INFRA_TYPE, this);
}
}
当我调试代码时
// getMapper will return DozerBeanMapper object
// and request is a RRREC object
getMapper().map(request, RR_REC.class);
我得到一个错误,下面是堆栈跟踪
Nov 17, 2015 2:46:44 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [RESTfulServlet] in context with path [] threw exception [Request processing failed; nested exception is org.dozer.MappingException: java.lang.NoSuchMethodException: com.qip.nb.ws.RR_INFRA_TYPE.<init>()] with root cause
java.lang.NoSuchMethodException: com.qip.nb.ws.RR_INFRA_TYPE.<init>()
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getDeclaredConstructor(Unknown Source)
at org.dozer.factory.ConstructionStrategies$ByConstructor.newInstance(ConstructionStrategies.java:257)
at org.dozer.factory.ConstructionStrategies$ByConstructor.create(ConstructionStrategies.java:245)
at org.dozer.factory.DestBeanCreator.create(DestBeanCreator.java:65)
at org.dozer.MappingProcessor.mapCustomObject(MappingProcessor.java:477)
at org.dozer.MappingProcessor.mapOrRecurseObject(MappingProcessor.java:434)
at org.dozer.MappingProcessor.mapFromFieldMap(MappingProcessor.java:330)
at org.dozer.MappingProcessor.mapField(MappingProcessor.java:276)
at org.dozer.MappingProcessor.map(MappingProcessor.java:245)
at org.dozer.MappingProcessor.map(MappingProcessor.java:187)
at org.dozer.MappingProcessor.map(MappingProcessor.java:124)
at org.dozer.MappingProcessor.map(MappingProcessor.java:119)
at org.dozer.DozerBeanMapper.map(DozerBeanMapper.java:111)
at com.qip.nb.ws.restful.controller.RRController.buildSOAPRequest(RRController.java:488)
at com.qip.nb.ws.restful.controller.RRController.getRRs(RRController.java:374)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:858)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:151)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at com.qip.nb.ws.restful.security.AuthenticationTokenProcessingFilter.doFilter(AuthenticationTokenProcessingFilter.java:52)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
最佳答案
Dozer 通常需要一个默认构造函数。您的类 RR_INFRA_TYPE
没有一个,因为您定义了默认构造函数以外的构造函数。
要告诉推土机如何实例化您的目标类,您必须实现自定义 bean 工厂。您可以在那里初始化您的 RR_INFRA_TYPE
对象所需的所有参数,然后此实例将由 dozer 进一步处理/填充。
更多信息在这里: http://dozer.sourceforge.net/documentation/custombeanfactories.html
关于java - Dozer MappingException NoSuchMethodException 初始化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33751925/
我有 Symfony 项目,其中有 2 个实体 - Building 和 Building_type。它们与 ManyToMany 单向关联相连。因此,当我尝试访问我的 Controller 时,我遇
在 couchBase 中保存 Map 类型数据时出现异常 Caused by: org.springframework.data.mapping.MappingException: Couldn't
我在使用无状态 session 进行更新时遇到问题,我 想知道是否有人见过这样的东西。 (NHibernate 3.1)。 我基本上是在做以下事情: SomeEntity e = statelessS
在使用hibernate时,我遇到了在两个不同的包中映射类的问题。 我有一个 myapp.domain.ItemforSale 类,它将映射到 myapp.cart.CartItem 我创建了 Car
最近,我将项目从 Hibernate 版本 3.1 迁移到 4.3,为了获得更好的性能,我尝试使用注释而不是 xml 映射。在继承类的所有实体类中,出现以下异常。错误是“org.hibernate.M
我正在努力解决以下问题: Caused by: org.hibernate.MappingException: Foreign key (FKj4uw5b6ekvxc2djohvon7lk7:bi_p
我尝试让 hibernate 4 运行(JBoss AS 7 附带)并将我的应用程序部署为 EAR(persistence.xml iis 在 EAR 的 META-INF 中)。 hibernate
我正在使用 JBoss AS 7 和 IDEA 11。当我尝试部署我的应用程序时遇到了这个问题: 我的应用中有两个实体: 首先: @Entity @Table(name="users") public
我在尝试使用 Hibernate 时遇到映射异常 - 在独立的 java 应用程序中(使用 netbeans 8)。我已经配置了 hibernate.cfg.xml 并设置了 hbm.xml 文件并映
我有一个数据库、hbm 映射文件和位于类库 中的 App.config。现在从一个测试项目中我引用该库并尝试调用我创建的 HibernateHelper 类,在运行时抛出以下错误: NHibernat
我有这个异常(exception): org.hibernate.MappingException: persistent class not known: java.lang.Long 我正在使用
情景 我需要在两个不同的上下文中表示一个对象。一个上下文不应该持续存在,另一个应该。持久对象是从另一个系统中提取的实际数据。非持久对象代表产品定义的一部分。两者将进行比较,我对存储定义数据不感兴趣。持
我有一个带有复合 ID 的表,其中一个字段是另一个表的外键。 我尝试使用以下类来实现这一点 - Tracking.java: public class Tracking { @Id @
我正在使用 Hibernate 注释并且有一个非常基本的数据对象: import java.io.Serializable; import javax.persistence.Entity; impo
我很好奇这个错误 org.hibernate.MappingException:未知实体:xyz 我是 hibernate 新手。欢迎提出任何建议。提前致谢。 最佳答案 Hibernate 将您的数据
我做错了什么? Exceprion 说我需要使“id”字段不可插入且不可更新。但我已经有了这些注释。我什至删除了“id”的setter方法,但它没有任何效果。是不是少了什么? weblogic.app
我正在为这两个类使用 JPA 注释: @Entity @RooJavaBean @RooToString @RooEntity @MappedSuperclass public abstract cl
使用 Castor 1.3,在测试时收到以下异常: org.exolab.castor.mapping.MappingException: The Java class com.company.sal
我收到以下错误: Could not determine type for: java.util.Set, at table: Ruleset, for columns: [org.hibernate
我在一个项目的代码中。当我尝试将对象 RRREC 类型转换为 RR_REC 类型时出现错误。 RRREC 类: public class RRREC{ protected String ow
我是一名优秀的程序员,十分优秀!