AbstractTransactionalJUnit4SpringContextTests

时间:2011-04-18 16:30:38

标签: hibernate spring testing maven junit

我使用AbstractTransactionalJUnit4SpringContextTests作为我的测试类的超类。

但“mvn test”内存不足。

以下是我的BaseTest类的片段:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations=
    {"classpath:**/applicationContext.xml",
     "classpath:**/simple-test-datasource.xml"})
@TransactionConfiguration(
     transactionManager="myService.transactionManager",defaultRollback=true)
public class ServiceBaseTest extends AbstractTransactionalJUnit4SpringContextTests{

----

}

我错过了@Before @After@BeforeClass @AfterClass这些测试真的很重的问题,因此我的内存不足了吗?

请帮忙!

谢谢!

这是堆栈跟踪:

java.lang.OutOfMemoryError: PermGen space
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at com.apple.crypto.provider.Apple.doSelfVerification(Apple.java:271)
at com.apple.crypto.provider.Apple.verifySelfIntegrity(Apple.java:192)
at com.apple.crypto.provider.HmacCore.<init>(HmacCore.java:45)
at com.apple.crypto.provider.HmacSHA1.<init>(HmacSHA1.java:30)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at java.security.Provider$Service.newInstance(Provider.java:1221)
at javax.crypto.Mac.a(DashoA13*..)
at javax.crypto.Mac.init(DashoA13*..)
at org.springframework.security.oauth.common.signature.HMAC_SHA1SignatureMethod.verify(HMAC_SHA1SignatureMethod.java:122)
at org.springframework.security.oauth.provider.OAuthProviderProcessingFilter.validateSignature(OAuthProviderProcessingFilter.java:261)
at org.springframework.security.oauth.provider.OAuthProviderProcessingFilter.doFilter(OAuthProviderProcessingFilter.java:146)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.oauth.provider.OAuthProviderProcessingFilter.doFilter(OAuthProviderProcessingFilter.java:193)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:277)

2 个答案:

答案 0 :(得分:2)

您似乎通过ContextConfiguration批注将整个Spring应用程序上下文加载到内存中。这可能会占用大量内存,具体取决于您定义的bean。

尝试通过在您的环境中设置M2_OPTS=-Xmx256m来增加JVM可用的内存。

答案 1 :(得分:1)

堆栈跟踪是关于perm gen内存而不是堆。所以请尝试增加每代内存,例如-XX:MaxPermSize = 1024M