我编写了一个Java Spring-WS-Application服务器,并尝试使用maven从命令行部署它。但是,在尝试执行“mvn clean package”时,它告诉我由于缺少堆空间而无法创建Java虚拟机。我的电脑只有4GB的RAM,可悲的是运行32位窗口。只要我包含-DskipTests,部署就会成功。
这个项目依赖于我的团队编写的其他项目,我可以使用“mvn clean install”部署它们,没有任何问题。我也可以没有问题地部署其他服务器,所以我认为我的java版本没有损坏。此外,我的开发团队的其他成员已经能够在他们的计算机上成功部署此服务器。
我也经历过并注释掉所有@Test注释以尝试并找到错误测试,但是当没有测试要运行时它仍会给我这个错误。
有关为何可能发生这种情况的任何想法?
Java版:
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) Client VM (build 23.21-b01, mixed mode, sharing)
“mvn clean package:”
的结果 C:\workspace\My-Project>mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building My Project Spring-WS Application 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ my-project ---
[INFO] Deleting C:\workspace\My-Project\target
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ my-project ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\workspace\My-Project\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.0:compile (default-compile) @ my-project ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 49 source files to C:\workspace\My-Project\target\classes
[WARNING] Note: C:\workspace\My-Project\src\main\java\my\package\of\doom\impl\classImpl.java uses or overrides a
deprecated API.
[WARNING] Note: Recompile with -Xlint:deprecation for details.
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ my-project ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.0:testCompile (default-testCompile) @ my-project ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 25 source files to C:\workspace\My-Project\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.14:test (default-test) @ my-project ---
[INFO] Surefire report directory: C:\workspace\My-Project\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Error occurred during initialization of VM
Could not create the Java virtual machine.
Could not reserve enough space for object heap
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.783s
[INFO] Finished at: Thu Jun 13 09:01:15 EDT 2013
[INFO] Final Memory: 14M/54M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.14:test (default-test) on project my-pro
ject: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.14:test failed: The fo
rked VM terminated without saying properly goodbye. VM crash or System.exit called ?
[ERROR] Command wascmd.exe /X /C "C:\Oracle2\Middleware\jdk160_24\jre\bin\java -Xms512m -Xmx1024m -XX:MaxPermSize=512m -
jar C:\workspace\My-Project\target\surefire\surefirebooter4008500116671254841.jar C:\workspace\My-Project\target\surefir
e\surefire8598565507069545685tmp C:\workspace\My-Project\target\surefire\surefire_07977292658698847040tmp"
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
的eclipse.ini:
-vm
C:/Oracle2/Middleware/jdk160_24/bin/javaw
-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502
-showsplash
org.eclipse.platform
--launcher.defaultAction
openFile
-vmargs
-Xms512m
-Xmx1024m
-XX:MaxPermSize=512m
-Dsun.lang.ClassLoader.allowArraySyntax=true
答案 0 :(得分:1)
仔细查看错误消息。它说测试JVM的堆没有足够的内存。尝试释放一些内存(关闭Eclipse)和/或以较低的堆/ perm gen大小运行测试(surefire设置)。