關於eclipse環境啓動不成功的問題解決方法

常信息補充:java

 

Caused by: javassist.CannotCompileException: by java.lang.OutOfMemoryError: PermGen space
       at javassist.ClassPool.toClass(ClassPool.java:1099)
       at javassist.CtClass.toClass(CtClass.java:1265)
       at com.taobao.hsf.bytecode.ClassGenerator.toClass(ClassGenerator.java:293)
       ... 37 more
Caused by: java.lang.OutOfMemoryError: PermGen space
       at java.lang.ClassLoader.defineClass1(Native Method)
       at java.lang.ClassLoader.defineClassCond(Unknown Source)
       at java.lang.ClassLoader.defineClass(Unknown Source)
       at sun.reflect.GeneratedMethodAccessor68.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at javassist.ClassPool.toClass2(ClassPool.java:1112)
       at javassist.ClassPool.toClass(ClassPool.java:1093)
       at javassist.CtClass.toClass(CtClass.java:1265)web

 

在 VM arguments中添加配置:-Xms256m -Xmx512m -XX:PermSize=128M -XX:MaxNewSize=128m -XX:MaxPermSize=256mspring

 

另外的博客apache

http://qingyuexiao.iteye.com/blog/1886059tomcat

 

以前使用tomcat7時遇到啓動報錯問題,日誌以下: 

嚴重: ContainerBase.addChild: start: 
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/mypro]] 
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) 
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) 
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) 
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) 
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1114) 
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1673) 
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) 
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) 
at java.util.concurrent.FutureTask.run(FutureTask.java:138) 
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 
at java.lang.Thread.run(Thread.java:619) 
Caused by: java.lang.IllegalStateException: Unable to complete the scan for annotations for web application [/mypro]. Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies 
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2109) 
at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1981) 
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1947) 
at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1932) 
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1326) 
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878) 
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:369) 
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) 
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) 
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5179) 
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
... 11 more 
Caused by: java.lang.StackOverflowError 
at java.util.HashMap.get(HashMap.java:300) 
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2257) 
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269) 
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269) 
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269) 
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269) 
at org.apache.catalina.startup.ContextConfig.populateSCIsForCacheEntry(ContextConfig.java:2269) 
…… 

在網上找了好久,最終解決問題,在這時MARK一下。如下是解決方法: 

--------------------------------------------------如下文章爲轉載-------------------------------------------------- 

使用tomcat 7.0.3x版本的同窗能夠發現tomcat啓動慢了很多,並且還可能遇到以下啓動時異常: 

Unable to complete the scan for annotations for web application [] due to a StackOverflowError. Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies. 

tomcat7.0.3X版本支持servlet3.0的特性,好比說支持@WebServlet、@WebListener,要支持這些特性,tomcat就得去掃描全部的jar包裏面的每一個類。這個異常代表在掃描jar包的時候,遞歸調用太深,致使棧溢出了,tomcat給了一個餿主意,讓你增大xss,這個仍是很差,xss加大了,可用線程數就少了。 

分析tomcat源代碼,發現它掃描的流程以下: 

1.掃描全部jar包 

2.經過查找jar包中META-INF/services/javax.servlet.ServletContainerInitializer文件內的定義,初始化ServletContainerInitializer實現 

3.若是web.xml中配置了metadata-complete="true" 或者沒有找到ServletContainerInitializer實現,都不會繼續掃描jar包 

網上大多數的答案的都是說在web.xml中加入了metadata-complete="true"就能避免這個異常。確實在不少場景下,這個異常是可以避免。可是使用spring-web-3.1.0.RELEASE的同窗就杯具了,這個jar包中定義了一個ServletContainerInitializer,仍是致使了掃描jar包。 

咱們能夠用另外的辦法來解決這個問題,咱們讓tomcat不掃描指定的jar包,tomcat就要輕鬆得多了,org.apache.tomcat.util.scan.StandardJarScanner中定義了defaultJarsToSkip,有了這個東東,咱們就能夠跳過某些jar包。 

若是你不想使用servlet3.0 annotation支持,在tomcat的catalina.properties配置文件中tomcat.util.scan.DefaultJarScanner.jarsToSkip的值後面加一個",*",這樣就不會掃描全部的jar包了。啓動更快,也不會出異常。 


tomcat在處理掃描是還有個小bug,好比我遇到了 

SEVERE: Unable to process Jar entry [__MACOSX/cn/****/._HandlerFactory.class] from... 

這是tomcat在掃描到以.class爲後綴的文件後,就分析類,很明顯,此文件都不是java類文件。tomcat不該該只判斷後綴爲.class就是java類文件。 app

相關文章
相關標籤/搜索