您的位置:首页 > 运维架构 > Tomcat

java.lang.OutOfMemoryError: PermGen space 原因 解决方案 tomcat 6

2010-04-23 11:05 483 查看

原因:

PermGen space的全称是Permanent Generation space,是指内存的永久保存区域,这块内存主要是被JVM存放Class和Meta信息的,Class在被Loader时就会被放到PermGen space中,它和存放类实例(Instance)的Heap区域不同,GC(Garbage Collection)不会在主程序运行期对PermGen space进行清理,所以如果你的应用中有很CLASS的话,就很可能出现PermGen space错误,这种错误常见在web服务器对JSP进行pre compile的时候。如果你的WEB APP下都用了大量的第三方jar, 其大小超过了jvm默认的大小(4M)那么就会产生此错误信息了。

解决方法: 手动设置MaxPermSize大小

修改TOMCAT_HOME/bin/catalina.sh
在“echo "Using CATALINA_BASE: $CATALINA_BASE"”上面加入以下行:
JAVA_OPTS="-server -XX:PermSize=64M -XX:MaxPermSize=128m
建议:将相同的第三方jar文件移置到tomcat/shared/lib目录下,这样可以达到减少jar 文档重复占用内存的目的。(如tomcat 版本为6请看下文,主要看黑体部分)

Deploy Alfresco Share on Tomcat 6

As I could not find a complete tutorial on how to deploy Afresco Share on an existing Apache Tomcat version 6 I’ll now summarize all steps required.

Prerequisites

Before following the next steps make sure you have

Java 1.5 or Java 1.6

Apache Tomcat 6.x

MySQL 5.x

installed.

Step 1: Get Alfresco Community Edition


Download the file archive
alfresco-community-war-3.2.tar.gz
and unpack the archive. It contains the
alfresco.war
and
share.war
web applications that you’ll need to get Alfresco Share up and running.

Step 2: Create database and database user

On Mac OS/Linux open a shell, on Windows open the command line. Log on to MySQL with the root user:

> mysql -u root -p


Next, create the database and a user for Alfresco and grant the according rights to the database user:

mysql> create database alfresco default character set utf8;
mysql> create user alfresco identified by 'alfresco';
mysql> grant all on alfresco.* to 'alfresco'@'localhost' identified by 'alfresco' with grant option;
mysql> grant all on alfresco.* to 'alfresco'@'localhost.localdomain' identified by 'alfresco' with grant option;


Step 3: Prepare Apache Tomcat

Make sure that your Tomcat installation disposes of the directories
<TOMCAT_HOME>/shared/classes
and <
TOMCAT_HOME>/shared/lib
. Tomcat 6 does not get distributed with these directories by default. If they are missing, please create them. Next, open the file
<TOMCAT_HOME>/conf/catalina.properties
and change the value of
shared.loader=
to:


shared.loader=${catalina.home}/shared/classes,${catalina.home}/shared/lib/*.jar


That way, Tomcat loads for all web applications any classes/property files and libraries that are located in these directories.

Alfresco does not get shipped with a JDBC driver for MySQL. You can download the current driver from http://dev.mysql.com/downloads/connector/j/5.1.html. Unpack the archive and copy the driver
mysql-connector-java-5.1.12-bin.jar
(at the time of writing this post this driver was the current one) to
<TOMCAT_HOME>/shared/lib
.

Copy from your dowloaded unpacked
alfresco-community-war-3.2.tar.gz
archive the file
<ALFRESCO_ARCHIVE>/extensions/extension/alfresco-global.properties
to
<TOMCAT_HOME>/shared/classes
. Open the file
alfresco-global.properties
and change the value of
db.driver=
to (line 29):

db.driver=com.mysql.jdbc.Driver


Before we can start deploying Alfresco, make sure your Tomcat installation has a configured heap size of at least 256 MB. By default, Tomcat is started with the default heap size of your JVM. Usually, with these default settings the deployment of Alfresco will fail.

To increase Tomcat’s heap size on a Unix/Linux system open the file
<TOMCAT_HOME>/bin/startup.sh
and add following line at the beginning of the file:


export CATALINA_OPTS="-Xms256m -Xmx512m -XX:MaxPermSize=196m"


On Windows based systems open the file
<TOMCAT_HOME>/bin/startup.cmd
and add the following line at the beginning of the file:


set CATALINA_OPTS="-Xms256m -Xmx512m -XX:MaxPermSize=196m"


In case Tomcat was running you have to restart it in order the heap size changes take effect.

Step 4: Deploy Alfresco web applications

Start Tomcat by executing the start script
<TOMCAT_HOME/bin/startup.sh
(Unix/Linux systems) or
<TOMCAT_HOME/bin/startup.cmd
(Windows systems).

Simply copy the file
<ALFRESCO_ARCHIVE>/alfresco.war
to
<TOMCAT_HOME>/webapps
. As long as you have not changed Tomcat’s default deploy settings, Tomcat will deploy the web archive automatically. Have a look at Tomcat’s logfile located at
<TOMCAT_HOME>/logs/catalina.out
. At the end of the log file there should be an entry similar to

18:52:46,528 User:System INFO  [service.descriptor.DescriptorService] Alfresco started (Community): Current version 3.2.0 (2039) schema 2019 - Installed version 3.2.0 (2039) schema 2019


Next, copy the file
<ALFRESCO_ARCHIVE>/share.war
to
<TOMCAT_HOME>/webapps
. At the end of the Tomcat’s log file you should see an entry like

23:56:58,258  INFO  [web.site.FrameworkHelper] Successfully Initialized Web Framework


Well done, we are finished. Let’s open Alfresco Share in your favorite browser. Therefore, type
http://localhost:8080/share
in the address bar. You should the see the following screen:



Login with username
admin
and password
admin
.
The document http://wiki.alfresco.com/w/images/d/de/Getting_Started_with_Share_for_Alfresco_Community_Edition_3_2.pdfwill help you to get acquainted with Alfresco Share. Have fun!

如有疑问:留言解答
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐