NoSuchMethodError的解决方法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/gfgdgszfd/article/details/52212281

今天重新将xwiki8.2版部署到tomcat,期间在导入的过程中报错 错误是:

NoSuchMethodError:org.apache.commons.io.FileUtils.copyInputstreamToFile(Ljava/io/Inputstream;Ljava/io/File;)V


这种错误原因在tomcat中和webapp中和jre/lib/ext中的common-io.jar可能存在相互冲突。


jar包调用:jre-->tomcat-->webapp。


解决:把jre中的common-io-1.3.jar换为common-io-2.4.jar



done。





科科

NoSuchMethodError

11-23

我在一个JSP文件中使用usebean,然而只可以调用该bean的部分方法,其它的方法却说:NoSuchMethodError,这可能是什么原因阿?rn出错提示:rndescription The server encountered an internal error () that prevented it from fulfilling this request.rnrnexception rnrnjavax.servlet.ServletException: com.hitsun.Cart.storeToDB(Ljava/lang/String;)Vrn org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)rn org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)rn org.apache.jsp.hitsun.shop.cart_jsp._jspService(cart_jsp.java:88)rn org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rnrnrnroot cause rnrnjava.lang.NoSuchMethodError: com.hitsun.Cart.storeToDB(Ljava/lang/String;)V//我明明在Cart类中定义了storeToDB方法阿,而且我定义的Cart.addItems方法却可以使用阿.这是怎么回事?为什么有的方法可以使用,而有的却说NoSuchMethodError?????????rn org.apache.jsp.hitsun.shop.cart_jsp._jspService(cart_jsp.java:71)rn org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rnrn

NoSuchMethodError的问题

06-08

![图片说明](https://img-ask.csdn.net/upload/201706/09/1496995432_549285.png)# 刚刚搭建好maven的ssm框架访问index的时候就出现这个问题了rnjava.lang.NoSuchMethodError: javax.el.ExpressionFactory.newInstance()Ljavax/el/ExpressionFactory;rn at org.apache.jasper.compiler.PageInfo.(PageInfo.java:79)rn at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:111)rn at org.apache.jasper.compiler.Compiler.compile(Compiler.java:374)rn at org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)rn at org.apache.jasper.compiler.Compiler.compile(Compiler.java:341)rn at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:657)rn at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)rn at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)rn at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)rn at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)rn at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)rn at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)rn at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)rn at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)rn at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)rn at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)rn at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)rn at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)rn at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)rn at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)rn at java.lang.Thread.run(Unknown Source)rnrnrn---------------------------------------------------------------------------------------rnC:\Users\Administrator\.m2\repository\junit\junit\4.11\junit-4.11.jarrnC:\Users\Administrator\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jarrnC:\Users\Administrator\.m2\repository\javax\servlet\javax.servlet-api\3.0.1\javax.servlet-api-3.0.1.jarrnC:\Users\Administrator\.m2\repository\javax\servlet\jsp\jsp-api\2.1\jsp-api-2.1.jarrnC:\Users\Administrator\.m2\repository\javax\servlet\jstl\1.2\jstl-1.2.jarrnC:\Users\Administrator\.m2\repository\org\aspectj\aspectjweaver\1.8.6\aspectjweaver-1.8.6.jarrnC:\Users\Administrator\.m2\repository\org\springframework\spring-core\4.1.7.RELEASE\spring-core-4.1.7.RELEASE.jarrnC:\Users\Administrator\.m2\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jarrnC:\Users\Administrator\.m2\repository\org\springframework\spring-beans\4.1.7.RELEASE\spring-beans-4.1.7.RELEASE.jarrnC:\Users\Administrator\.m2\repository\org\springframework\spring-aop\4.1.7.RELEASE\spring-aop-4.1.7.RELEASE.jarrnC:\Users\Administrator\.m2\repository\aopalliance\aopalliance\1.0\aopalliance-1.0.jarrnC:\Users\Administrator\.m2\repository\org\springframework\spring-context\4.1.7.RELEASE\spring-context-4.1.7.RELEASE.jarrnC:\Users\Administrator\.m2\repository\org\springframework\spring-expression\4.1.7.RELEASE\spring-expression-4.1.7.RELEASE.jarrnC:\Users\Administrator\.m2\repository\org\springframework\spring-jdbc\4.1.7.RELEASE\spring-jdbc-4.1.7.RELEASE.jarrnC:\Users\Administrator\.m2\repository\org\springframework\spring-tx\4.1.7.RELEASE\spring-tx-4.1.7.RELEASE.jarrnC:\Users\Administrator\.m2\repository\org\springframework\spring-web\4.1.7.RELEASE\spring-web-4.1.7.RELEASE.jarrnC:\Users\Administrator\.m2\repository\org\springframework\spring-webmvc\4.1.7.RELEASE\spring-webmvc-4.1.7.RELEASE.jarrnC:\Users\Administrator\.m2\repository\org\springframework\spring-test\4.0.6.RELEASE\spring-test-4.0.6.RELEASE.jarrnC:\Users\Administrator\.m2\repository\org\mybatis\mybatis\3.2.7\mybatis-3.2.7.jarrnC:\Users\Administrator\.m2\repository\org\mybatis\mybatis-spring\1.2.3\mybatis-spring-1.2.3.jarrnC:\Users\Administrator\.m2\repository\mysql\mysql-connector-java\5.1.37\mysql-connector-java-5.1.37.jarrnC:\Users\Administrator\.m2\repository\com\alibaba\druid\1.0.16\druid-1.0.16.jarrnC:\Users\Administrator\.m2\repository\com\mchange\c3p0\0.9.5-pre8\c3p0-0.9.5-pre8.jarrnC:\Users\Administrator\.m2\repository\com\mchange\mchange-commons-java\0.2.7\mchange-commons-java-0.2.7.jarrnC:\Users\Administrator\.m2\repository\org\slf4j\slf4j-log4j12\1.7.12\slf4j-log4j12-1.7.12.jarrnC:\Users\Administrator\.m2\repository\org\slf4j\slf4j-api\1.7.12\slf4j-api-1.7.12.jarrnC:\Users\Administrator\.m2\repository\log4j\log4j\1.2.17\log4j-1.2.17.jarrnC:\Users\Administrator\.m2\repository\commons-fileupload\commons-fileupload\1.3.1\commons-fileupload-1.3.1.jarrnC:\Users\Administrator\.m2\repository\commons-io\commons-io\2.2\commons-io-2.2.jarrnC:\Users\Administrator\.m2\repository\org\apache\poi\poi\3.16-beta2\poi-3.16-beta2.jarrnC:\Users\Administrator\.m2\repository\commons-codec\commons-codec\1.10\commons-codec-1.10.jarrnC:\Users\Administrator\.m2\repository\org\apache\commons\commons-collections4\4.1\commons-collections4-4.1.jarrnC:\Users\Administrator\.m2\repository\com\alibaba\fastjson\1.2.24\fastjson-1.2.24.jarrnC:\Users\Administrator\.m2\repository\org\glassfish\web\el-impl\2.2\el-impl-2.2.jarrnC:\Users\Administrator\.m2\repository\javax\el\el-api\2.2\el-api-2.2.jarrn这些是我的包rnrnrn-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------rn这个是我的applicationContext.xml文件的内容rnrnrnrn rn rn rn rn rn rn rn rn rn rn rn rnrn rn rn rn rn rn rn rn rn rn rn rn rn rnrn rn rn rn rn rnrn rn rnrn rn rn rn rn rnrn rn rn rn rnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnrnrn-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------rn这个是applicationContext-mvc里面的内容rn rnrn rn rn rn rn rn rn rn rn rn text/html;charset=UTF-8 rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnrn

NoSuchMethodError: org.apache.commons.collections.IteratorUtils.emptyIterator()

08-13

这是什么原因啊,有人会吗?在网上找了好久也没有解决。rn2011-8-13 11:06:43 org.apache.catalina.core.StandardContext listenerStartrn严重: Exception sending context initialized event to listener instance of class com.liferay.portal.spring.context.PortalContextLoaderListenerrnjava.lang.NoSuchMethodError: org.apache.commons.collections.IteratorUtils.emptyIterator()Lorg/apache/commons/collections/ResettableIterator;rn at org.apache.commons.configuration.PropertyConverter.toIterator(PropertyConverter.java:882)rn at org.apache.commons.configuration.AbstractConfiguration.addPropertyValues(AbstractConfiguration.java:416)rn at org.apache.commons.configuration.AbstractConfiguration.addProperty(AbstractConfiguration.java:389)rn at com.germinus.easyconf.AggregatedProperties.addIncludedPropertiesSources(AggregatedProperties.java:215)rn at com.germinus.easyconf.AggregatedProperties.addFileProperties(AggregatedProperties.java:180)rn at com.germinus.easyconf.AggregatedProperties.addPropertiesSource(AggregatedProperties.java:140)rn at com.germinus.easyconf.AggregatedProperties.addBaseFileName(AggregatedProperties.java:116)rn at com.germinus.easyconf.ConfigurationLoader.readPropertiesConfiguration(ConfigurationLoader.java:54)rn at com.germinus.easyconf.ComponentConfiguration.getAvailableProperties(ComponentConfiguration.java:152)rn at com.germinus.easyconf.ComponentConfiguration.getProperties(ComponentConfiguration.java:140)rn at com.liferay.portal.configuration.ConfigurationImpl.getComponentProperties(ConfigurationImpl.java:338)rn at com.liferay.portal.configuration.ConfigurationImpl.printSources(ConfigurationImpl.java:390)rn at com.liferay.portal.configuration.ConfigurationImpl.(ConfigurationImpl.java:133)rn at com.liferay.portal.configuration.ConfigurationImpl.(ConfigurationImpl.java:72)rn at com.liferay.portal.util.PropsUtil.(PropsUtil.java:93)rn at com.liferay.portal.util.PropsUtil.(PropsUtil.java:225)rn at com.liferay.portal.spring.context.PortalApplicationContext.loadBeanDefinitions(PortalApplicationContext.java:63)rn at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)rn at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)rn at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)rn at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)rn at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)rn at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)rn at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)rn at com.liferay.portal.spring.context.PortalContextLoaderListener.contextInitialized(PortalContextLoaderListener.java:49)rn at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3795)rn at org.apache.catalina.core.StandardContext.start(StandardContext.java:4252)rn at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)rn at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)rn at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)rn at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)rn at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)rn at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)rn at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1150)rn at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)rn at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)rn at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)rn at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)rn at org.apache.catalina.core.StandardService.start(StandardService.java:448)rn at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)rn at org.apache.catalina.startup.Catalina.start(Catalina.java:552)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)rn at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)

NoSuchMethodError错误

05-16

rn在如下代码发生了这个错误rnrnquery.getIsSelf()==1rnrn错误rnrn[TRACE][15:30:43][org.hibernate.type.descriptor.sql.BasicBinder] - binding parameter [1] as [BIGINT] - [2]rn[DEBUG][15:30:43][org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] - Released JDBC connectionrnException in thread "Thread-12" java.lang.NoSuchMethodError: com.nielsen.nsi.domain.Query.getIsSelf()Irn at com.nielsen.nsi.timer.SyncWordCloudDataService.syncWordCloudData(SyncWordCloudDataService.java:59)rn at com.nielsen.nsi.timer.SyncWordCloudDataService$$FastClassBySpringCGLIB$$e2696af.invoke()rn at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)rn at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)rn at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)rn at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)rn at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)rn at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)rn at com.nielsen.nsi.timer.SyncWordCloudDataService$$EnhancerBySpringCGLIB$$aa7640e6.syncWordCloudData()rn at com.nielsen.nsi.timer.SyncBuzzDataService$SyncWordCloudDataRunnable.run(SyncBuzzDataService.java:173)rn at java.lang.Thread.run(Thread.java:722)rn[DEBUG][15:30:43][org.hibernate.loader.Loader] - Result set row: 0rnrn【排查】rn1,从产品环境上拉下Query.class,反编译,发现这个类的确有这个方法;rn2,在我本地运行的时候没有出错;rn3,把本地类替换到服务器上之后,出现错误,觉得应该是代码不一致;rn4,同步代码之后,发现Query里的isserf字段从int变成了Integerrn5,把代码更新成 SELF_BRAND .equals(query.getIsSelf()) 就可以了。rnrn【原因分析】rnJava的编译环境和运行环境还是有不同的。rn对于代码query.getIsSelf()==1来说,编译器可能有两种解释:rn1,query.getIsSelf()拿到的是Integer对象,编译器会把后面的1自动转化为一个Integer对象,然后做比较,看是否是一个对象(当然不会是一个)rn2,query.getIsSelf()拿到的是Integer对象,编译器会自动解释为query.getIsSelf().intValue(),获得int值,然后和1做比较rn无论哪种,反正编译器没有报错rnrn但是到了运行的时候,运行器根据==1去到Query里找方法: int getIsSelf() 但是没有,因为只有 Integer getIsSelf() 方法。rn于是就爆出这个错误。 rnrn【避免方法】rn1,严格遵守类型一致,尽量避免是用Java自动类型转换的功能;rn2,找错的时候,使用Error,而不是找出错日志, 很奇怪,这个地方竟然没有报错误日志:[ERROR]rn

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试