2

I have a library (vraptor-test) that does unit testing at my webservices in my maven project. In onder to run these tests, this library starts an embedded Tomcat.

Tomcat tomcat = new Tomcat();

I have checked the dependency tree, and the list below representss tomcat related jars added to my project by the test library:

+- org.apache.tomcat:tomcat-catalina:jar:7.0.23:compile
[INFO] |  |  +- org.apache.tomcat:tomcat-servlet-api:jar:7.0.23:compile
[INFO] |  |  +- org.apache.tomcat:tomcat-juli:jar:7.0.23:compile
[INFO] |  |  +- org.apache.tomcat:tomcat-annotations-api:jar:7.0.23:compile
[INFO] |  |  +- org.apache.tomcat:tomcat-api:jar:7.0.23:compile
[INFO] |  |  \- org.apache.tomcat:tomcat-util:jar:7.0.23:compile
[INFO] |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:7.0.23:compile
[INFO] |  \- org.apache.tomcat:tomcat-jasper:jar:7.0.23:compile
[INFO] |     +- org.apache.tomcat:tomcat-jsp-api:jar:7.0.23:compile
[INFO] |     +- org.apache.tomcat:tomcat-el-api:jar:7.0.23:compile
[INFO] |     +- org.eclipse.jdt.core.compiler:ecj:jar:3.7:compile
[INFO] |     \- org.apache.tomcat:tomcat-jasper-el:jar:7.0.23:compile

When I run my test classes the error below pops up and the test doesn't even complete:

SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: PermGen space

Usually, I would make changes to setenv.bat under tomcat folder to increase the PermGem space, but, since I'm running an embedded Tomcat, I can't find its folder, only its jars.

I've tried increasing JVM memory in Eclipse (Window -> Preferences -> Java -> Installed JREs -> jdk -> Edit -> Default Vm Arguments) to -Xmx1024M -Xms1024M -XX:PermSize=2048m -XX:MaxPermSize=2048m but I'm still getting the same error.

Where can I change permgem space of my embedded tomcat?

Bruno Gasparotto
  • 671
  • 12
  • 31

1 Answers1

2

Double-click on your Tomcat service under the Servers tab, and click on the "Open launch configuration" to open the Tomcat launch configuration window. Then, in their change your VM args (different from default VM args).

EDIT: If you are running a JAR from a Junit Test, you will need to change the VM Arguments in the Junit Launch configruation. You can view your Run/Debug launch configs and then edit the arguments tab.

stevebot
  • 23,275
  • 29
  • 119
  • 181
  • 2
    Are you sure there is a Tomcat service if the OP is using an embedded tomcat and starting it from the unit test? I'd say he should set those vm arguments in the run configuration of the test environment, similar approach different location. :) – Thomas Apr 03 '14 at 14:56
  • @stevebot, I do have the Tomcat service you meant, but it refers to another Tomcat (download my self, so I know the installation folder). I don't think that this is the case, but I've tried anyway and got the same error. – Bruno Gasparotto Apr 03 '14 at 14:59
  • @Thomas, could you give me an explanation of how do I set the vm arguments of the test environment? I mean, the embedded Tomcat. – Bruno Gasparotto Apr 03 '14 at 15:00
  • 1
    @BrunoGasparotto look in your config (Run configuration) there you will see Junit. This is right under "Run" when right clicking on the project. – stevebot Apr 03 '14 at 15:02
  • 1
    @BrunoGasparotto as stevebot already said, open your run configuration under _Run->Run Configurations...->JUnit->Your Config_ and then set the arguments in the _Arguments_ tab. – Thomas Apr 03 '14 at 15:04
  • Did the change as you guys said and the error is gone. Thank you very much. – Bruno Gasparotto Apr 03 '14 at 15:11