我正在Jenkins构建服务器上构建Maven Java应用程序.我java.lang.OutOfMemoryError: PermGen space在Jenkins构建期间遇到了很多次(但从未在我的localhost上),因此它无法构建.
我已经尝试过设置MAVEN_OPTSJenkins:我进入了Jenkins- > Manage Jenkins- > Configure system- > Global MAVEN_OPTS并且设置为-Xms512m -Xmx1024m -XX:MaxPermSize=512m -XX:PermSize=512m.尽管将其设置为这个高价值,我们仍然会遇到PermGen空间问题.我不想将MAVEN_OPTS设置为更高的值; 我不知道我的应用程序如何需要一个空间,我宁愿深入研究高内存使用问题.
最近,我一直在想,也许permgen空间问题不是来自Maven本身,而是来自Maven旋转的JVM进程之一(例如:插件).我提出这个假设,因为Maven仍然能够执行TestNG测试,尽管已经吐出了我们的permgen空间错误线.导致PermGen错误的一个这样的插件是Jetty:
Oct 31, 2012 7:55:37 AM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: handle failed
java.lang.OutOfMemoryError: PermGen space
Run Code Online (Sandbox Code Playgroud)
因此,我想知道:
该MAVEN_OPTS变量是否也适用于Maven构建旋转的子JVM进程?如果没有,那么如何为这些子进程(如Jetty)设置JVM选项?
注意:我使用的是Maven 3.0.4.
当我运行maven-jetty-plugin时,我运行下一个命令:
mvn -DMAVEN_OPTS="-Xmx1024m -Xms512m" -Djetty.port=8080 jetty:run
Run Code Online (Sandbox Code Playgroud)
但是当我尝试输出自由堆大小时
Long heapFreeSize = Runtime.getRuntime().freeMemory();
Run Code Online (Sandbox Code Playgroud)
它总是输出大约30000000的东西.
我想它的大小以字节为单位,所以大约30兆字节.
为什么免费堆内存没有增加?
我正在使用Maven,Selenium和Jetty进行集成测试.测试执行正常,但是当服务器关闭时,Jetty服务器会抛出一个java.lang.ClassNotFoundException: org.codehaus.groovy.runtime.dgm$371.这是完整的堆栈跟踪:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.main.SeleniumHelloWorldExampleIT
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 13.479 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- selenium-maven-plugin:2.3:stop-server (stop-selenium) @ MySampleWebApp ---
Stopping Selenium server...
00:28:55,976 INFO [org.openqa.jetty.util.Credential] Checking Resource aliases
00:28:55.983 INFO - Command request: shutDownSeleniumServer[, ] on session null
00:28:55.989 INFO - Shutdown command received
00:28:55.992 INFO - Got result: OK on session null
00:28:55.994 …Run Code Online (Sandbox Code Playgroud) 我正进入(状态
java.lang.ClassNotFoundException: org.apache.jasper.runtime.JspApplicationContextImpl
Run Code Online (Sandbox Code Playgroud)
使用jetty时:在web项目上运行插件.
在处理某些问题时,问题只发生在某些机器上!
使用的Java版本:7 Maven版本:3.1
相关的依赖项和插件: -


上下文和设置信息:
问题描述
在Spring的JavaConfig用于引导Spring上下文而不是使用a的项目中,启动jetty 9非常慢web.xml.Jetty似乎在适当的时间内无所事事.这发生在以下行之后:
INFO:oejs.Server:main: jetty-9.2.3.v20140905
Jetty确实最终开始,但与常规的tomcat 7发行版相比,启动需要很长时间.
其他资源
public class DispatcherServletInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
//implementation
}
Run Code Online (Sandbox Code Playgroud) 为了轻松运行我的webapp,我决定将Jetty添加到我的单个POM文件中.
在官方文档之后,我将此添加到我的<plugins>:
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.0-SNAPSHOT</version>
</plugin>
Run Code Online (Sandbox Code Playgroud)
问题:mvn jetty:run失败:
$ mvn jetty:start
[INFO] Scanning for projects...
[WARNING] The POM for org.eclipse.jetty:jetty-maven-plugin:jar:9.4.0-SNAPSHOT is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.eclipse.jetty:jetty-maven-plugin:9.4.0-SNAPSHOT: Plugin org.eclipse.jetty:jetty-maven-plugin:9.4.0-SNAPSHOT or one of its dependencies could not be resolved: Could not find artifact org.eclipse.jetty:jetty-maven-plugin:jar:9.4.0-SNAPSHOT
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml (13 KB at 2.1 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml (20 KB at 3.2 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD …Run Code Online (Sandbox Code Playgroud) 我正在尝试分析使用mvn jetty:runVisualVM 1.3.6 执行的Java 7应用程序.CPU显示为不可用,配置文件选项卡列出以下错误:
WARNING! Class sharing is enabled for this JVM. This can cause problems when profiling the application and eventually may crash it. Please see the VisualVM Troubleshooting Guide for more information and steps to fix the problem: https://visualvm.java.net/troubleshooting.html#xshare.
Run Code Online (Sandbox Code Playgroud)
我可以正常配置任何其他应用程序.
VisualVM日志多次显示以下错误:
java.io.IOException: Unable to open socket file: target process not responding or HotSpot VM not loaded
Run Code Online (Sandbox Code Playgroud)
可能相关的细节:
- OSX 10.8.3
- 在JDK 1.7u25下运行的app和VisualVM
我可以假设downvotes与这样一个事实有关,即有一个与此问题相关的文档错误以及设置的建议Xshare:off,我将包含此错误报告的链接,该报告在1.6u6之后将其列为已修复.我正在运行1.7u25,所以这不适用于我.
我正在Hello World使用servlet-3.1运行一个简单的Web应用程序,在jdk-8上运行jetty-9并使用.maven-jetty-plugin
public class HelloWorldServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
try {
String message = "Hello Jetty From the HelloWorldServlet";
OutputStream stream = response.getOutputStream();
stream.write(message.getBytes());
stream.flush();
} catch (IOException ex) {
Logger.getLogger(HelloWorldServlet.class.getName()).log(Level.SEVERE, null, ex);
}
}
Run Code Online (Sandbox Code Playgroud)
并在web.xml文件中很好地映射:
<servlet>
<servlet-name>hello</servlet-name>
<servlet-class>org.tarrsalah.jetty.example.HelloWorldServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>hello</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
Run Code Online (Sandbox Code Playgroud)
但是看起来jetty在运行mvn jetty时无法完成我的servlet类:run,我在这里缺少什么?
--- jetty-maven-plugin:9.1.3.v20140225:run (default-cli) @ jetty-example ---
2014-04-02 10:09:46.126:INFO::main: Logging initialized @12796ms
Configuring Jetty for project: jetty-example …Run Code Online (Sandbox Code Playgroud) 我在使用eclipse中的maven jetty插件快速启动webapp时遇到了问题.我正在使用码头:跑步目标.
打开日志记录后,问题似乎是jetty扫描我的webapp中的所有jar文件以进行Web应用程序配置.只是包含一个依赖项jersey-media-moxy导致jetty在其启动时间增加48秒.
如何在jetty-maven-plugin中限制此扫描?我发现由于扫描导致Jetty启动延迟,但在我进行一些外部jetty配置之前,包括这是maven配置,我想确保没有更简单的选择.
http://eclipse.org/jetty/documentation/current/quickstart-webapp.html看起来很有希望,但我不确定如何继续(因为这也没有提到maven插件).
我的pom.xml文件包含在下面:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.my-app</groupId>
<artifactId>my-app</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>my-app</name>
<build>
<finalName>my-app</finalName>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.9.v20150224</version>
<configuration>
<war>${project.basedir}/target/my-app.war</war>
<stopPort>8088</stopPort>
<stopKey>foo</stopKey>
<stopWait>10</stopWait>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<!-- artifactId>jersey-container-servlet-core</artifactId -->
<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<artifactId>jersey-container-servlet</artifactId>
</dependency> …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用JSF和Weld CDI配置Jetty.按照本手册后,我偶然发现了以下堆栈跟踪:
Caused by: java.lang.IllegalStateException: Singleton not set for STATIC_INSTANCE => []
at org.jboss.weld.bootstrap.api.helpers.RegistrySingletonProvider$RegistrySingleton.get(RegistrySingletonProvider.java:28)
at org.jboss.weld.Container.instance(Container.java:55)
at org.jboss.weld.SimpleCDI.<init>(SimpleCDI.java:77)
at org.jboss.weld.environment.WeldProvider$EnvironmentCDI.<init>(WeldProvider.java:45)
at org.jboss.weld.environment.WeldProvider.getCDI(WeldProvider.java:61)
at javax.enterprise.inject.spi.CDI.current(CDI.java:60)
at org.jboss.weld.servlet.WeldInitialListener.contextInitialized(WeldInitialListener.java:94)
at org.jboss.weld.servlet.api.helpers.ForwardingServletListener.contextInitialized(ForwardingServletListener.java:34)
at org.jboss.weld.environment.servlet.EnhancedListener.onStartup(EnhancedListener.java:65)
at org.eclipse.jetty.plus.annotation.ContainerInitializer.callStartup(ContainerInitializer.java:140)
at org.eclipse.jetty.annotations.ServletContainerInitializersStarter.doStart(ServletContainerInitializersStarter.java:63)
... 50 more
Run Code Online (Sandbox Code Playgroud)
有人看到这里出了什么问题吗?