iteye_20094 2008-12-22 20:59
浏览 191
已采纳

NoSuchMehod的怪问题

我在工程中遇到一个怪问题。

    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?




重新查看了代码,果然和1楼说的一样,是在Action的方法调用里面传入的是obj而不是class。 谢谢
  • 写回答

2条回答 默认 最新

  • qbqopen 2008-12-22 20:59
    关注

    com/hbs/model/TailProjectItem

    你确定传的这个是个对象(Object),而不是是个class?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥15 pyqt信号槽连接写法
  • ¥500 把面具戴到人脸上,请大家贡献智慧,别用大模型回答,大模型的答案没啥用
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。