当尝试通过SpringDataAccessService上的HibernateUpdater存储HibernateBeans时,我不断从dpHibernate获取ClassCastException。通过单独的服务将数据提供给客户端,dao到目前为止工作正常。
我已经尝试过手动放置所有必要的库,也许有人可以给我一个正确版本的提示或者我的配置中有什么问题。
栈跟踪
{operation})****************saveBean
{deserialize} 1
[BlazeDS]Error processing remote invocation: java.lang.ClassCastException: org.dphibernate.persistence.state.ObjectChangeMessage$$EnhancerByLambdajWithCGLIB$$4a51fe7a cannot be cast to net.sf.cglib.proxy.Factory
incomingMessage: Flex Message (flex.messaging.messages.RemotingMessage)
operation = saveBean
clientId = C060A0E3-C30E-F1B1-61D0-192B750927F4
destination = dataAccessService
messageId = 0F136397-F41E-B085-22ED-696BFB6938A5
timestamp = 1303143775091
timeToLive = 0
body =
[
[]
]
hdr(DSId) = C060524C-221A-5A0A-2968-40940F71F845
hdr(DSEndpoint) = my-amf
java.lang.ClassCastException: org.dphibernate.persistence.state.ObjectChangeMessage$$EnhancerByLambdajWithCGLIB$$4a51fe7a cannot be cast to net.sf.cglib.proxy.Factory
at ch.lambdaj.proxy.ClassImposterizer.createProxy(ClassImposterizer.java:134)
at ch.lambdaj.proxy.ClassImposterizer.imposterise(ClassImposterizer.java:101)
at ch.lambdaj.proxy.ProxyUtil.createProxy(ProxyUtil.java:50)
at ch.lambdaj.function.argument.ArgumentsFactory.createPlaceholder(ArgumentsFactory.java:52)
at ch.lambdaj.function.argument.ArgumentsFactory.registerNewArgument(ArgumentsFactory.java:45)
at ch.lambdaj.function.argument.ArgumentsFactory.createArgument(ArgumentsFactory.java:39)
at ch.lambdaj.function.argument.ArgumentsFactory.createArgument(ArgumentsFactory.java:31)
at ch.lambdaj.Lambda.on(Lambda.java:44)
at org.dphibernate.persistence.state.ObjectChangeUpdater.update(ObjectChangeUpdater.java:231)
at org.dphibernate.services.ProxyUpdaterService.saveBean(ProxyUpdaterService.java:29)
at org.dphibernate.services.DataAccessService.saveBean(DataAccessService.java:45)
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 flex.messaging.services.remoting.adapters.JavaAdapter.invoke(JavaAdapter.java:418)
at org.dphibernate.adapters.RemotingAdapter.invoke(RemotingAdapter.java:124)
at flex.messaging.services.RemotingService.serviceMessage(RemotingService.java:183)
at flex.messaging.MessageBroker.routeMessageToService(MessageBroker.java:1400)
at flex.messaging.endpoints.AbstractEndpoint.serviceMessage(AbstractEndpoint.java:1005)
at flex.messaging.endpoints.AbstractEndpoint$$FastClassByCGLIB$$1a3ef066.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.flex.core.MessageInterceptionAdvice.invoke(MessageInterceptionAdvice.java:66)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.adapter.ThrowsAdviceInterceptor.invoke(ThrowsAdviceInterceptor.java:124)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$FixedChainStaticTargetInterceptor.intercept(Cglib2AopProxy.java:572)
at flex.messaging.endpoints.AMFEndpoint$$EnhancerByCGLIB$$635368af.serviceMessage(<generated>)
at flex.messaging.endpoints.amf.MessageBrokerFilter.invoke(MessageBrokerFilter.java:103)
at flex.messaging.endpoints.amf.LegacyFilter.invoke(LegacyFilter.java:158)
at flex.messaging.endpoints.amf.SessionFilter.invoke(SessionFilter.java:44)
at flex.messaging.endpoints.amf.BatchProcessFilter.invoke(BatchProcessFilter.java:67)
at flex.messaging.endpoints.amf.SerializationFilter.invoke(SerializationFilter.java:166)
at flex.messaging.endpoints.BaseHTTPEndpoint.service(BaseHTTPEndpoint.java:291)
at flex.messaging.endpoints.AMFEndpoint$$EnhancerByCGLIB$$635368af.service(<generated>)
at org.springframework.flex.servlet.MessageBrokerHandlerAdapter.handle(MessageBrokerHandlerAdapter.java:108)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
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)
[BlazeDS]Exception when invoking service 'remoting-service': flex.messaging.MessageException: java.lang.ClassCastException : org.dphibernate.persistence.state.ObjectChangeMessage$$EnhancerByLambdajWithCGLIB$$4a51fe7a cannot be cast to net.sf.cglib.proxy.Factory
incomingMessage: Flex Message (flex.messaging.messages.RemotingMessage)
operation = saveBean
clientId = C060A0E3-C30E-F1B1-61D0-192B750927F4
destination = dataAccessService
messageId = 0F136397-F41E-B085-22ED-696BFB6938A5
timestamp = 1303143775091
timeToLive = 0
body =
[
[]
]
hdr(DSId) = C060524C-221A-5A0A-2968-40940F71F845
hdr(DSEndpoint) = my-amf
Exception: flex.messaging.MessageException: java.lang.ClassCastException : org.dphibernate.persistence.state.ObjectChangeMessage$$EnhancerByLambdajWithCGLIB$$4a51fe7a cannot be cast to net.sf.cglib.proxy.Factory
at flex.messaging.services.remoting.adapters.JavaAdapter.invoke(JavaAdapter.java:444)
at org.dphibernate.adapters.RemotingAdapter.invoke(RemotingAdapter.java:124)
at flex.messaging.services.RemotingService.serviceMessage(RemotingService.java:183)
at flex.messaging.MessageBroker.routeMessageToService(MessageBroker.java:1400)
at flex.messaging.endpoints.AbstractEndpoint.serviceMessage(AbstractEndpoint.java:1005)
at flex.messaging.endpoints.AbstractEndpoint$$FastClassByCGLIB$$1a3ef066.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.flex.core.MessageInterceptionAdvice.invoke(MessageInterceptionAdvice.java:66)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.adapter.ThrowsAdviceInterceptor.invoke(ThrowsAdviceInterceptor.java:124)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$FixedChainStaticTargetInterceptor.intercept(Cglib2AopProxy.java:572)
at flex.messaging.endpoints.AMFEndpoint$$EnhancerByCGLIB$$635368af.serviceMessage(<generated>)
at flex.messaging.endpoints.amf.MessageBrokerFilter.invoke(MessageBrokerFilter.java:103)
at flex.messaging.endpoints.amf.LegacyFilter.invoke(LegacyFilter.java:158)
at flex.messaging.endpoints.amf.SessionFilter.invoke(SessionFilter.java:44)
at flex.messaging.endpoints.amf.BatchProcessFilter.invoke(BatchProcessFilter.java:67)
at flex.messaging.endpoints.amf.SerializationFilter.invoke(SerializationFilter.java:166)
at flex.messaging.endpoints.BaseHTTPEndpoint.service(BaseHTTPEndpoint.java:291)
at flex.messaging.endpoints.AMFEndpoint$$EnhancerByCGLIB$$635368af.service(<generated>)
at org.springframework.flex.servlet.MessageBrokerHandlerAdapter.handle(MessageBrokerHandlerAdapter.java:108)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
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.ClassCastException: org.dphibernate.persistence.state.ObjectChangeMessage$$EnhancerByLambdajWithCGLIB$$4a51fe7a cannot be cast to net.sf.cglib.proxy.Factory
at ch.lambdaj.proxy.ClassImposterizer.createProxy(ClassImposterizer.java:134)
at ch.lambdaj.proxy.ClassImposterizer.imposterise(ClassImposterizer.java:101)
at ch.lambdaj.proxy.ProxyUtil.createProxy(ProxyUtil.java:50)
at ch.lambdaj.function.argument.ArgumentsFactory.createPlaceholder(ArgumentsFactory.java:52)
at ch.lambdaj.function.argument.ArgumentsFactory.registerNewArgument(ArgumentsFactory.java:45)
at ch.lambdaj.function.argument.ArgumentsFactory.createArgument(ArgumentsFactory.java:39)
at ch.lambdaj.function.argument.ArgumentsFactory.createArgument(ArgumentsFactory.java:31)
at ch.lambdaj.Lambda.on(Lambda.java:44)
at org.dphibernate.persistence.state.ObjectChangeUpdater.update(ObjectChangeUpdater.java:231)
at org.dphibernate.services.ProxyUpdaterService.saveBean(ProxyUpdaterService.java:29)
at org.dphibernate.services.DataAccessService.saveBean(DataAccessService.java:45)
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 flex.messaging.services.remoting.adapters.JavaAdapter.invoke(JavaAdapter.java:418)
... 43 more
dpHibernate.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:flex="http://www.springframework.org/schema/flex" xmlns:security="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/flex
http://www.springframework.org/schema/flex/spring-flex-1.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd
">
<!-- Defines the remoting adapter, which intercepts inbound & outbound messages, and routes them thruogh dpHibernate -->
<bean id="dpHibernateRemotingAdapter"
class="org.springframework.flex.core.ManageableComponentFactoryBean">
<constructor-arg value="org.dphibernate.adapters.RemotingAdapter" />
<property name="properties">
<value>
{"dpHibernate" :
{
"serializerFactory" : "org.dphibernate.serialization.SpringContextSerializerFactory"
}
}
</value>
</property>
</bean>
<bean id="dpHibernateMessagingAdapter"
class="org.springframework.flex.core.ManageableComponentFactoryBean">
<constructor-arg
value="org.dphibernate.adapters.MessagingAdapter" />
</bean>
<!-- Provides a basic dataAccessService for CRUD operations through dpHibernate.
It's also exported as a remoting destination, which makes it accessible to flex clients
-->
<bean id="dataAccessService" class="org.dphibernate.services.SpringDataAccessService" autowire="constructor">
<flex:remoting-destination />
</bean>
<!-- ProxyBatchLoader enabled batched loading of objects. A single request is sent for many objects,
rather than several individual requests. This is optional, but provides significant performance improvements -->
<bean id="proxyBatchLoader" class="org.dphibernate.services.ProxyBatchLoader" autowire="constructor" />
<!-- <bean id="proxyUpdaterService" class="org.dphibernate.services.SpringProxyUpdaterService" autowire="constructor"/> -->
<!-- <bean id="proxyLoadService" class="org.dphibernate.services.ProxyLoadService" autowire="constructor"/> -->
<!-- Required - Will be referenced from web.xml -->
<bean id="dpHibernateSessionFilter" class="org.dphibernate.filters.SpringHibernateSessionServletFilter" />
<!-- The cache is used to prevent serializing the same object many times during serialization. Required -->
<bean id="dpHibernateCache"
class="org.dphibernate.serialization.DPHibernateCache" scope="prototype" />
<!-- The main serializer. Converts outbound POJO's to ASObjects with dpHibernate proxies for lazy loading. Required -->
<bean id="dpHibernateSerializer"
class="org.dphibernate.serialization.HibernateSerializer" scope="prototype">
<property name="pageSize" value="10"/>
</bean>
<bean id="dpHibernateDeserializer" class="org.dphibernate.serialization.HibernateDeserializer" scope="prototype" />
<!-- Handles entity updates (CRUD). Required if using entity persistence. -->
<bean id="objectChangeUpdater"
class="org.dphibernate.persistence.state.AuthenticatedObjectChangeUpdater"
scope="prototype">
<property name="preProcessors" ref="dpHibernatePreProcessors" />
<property name="postProcessors" ref="dpHibernatePostProcessors" />
</bean>
<!-- Used in update process, for resolving proxies back to the entity -->
<bean id="hibernateProxyResolver" class="org.dphibernate.persistence.state.DbProxyResolver"
scope="prototype">
<constructor-arg ref="sessionFactory" />
</bean>
<!-- Optional. Pre processors are invoked before an update operation. Must implement IChangeMessageInterceptor -->
<util:list id="dpHibernatePreProcessors">
<!-- <ref bean="uniqueUsernameInterceptor" /> -->
</util:list>
<!-- Optional. Post processors are invokes after an update operation. Must implement IChangeMessageInterceptor -->
<util:list id="dpHibernatePostProcessors">
<!-- <ref bean="passwordEncryptionInterceptor" /> -->
</util:list>
flexContext.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:flex="http://www.springframework.org/schema/flex"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/flex
http://www.springframework.org/schema/flex/spring-flex-1.0.xsd">
<flex:message-destination id="chat"/>
<flex:remoting-destination ref="_messageBroker"/>
<!-- gets id "_messageBroker" by default -->
<flex:message-broker services-config-path="/WEB-INF/flex/services-config.xml">
<flex:remoting-service default-adapter-id="dpHibernateRemotingAdapter" default-channels="my-amf,my-secure-amf" />
<flex:message-service default-adapter-id="dpHibernateMessagingAdapter" default-channels="my-streaming-amf,my-polling-amf"/>
</flex:message-broker>
<!-- Application specific DAOs -->
<bean class="com.mycompany.myproject.hibernate.dao.PersonDAO"></bean>
<bean class="com.mycompany.myproject.hibernate.dao.PersonSalutationDAO"></bean>
由于通过单独的dao函数获取数据工作正常,我想为什么不以这种方式存储它。到目前为止,它适用于我想要存储和加载的内容,但没有ChangeSet功能,因此我始终必须始终传输完整数据。