- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我使用 HibernateSession 类中的 load 方法时,出现以下异常,如下所示:
getCurrentSession().load(entityClass, id);
。
如果我使用以下内容,我不会收到异常:
getCurrentSession().get(entityClass, id);
。
这是类代码
package com.company.x.y.field;
@Entity
@Table(name = "FIELD")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "FIELDTYPE")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE,region="xEntity")
public abstract class AbstractField extends AbstractEntity {
private static final long serialVersionUID = 1L;
private final ValueType valueType;
private final FieldType fieldType;
private DataPoint dataPoint;
private String name;
private String title;
private String guid;
private boolean deleted;
private Integer sequence;
protected AbstractField(FieldType fieldType, ValueType valueType) {
this.fieldType = fieldType;
this.valueType = valueType;
}
@Id
@SequenceGenerator(name = "SEQ_FIELD_ID", sequenceName = "SEQ_FIELD_ID", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_FIELD_ID")
@Override
@Column(name = "FIELD_ID")
public Long getId() {
return id;
}
@Transient
public ValueType getValueType() {
return valueType;
}
@Transient
public FieldType getFieldType() {
return fieldType;
}
@ManyToOne
//@JoinColumn(name = "DP_ID", updatable = false)
@JoinColumn(name = "DP_ID")
public DPClass getDPClass() {
return dpClass;
}
public void setDataPoint(DPClass dpClass) {
this.dpClass = dpClass;
}
@Column(name = "NAME")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(name = "TITLE")
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@Column(name = "GUID")
public String getGuid() {
if (StringUtils.isEmpty(guid)) {
guid = UUID.randomUUID().toString().toUpperCase().replaceAll("-", "");
}
return guid;
}
public void setGuid(String guid) {
this.guid = guid;
}
@Column(name = "DELETED_IND")
public boolean isDeleted() {
return deleted;
}
public void setDeleted(boolean deleted) {
this.deleted = deleted;
}
@Column(name = "SEQUENCE")
public Integer getSequence() {
return sequence;
}
public void setSequence(Integer sequence) {
this.sequence = sequence;
}
@Column(name = "CREAT_TS")
public Date getDateCreated() {
return dateCreated;
}
@Column(name = "CREAT_USER")
public String getUserCreated() {
return userCreated;
}
@Column(name = "LAST_UPDATE_TS")
public Date getDateUpdated() {
return dateUpdated;
}
@Column(name = "LAST_UPDATE_USER")
public String getUserUpdated() {
return userUpdated;
}
}
异常情况如下:
org.hibernate.HibernateException: Javassist Enhancement failed: com.company.x.y.field.AbstractField
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:142)
at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.getProxy(JavassistProxyFactory.java:71)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:631)
at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3737)
at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:360)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:281)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:985)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:978)
at com.company.x.y.field.app.FieldServiceImpl.getById(FieldServiceImpl.java:152)
at com.company.x.y.field.app.FieldServiceImpl.getById(FieldServiceImpl.java:1)
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.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy67.getById(Unknown Source)
at com.company.impl.web.AbstractEntityBean.getEntity(AbstractEntityBean.java:36)
at sun.reflect.GeneratedMethodAccessor289.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:302)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at com.sun.el.parser.AstValue.getValue(AstValue.java:116)
at com.sun.el.parser.AstValue.getValue(AstValue.java:163)
at com.sun.el.parser.AstEqual.getValue(AstEqual.java:54)
at com.sun.el.parser.AstOr.getValue(AstOr.java:54)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:193)
at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:422)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1038)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1048)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1048)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1048)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1048)
at org.primefaces.component.tabview.TabView.processDecodes(TabView.java:243)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1048)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1048)
at org.primefaces.component.tabview.TabView.processDecodes(TabView.java:243)
at javax.faces.component.UIForm.processDecodes(UIForm.java:216)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1048)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1048)
at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:926)
at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:508)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
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.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:64)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:101)
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.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.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.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.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:185)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:269)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.InstantiationException: com.company.x.y.field.AbstractField_$$_javassist_28
at java.lang.Class.newInstance0(Class.java:340)
at java.lang.Class.newInstance(Class.java:308)
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:139)
... 100 more
如果有人能给出原因,我们将不胜感激>谢谢。
最佳答案
类com.company.x.y.field.AbstractField
没有默认(无参数)构造函数。
得出上述结论的堆栈跟踪部分。
Caused by: java.lang.InstantiationException: com.company.x.y.field.AbstractField_$$_javassist_28
at java.lang.Class.newInstance0(Class.java:340)
at java.lang.Class.newInstance(Class.java:308)
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:139)
... 100 more
关于hibernate - 获取异常 Javassist 增强失败 : due to JavassistLazyInitializer. getProxy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12322032/
Maven Artifact 之间有什么区别 javassist:javassist 和 org.javassist:javassist 在我的项目中,我的第一个依赖项是 3.8 版本,而我引入的第二
我有一个 CtMethod实例,但我不知道如何从中获取参数(不是类型)的名称。我试过 getParameterTypes ,但它似乎只返回类型。 我假设这是可能的,因为我使用的库没有源,只有类文件,我
可以使用 CtMethod.setBody("..") 设置方法主体,但我没有找到任何 API 来获取字符串格式的方法主体。 最佳答案 这不可能。 Javassist 不是反编译器。类文件中的方法以
可以使用CtMethod.setBody("..")设置方法体,但我没有找到任何API来获取字符串格式的方法体。 最佳答案 这是不可能的。 Javassist 不是反编译器。类文件中的方法用 Java
当使用 javassist 检测 com.sun.net.* 类时,我可以成功使用 .insertAfter 方法。但是,当尝试从 Glassfish 中运行的应用程序检测第三方类时,我收到错误: F
我正在使用 javassist 来更改方法体。当该方法在应用程序中定义时我可以做到这一点。但是,当我想更改应用程序使用的 jar 文件中定义的方法时,我会收到以下运行时错误: javassist.Ca
我在模型上使用 javassist:com.project.model.Model我已经尝试过各种组合如何为 ClassPath 和 CtClass 格式化字符串,但无济于事。 ClassPo
我正在处理 SpringMVC、Hibernate 和 JSON,但出现此错误。 HTTP Status 500 - Could not write JSON: No serializer found
我正在使用 javassist 创建一个类并为其添加注释。当我使用 CtClass.writeFile 并且我看到带有 Java 反编译器的类文件时,注释就在那里,但是当我使用 class.getAn
我想读取一个方法的返回值,并且我必须将其传递给使用 method.insertAfter 插入的代码。 示例: public String sayHello(){ return "1"; }
这是原始方法: @GET @Produces({"application/json"}) public Response getTermClouds(@Context SecurityCo
我正在尝试在应用程序启动期间使用附加功能来增强一些代码。整个设置本身工作正常,但有一点我认为 javassist 可能会生成错误的代码。 我正在特定类的特定方法上执行此操作,我之前检查过返回值实际上是
我正在编写一些 Javassist 代码来拦截方法调用并用代理替换它们。为此,我使用 ExprEditor 按以下方式替换调用: public static void main(String[] ar
我目前正在实现一个注释,强制字段通过 javassist 遵守条件。我想检查一个字段在读取时是否已初始化...因此,目前,我通过在虚拟机通过 Translator.onLoad(ClassPool p
我正在尝试使用 javassist 在编译时插入一些代码片段 环境 Java 8 Spring 启动 2.2.6 hibernate 5.4.12.Final Javasist nl.topicu
我对 javassist 有点问题,用方法处理程序装饰类。问题是方法处理程序与 Abc 类中的 method1 一起正常工作,但不会拦截对 Def 内部类中的 method2 的调用。 public
我将代码注入(inject)到 doGet 方法中 val replace = "" + " System.out.println(\"[before] " + className + "\")
我试图捕获分支和循环语句的条件表达式中涉及的变量值,例如: if (a + b < c - 5) { // here, capture value of a, b and c // if bo
我正在开发一个需要类检测的项目。我使用 javassist 因为在我的情况下进行检测非常方便。 我遇到了一个问题,可以使用以下代码片段进行描述: 假设 1 类: public class Class1
我试图在 java 类文件中找到类初始值设定项。我可以找到该方法,但如果在类文件中找不到 main,那么我希望它找到类初始值设定项并在那里注入(inject)代码。 如何使用 Javassist 找到
我是一名优秀的程序员,十分优秀!