我在工程中遇到一个怪问题。
TailPriceService 继承自 BaseService。 在BaseService里面有一个deleteObjece(Objece.class, id)方法。
将TailPriceService 注入到Actoin里面,并且在调用deleteObjece方法时抛出NoSuchMehod异常。
我使用java反编译查看BaseService.class 的代码发现在BaseService里面有这样的方法:
public boolean deleteObject(Class objClass, String id)
{
try
{
getHibernateTemplate().delete(getObject(objClass, id));
}
catch(RuntimeException e)
{
return false;
}
return true;
}
而且在Action里面的调用:
service.deleteObject(com/hbs/model/TailProjectItem, request.getParameter("tailProjectItemId"));
可是就是在工程运行调用的时候报错。
18:11:26,708 DEBUG TransactionSynchronizationManager:166 - Bound value [org.springframework.orm.hibernate3.SessionHolder@150d9b5] for key [org.hibernate.impl.SessionFactoryImpl@baf4ae] to thread [TP-Processor2]
18:11:26,708 DEBUG TransactionSynchronizationManager:190 - Removed value [org.springframework.orm.hibernate3.SessionHolder@150d9b5] for key [org.hibernate.impl.SessionFactoryImpl@baf4ae] from thread [TP-Processor2]
2008-12-22 18:11:26 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet action threw exception
java.lang.NoSuchMethodError: com.hbs.manage.tailpricemanage.TailPriceService.deleteObject(Ljava/lang/Class;Ljava/lang/String;)V
at com.hbs.manage.tailpricemanage.TailPriceAction.execute(TailPriceAction.java:58)
at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:106)
at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:53)
at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:64)
at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:48)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:280)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1858)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:459)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:214)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.hbs.filter.SSOFilter.doFilter(SSOFilter.java:42)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.hbs.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:135)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:686)
at java.lang.Thread.run(Thread.java:595)
问题补充:
引用
com/hbs/model/TailProjectItem
你确定传的这个是个对象(Object),而不是是个class?
你确定传的这个是个对象(Object),而不是是个class?
重新查看了代码,果然和1楼说的一样,是在Action的方法调用里面传入的是obj而不是class。 谢谢