最近我已经向Heroku部署了一个Java应用程序。我部署的应用程序还具有可以打开的后台进程。该应用程序倾向于接近Heroku为单个dyno分配的所有512MB - 没有后台进程运行。在没有打开后台进程的情况下,一切似乎都能正常工作,但是当我打开后台进程时,我的应用程序开始使用的内存超过分配的512MB,我立即用NoSuchMethodErrors命中。我已经在下面列出了堆栈跟踪。我觉得由于内存不足而抛出NoSuchMethodError似乎很奇怪,但它是我能想到的唯一变量。该程序完全正常,直到我打开后台进程。
真正奇怪的是,一旦我重新启动应用程序,所有端点将在短时间内没有问题地提供JSON服务 - 但是在可变的时间之后,相同的端点将开始抛出NoSuchMethodErrors。应用程序如何找到一种方法,然后10分钟后再找不到它?
java.lang.NoSuchMethodError: org.jboss.resteasy.specimpl.BuiltResponse.getHeaders()Ljavax/ws/rs/core/MultivaluedMap;
2015-01-31T01:06:37.924505+00:00 app[web.1]: at org.jboss.resteasy.core.ServerResponseWriter.setDefaultContentType(ServerResponseWriter.java:186)
2015-01-31T01:06:37.924507+00:00 app[web.1]: at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:46)
2015-01-31T01:06:37.924509+00:00 app[web.1]: at org.jboss.resteasy.core.SynchronousDispatcher.writeResponse(SynchronousDispatcher.java:427)
2015-01-31T01:06:37.924510+00:00 app[web.1]: at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:376)
2015-01-31T01:06:37.924550+00:00 app[web.1]: at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179)
2015-01-31T01:06:37.924552+00:00 app[web.1]: at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220)
2015-01-31T01:06:37.924554+00:00 app[web.1]: at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
2015-01-31T01:06:37.924556+00:00 app[web.1]: at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
2015-01-31T01:06:37.924558+00:00 app[web.1]: at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
2015-01-31T01:06:37.924559+00:00 app[web.1]: at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:751)
2015-01-31T01:06:37.924561+00:00 app[web.1]: at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:566)
2015-01-31T01:06:37.924562+00:00 app[web.1]: at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
2015-01-31T01:06:37.924564+00:00 app[web.1]: at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:578)
2015-01-31T01:06:37.924566+00:00 app[web.1]: at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221)
2015-01-31T01:06:37.924567+00:00 app[web.1]: at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1111)
2015-01-31T01:06:37.924570+00:00 app[web.1]: at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)
2015-01-31T01:06:37.924572+00:00 app[web.1]: at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1045)
2015-01-31T01:06:37.924569+00:00 app[web.1]: at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:498)
2015-01-31T01:06:37.924573+00:00 app[web.1]: at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
2015-01-31T01:06:37.924575+00:00 app[web.1]: at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:199)
2015-01-31T01:06:37.924576+00:00 app[web.1]: at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)
2015-01-31T01:06:37.924578+00:00 app[web.1]: at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:98)
2015-01-31T01:06:37.924579+00:00 app[web.1]: at org.eclipse.jetty.server.Server.handle(Server.java:461)
2015-01-31T01:06:37.924581+00:00 app[web.1]: at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:284)
2015-01-31T01:06:37.924582+00:00 app[web.1]: at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:244)
2015-01-31T01:06:37.924584+00:00 app[web.1]: at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:534)
2015-01-31T01:06:37.924586+00:00 app[web.1]: at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:607)
2015-01-31T01:06:37.924587+00:00 app[web.1]: at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:536)
2015-01-31T01:06:37.924594+00:00 app[web.1]: at java.lang.Thread.run(Thread.java:745)
这是我的mvn依赖:树
[INFO] --- maven-dependency-plugin:2.4:tree (default-cli) @ crewdriver ---
[INFO] com.getworkers:crewdriver:war:1.2-SNAPSHOT
[INFO] +- org.jboss.resteasy:resteasy-jaxrs:jar:3.0.9.Final:compile
[INFO] | +- org.jboss.resteasy:jaxrs-api:jar:3.0.9.Final:compile
[INFO] | +- org.jboss.spec.javax.annotation:jboss-annotations-api_1.1_spec:jar:1.0.1.Final:compile
[INFO] | +- javax.activation:activation:jar:1.1:compile
[INFO] | \- net.jcip:jcip-annotations:jar:1.0:compile
[INFO] +- org.jboss.resteasy:resteasy-client:jar:3.0.9.Final:compile
[INFO] +- org.jboss.resteasy:resteasy-jaxb-provider:jar:3.0.9.Final:compile
[INFO] | \- com.sun.xml.bind:jaxb-impl:jar:2.2.7:compile
[INFO] | +- com.sun.xml.bind:jaxb-core:jar:2.2.7:compile
[INFO] | | +- javax.xml.bind:jaxb-api:jar:2.2.7:compile
[INFO] | | \- com.sun.istack:istack-commons-runtime:jar:2.16:compile
[INFO] | \- com.sun.xml.fastinfoset:FastInfoset:jar:1.2.12:compile
[INFO] | \- javax.xml.bind:jsr173_api:jar:1.0:compile
[INFO] +- org.jboss.resteasy:resteasy-jackson-provider:jar:3.0.9.Final:compile
[INFO] | +- org.codehaus.jackson:jackson-core-asl:jar:1.9.12:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.12:compile
[INFO] | +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.12:compile
[INFO] | \- org.codehaus.jackson:jackson-xc:jar:1.9.12:compile
[INFO] +- org.jboss.resteasy:resteasy-servlet-initializer:jar:3.0.9.Final:compile
[INFO] | \- org.jboss.resteasy:async-http-servlet-3.0:jar:3.0.9.Final:compile
[INFO] +- org.eclipse.jetty.orbit:javax.servlet:jar:3.0.0.v201112011016:provided
[INFO] +- net.spy:spymemcached:jar:2.11.4:compile
[INFO] +- com.google.code.gson:gson:jar:2.2.4:compile
[INFO] +- com.sun.jersey:jersey-client:jar:1.18.1:compile
[INFO] | \- com.sun.jersey:jersey-core:jar:1.18.1:compile
[INFO] +- net.fckeditor:java-core:jar:2.6:compile
[INFO] | +- org.devlib.schmidt:imageinfo:jar:1.9:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.5.8:compile
[INFO] +- mysql:mysql-connector-java:jar:5.1.31:compile
[INFO] +- com.twilio.sdk:twilio-java-sdk:jar:3.3.15:compile
[INFO] | \- com.googlecode.json-simple:json-simple:jar:1.1:compile
[INFO] +- com.github.spullara.mustache.java:compiler:jar:0.8.15:compile
[INFO] | \- com.google.guava:guava:jar:16.0.1:compile
[INFO] +- commons-lang:commons-lang:jar:2.6:compile
[INFO] +- commons-io:commons-io:jar:2.4:compile
[INFO] +- commons-fileupload:commons-fileupload:jar:1.3.1:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.7:compile
[INFO] | \- log4j:log4j:jar:1.2.17:compile
[INFO] +- org.slf4j:slf4j-simple:jar:1.7.7:compile
[INFO] +- com.newrelic.agent.java:newrelic-agent:jar:3.5.1:provided
[INFO] +- com.sendgrid:sendgrid-java:jar:1.0.0:compile
[INFO] | +- org.json:json:jar:20140107:compile
[INFO] | \- com.mashape.unirest:unirest-java:jar:1.3.8:compile
[INFO] | \- org.apache.httpcomponents:httpasyncclient:jar:4.0.1:compile
[INFO] | \- org.apache.httpcomponents:httpcore-nio:jar:4.3.2:compile
[INFO] +- com.sendgrid:smtpapi-java:jar:0.0.2:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.3.3:compile
[INFO] | +- org.apache.httpcomponents:httpcore:jar:4.3.2:compile
[INFO] | +- commons-logging:commons-logging:jar:1.1.3:compile
[INFO] | \- commons-codec:commons-codec:jar:1.6:compile
[INFO] +- org.apache.httpcomponents:httpmime:jar:4.3.3:compile
[INFO] +- commons-validator:commons-validator:jar:1.4.0:compile
[INFO] | +- commons-beanutils:commons-beanutils:jar:1.8.3:compile
[INFO] | \- commons-digester:commons-digester:jar:1.8:compile
[INFO] +- org.eclipse.jetty.aggregate:jetty-all:jar:9.2.1.v20140609:compile
[INFO] | +- javax.websocket:javax.websocket-api:jar:1.0:compile
[INFO] | \- javax.servlet:javax.servlet-api:jar:3.1.0:compile
[INFO] +- org.eclipse.jetty:jetty-plus:jar:9.2.1.v20140609:compile
[INFO] | \- org.eclipse.jetty:jetty-jndi:jar:9.2.1.v20140609:compile
[INFO] +- org.eclipse.jetty:jetty-webapp:jar:9.2.1.v20140609:compile
[INFO] | \- org.eclipse.jetty:jetty-xml:jar:9.2.1.v20140609:compile
[INFO] +- org.eclipse.jetty:jetty-servlet:jar:9.2.1.v20140609:compile
[INFO] | \- org.eclipse.jetty:jetty-security:jar:9.2.1.v20140609:compile
[INFO] | \- org.eclipse.jetty:jetty-server:jar:9.2.1.v20140609:compile
[INFO] | +- org.eclipse.jetty:jetty-http:jar:9.2.1.v20140609:compile
[INFO] | \- org.eclipse.jetty:jetty-io:jar:9.2.1.v20140609:compile
[INFO] +- org.eclipse.jetty:jetty-util:jar:9.2.1.v20140609:compile
[INFO] +- org.eclipse.jdt:core:jar:3.3.0-v_771:compile
[INFO] | +- org.eclipse.core:resources:jar:3.3.0-v20070604:compile
[INFO] | | \- org.eclipse.core:expressions:jar:3.3.0-v20070606-0010:compile
[INFO] | +- org.eclipse.core:runtime:jar:3.10.0-v20140318-2214:compile
[INFO] | | +- org.eclipse:osgi:jar:3.10.0-v20140606-1445:compile
[INFO] | | +- org.eclipse.equinox:common:jar:3.6.200-v20130402-1505:compile
[INFO] | | +- org.eclipse.core:jobs:jar:3.6.0-v20140424-0053:compile
[INFO] | | +- org.eclipse.equinox:registry:jar:3.5.400-v20140428-1507:compile
[INFO] | | +- org.eclipse.equinox:preferences:jar:3.5.200-v20140224-1527:compile
[INFO] | | +- org.eclipse.core:contenttype:jar:3.4.200-v20140207-1251:compile
[INFO] | | \- org.eclipse.equinox:app:jar:1.3.200-v20130910-1609:compile
[INFO] | +- org.eclipse.core:filesystem:jar:1.1.0-v20070606:compile
[INFO] | \- org.eclipse:text:jar:3.3.0-v20070606-0010:compile
[INFO] | \- org.eclipse.core:commands:jar:3.3.0-I20070605-0010:compile
[INFO] +- net.integrio:tools:jar:1.0:compile
[INFO] +- xdo:xdocore:jar:1.0:compile
[INFO] +- net.integrio:integrio-db:jar:1.1:compile
[INFO] +- net.integrio:integrio-db-ext:jar:1.2:compile
[INFO] +- net.integrio:integrio-js:jar:1.3.0.6:compile
[INFO] +- net.integrio:integrio-json:jar:1.1:compile
[INFO] +- net.integrio:integrio-utils:jar:1.2:compile
[INFO] +- net.integrio:integrio-web-tags:jar:1.2:compile
[INFO] +- net.integrio:integrio-web:jar:1.2:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.3.2:compile
[INFO] \- javax.inject:javax.inject:jar:1:compile
答案 0 :(得分:1)
从技术角度来看,A无法想到会发生的事情。缺少内存会导致内存不足会导致NoSuchMethodError吗?
OutOfMemoryError
例外。即使某些东西“压扁”它们,对类加载的潜在损害也会导致异常,说该类无法加载......不是这个。
当您尝试加载某个类的不兼容版本时,会发生NoSuchMethodError
。具体来说,一个类调用第二个类的方法,并且该方法不再存在...在类加载器找到的类代码的版本中。
您应该检查在运行时使用的包含BuiltResponse
的JAR是否与构建代码的JAR相同。
这也可能是您正在使用的某些库之间的版本不匹配。
在没有启用后台进程的情况下,一切似乎都能正常工作,但是当我打开后台进程时,我的应用程序开始使用的内存超过分配的512MB而且我立即被NoSuchMethodErrors命中。
我怀疑额外的内存使用量是红鲱鱼。问题与后台进程代码及其依赖性有关。