OpenCMS 9.0 with TomEE 1.6 Web Profile#
OpenCms Home | General OpenCms Wiki | OpenCMS Development | OpenCms 9.0.1 Upgrade | OpenCms 10.0.1 Upgrade
Preface#
- My task was to create a website where the content can be edited by non-technical authors. Therefore I searched for a content management system (CMS). The most public ones like Wordpress, Joomla and Typo3 are certainly a good choice, but I prefer Java (and a JavaEE stack) over PHP. Additionally I have some other WebApps which I wanted to integrate in the same web server. My choice was OpenCMS due to good reputations and nice looking reference sites.
- Though I may do in future I don't wanted to dive into development (templates), but wanted to create a website quickly. So my first approach, which I describe here, is a quick and dirty solution!
- MySQL is up and running (apt-get install mysql-server)
URLS:
- Login: http://localhost:8080/opencms/opencms/system/login/
- Site: http://localhost:8080/opencms/opencms/<sitename> (/sites/default/ will be omitted !!!)
- Workplace: http://localhost:8080/opencms/opencms/system/workplace/views/workplace.jsp
See also general infos about TomEE.
Inhaltsverzeichnis
- OpenCMS 9.0 with TomEE 1.6 Web Profile
- Preface
- 1. Update Java JDK
- 2. Install TomEE
- 3. Configure TomEE
- 4a. Prepare OpenCMS
- 4b Fix logging problem in OpenCMS
- 5. Start TomEE
- 6. Deploy OpenCMS
- 7. Fix OpenCMS setup error
- 8. Setup OpenCMS
- 9. OpenCMS Security
- 10. Optional: Install a second instance of OpenCMS
- 11. Adjust Workplace settings
- 12. Switch start page for the web server
- 13 Own icon at the Url (Favicon)
- 14. Change locale from en to de (switch language)
- 15. Skinndriva
- 16. Removing "/opencms/opencms" prefix
- 17. Bootstrap Demo Color Theme
- 18. org.opencms.file.CmsVfsResourceNotFoundException
- 19. Edit tips
- 20. Reset password
1. Update Java JDK#
Option 1 (Ubuntu 10): Install via package manager - DID NOT WORK FOR ME, see Option 2! (this is just as reference)- Show installed Java packages
> update-java-alternatives -l
- Check 32 or 64bit System?
> uname -m ==> output example: x86_64
- Additionally you may want to check linux Version
> uname -a ==> output example: Linux euve2798 2.6.18-028stab107.2 #1 SMP Mon Jul 1 21:48:35 MSD 2013 x86_64 GNU/Linux (Ubuntu 10.04 minimal )
- Delete old Version 6
> apt-get purge openjdk-6-*
- Add special repository source
> add-apt-repository ppa:openjdk/ppa
- Update package cache
> apt-get update
- Check new package is in list
> apt-cache search openjdk-7*
- Install
> apt-get install openjdk-7-jdk openjdk-7-doc openjdk-7-jre-lib=> Results in problem with dependencies, which I could not solve (?)
Option 2: Install manually
- Download JDK
- Configure (example for jdk-7u45-linux-x64.tar.gz):
> tar -xzvf jdk-7u45-linux-x64.tar.gz > mkdir /usr/java > cp -r jdk1.7.0_45 /usr/java > ln -s /usr/java/jdk1.7.0_45 /usr/java/jdkx > ln -s /usr/java/jdkx /usr/java/latest > ln -s /usr/java/latest /usr/java/default > ln -s /usr/java/default/bin/java /usr/bin/java > ln -s /usr/java/default/bin/javac /usr/bin/javac > ln -s /usr/java/default/bin/javah /usr/bin/javah > ln -s /usr/java/default/bin/javadoc /usr/bin/javadoc > ln -s /usr/java/default/bin/javaws /usr/bin/javaws
- Set java home
JAVA_HOME=/usr/java/jdk1.7.0_45;export JAVA_HOME
- Reboot necessary !
/markus/tomee/bin/catalina.sh: line 392: /usr/java/jdk1.7.0_45/bin/java: No such file or directory
Option 3 with Ubuntu 12.04
apt-get install openjdk-7-jre-headless JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64;export JAVA_HOME
- Check
java -version ==> output example java version "1.7.0_45" Java(TM) SE Runtime Environment (build 1.7.0_45-b18) Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
2. Install TomEE#
> wget http://mirrors.ae-online.de/apache/tomee/tomee-1.6.0/apache-tomee-1.6.0-webprofile.tar.gz > gunzip > tar xvf *
3. Configure TomEE#
- Edit port in <tomee_home>/conf/server.xml
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
- Edit <tomee_home>/conf/tomcat-users.xml to enable services
<role rolename="tomcat"/> <role rolename="admin-gui"/> <role rolename="admin-script"/> <role rolename="manager-gui"/> <role rolename="manager-status"/> <role rolename="tomee-admin"/> <user username="youruser" password="your_long_password" roles="tomcat,tomee-admin,manager-gui,manager-status,admin-script,admin-gui"/>
- Edit <tomee_home>/webapps/manager/WEB-INF/web.xml to enable deployment of large war files (like OpenCMS). Otherwise you get this error:
org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (119990388) exceeds the configured maximum (52428800)Default is 52428800 = 50 MB * 1024 * 1024.
Change to 125829120 = 120 MB:
<multipart-config> <!-- 120MB max --> <max-file-size>125829120</max-file-size> <max-request-size>125829120</max-request-size> <file-size-threshold>0</file-size-threshold> </multipart-config>
- Add mysql connector lib to <tomee_home>/lib
mysql-connector-java-5.1.27-bin.jar
4a. Prepare OpenCMS#
See OpenCms installation- Download WAR file
> wget http://www.opencms.org/downloads/opencms/opencms-9.0.0.zip > unzip
- Enhance TomEE JAVA settings
Hint: Check memory usage under Tomcat Startpage > Server Status > JVM
==> example output: Free memory: 138.30 MB Total memory: 912.75 MB Max memory: 1776.00 MB
Edit bin/catalina.sh
You may either extend JAVA_OPTS or CATALINA_OPTS.
Here are some example settings
JAVA_OPTS="$JAVA_OPTS -server -Xms1024m -Xmx2048m -XX:MaxPermSize=512m -Djava.awt.headless=true -Dfile.encoding=UTF-8" JAVA_OPTS="$JAVA_OPTS -server -Xms1536m -Xmx1536m -XX:MaxPermSize=256m -Djava.awt.headless=true -Dfile.encoding=UTF-8" JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms1536m -Xmx1536m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC" export JAVA_OPTS="-Xms256m -Xmx512m -XX:MaxPermSize=128m" CATALINA_OPTS="-server -Xss1G -Xms2G -Xmx2G -XX:NewSize=1G -Xincgc $CATALINA_OPTS" -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled JAVA_OPTS=”-Xms128m -Xmx256m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000? -Xmx2048M -Xmx6144M -XX:PermSize=128m -XX:MaxPermSize=256m
- Enhance MySql
For OpenCms, the limit should be as high as possible, a setting of max_allowed_packet=32M is recommended.
Edit /etc/mysql/my.cnf
max_allowed_packet=32MIn Windows edit one of those
C:\Users\All Users\MySQL\MySQL Server 5.6\my.ini <mysql_home>\MySQL Server 5.6\my.ini
4b Fix logging problem in OpenCMS#
When you deploy OpenCMS like in Step 5 you get this error (see logs/catalina.out):org.apache.catalina.LifecycleException: An invalid Lifecycle transition was attempted ([before_destroy]) for component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/opencms]] in state [STARTING_PREP] at org.apache.catalina.util.LifecycleBase.invalidTransition(LifecycleBase.java:409) [...] SEVERE: Unable to deploy collapsed ear in war StandardEngine[Catalina].StandardHost[localhost].StandardContext[/opencms] org.apache.openejb.OpenEJBException: Creating application failed: /markus/tomee/webapps/opencms: org/apache/log4j/Priority at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:897) [...] Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Priority at org.apache.openjpa.lib.log.Log4JLogFactory.newLogAdapter(Log4JLogFactory.java:33) [...] Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Priority at java.net.URLClassLoader$1.run(URLClassLoader.java:366) [...]So somehow log4j is needed for deployment (and later for setup also)
So add log4j to <tomee_home>\lib
log4j-1.2.17.jar
5. Start TomEE#
- Add JAVA_HOME to <tomee_home>/bin/startup.sh
# Markus set javapath # old: JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk;export JAVA_HOME JAVA_HOME=/usr/java/jdk1.7.0_45;export JAVA_HOME } Start/Stop with {{{ ./statup.sh ./shutdown.shHint: Install a mail server also, see Postfix Installation
6. Deploy OpenCMS#
- Deploy war file with TomEE App Manager (http://www.your-domain.de/manager)
Context Path= /opencms War= /markus/opencms/opencms.war
7. Fix OpenCMS setup error#
27: Shutdown completed, total uptime was 00:04:42. 26: Shutting down OpenCms, version 9.0.0 in web application "opencms" 25: 24: 23: at org.opencms.setup.CmsSetupWorkplaceImportThread.run(CmsSetupWorkplaceImportThread.java:202) 22: at org.opencms.setup.CmsSetupWorkplaceImportThread.kill(CmsSetupWorkplaceImportThread.java:110) 21: at org.opencms.main.CmsShell.exit(CmsShell.java:571) 20: java.lang.NullPointerException 19: at org.opencms.setup.CmsSetupWorkplaceImportThread.run(CmsSetupWorkplaceImportThread.java:187) 18: at org.opencms.main.CmsShell.start(CmsShell.java:663) 17: at org.opencms.main.CmsShell.executeCommands(CmsShell.java:835) 16: at org.opencms.main.CmsShell.executeCommand(CmsShell.java:760) 15: ${user}@${project}>java.lang.NullPointerException 14: ${user}@${project}># Turn echo on 13: at org.opencms.setup.CmsSetupWorkplaceImportThread.run(CmsSetupWorkplaceImportThread.java:148) 12: at org.opencms.main.CmsShell.<init>(CmsShell.java:447) 11: at org.opencms.main.OpenCmsCore.upgradeRunlevel(OpenCmsCore.java:1964) 10: at org.opencms.main.OpenCmsCore.initConfiguration(OpenCmsCore.java:1078) 9: at org.opencms.configuration.CmsConfigurationManager.loadXmlConfiguration(CmsConfigurationManager.java:335) 8: at org.opencms.configuration.CmsConfigurationManager.loadXmlConfiguration(CmsConfigurationManager.java:494) 7: at org.opencms.configuration.CmsWorkplaceConfiguration.addXmlDigesterRules(CmsWorkplaceConfiguration.java:997) 6: at org.apache.commons.digester.Digester.addRule(Digester.java:1975) 5: at org.opencms.configuration.CmsSetNextRule.setDigester(CmsSetNextRule.java:397) 4: java.lang.LinkageError: loader constraint violation: when resolving method "org.apache.commons.digester.Digester.setLogger(Lorg/apache/commons/logging/Log;)V" the class loader (instance of org/apache/tomee/catalina/LazyStopWebappClassLoader) of the current class, org/opencms/configuration/CmsSetNextRule, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, org/apache/commons/digester/Digester, have different Class objects for the type ns/logging/Log;)V used in the signature 3: 2: OpenCms property file: "/markus/tomee/tomee_wp16/webapps/opencms/WEB-INF/config/opencms.properties". 1: OpenCms WEB-INF path: "/markus/tomee/tomee_wp16/webapps/opencms/WEB-INF/".
- Delete commons-logging-1.1.1.jar from webapps/opencms/WEB-INF/lib
- Optional: replace commons-logging-1.1.1.jar with commons-logging-1.1.3.jar in <tomee_home>\lib folder
Hint: If you need to run OpenCMS setup again (see below)then change /webapps/opencms/WEB-INF/config/opencms.properties
wizard.enabled=true
8. Setup OpenCMS#
NOTE: Check capter 10 if you have an instance already!!!http://<www.your-domain.de>/opencms/setup
Enter the URL of your Alkacon OpenCms site | http://your-domain.de | The OpenCms site URL: Alkacon OpenCms is capable of managing multiple sites. However, the OpenCms Workplace must always be accessed through one specific URL. The site URL you enter here will be used both as URL to access the Workplace, and as URL for the default site. In case you want to add other sites, or if you want to use different URLs for default site and Workplace, you must manually edit the opencms-system.xml file after the installation. |
Enter a name for your Alkacon OpenCms server | OpenCmsServer | This server name will be used for various log messages in OpenCms. This can be handy if you have to compare logfiles from a couple of different servers. |
Finally: http://<www.your-domain.de>/opencms/opencms
9. OpenCMS Security#
Change the Admin user password- Login http://<www.your-domain.de>/opencms/opencms/system/login
- Maybe reload of page is necessary (Strg+R or F5)
- Menu > Workplace > View=Administration > Account Management > User Management
10. Optional: Install a second instance of OpenCMS #
You can use that one as reference and play around in the first one.- Deploy it again in another context, but with adjusting opencms.properties. Otherwise you overide the database of your first instance! In this example we use "OpenCMSOrig" instead of "OpenCMS".
- Deploy WAR file again (compare previous steps)
Context Path (required): /opencmsOrig WAR or Directory URL: D:\lang\cms\opencms-9.0.0\opencms.war
- Shutdown tomee
- Delete again webapps\opencmsOrig\WEB-INF\lib\commons-logging-1.1.1.jar
- Edit webapps\opencmsOrig\WEB-INF\config\opencms.properties
# the URL to make the JDBC DriverManager return connections from the DBCP pool db.pool.default.poolUrl=opencmsOrig:default [...] db.project.driver= db.project.pool=opencmsOrig:default db.project.sqlmanager= db.user.driver= db.user.pool=opencmsOrig:default db.user.sqlmanager= db.history.driver= db.history.pool=opencmsOrig:default db.history.sqlmanager= db.subscription.driver= db.subscription.pool=opencmsOrig:default db.subscription.sqlmanager=
- Restart tomee
- Setup again http://www.your-domain.de/opencmsOrig/setup
- Choose databasename = openCmsOrig
11. Adjust Workplace settings#
Change admin language and list optionsMenu > Workplace > Preferences > Workplace Tab > Language Menu > Workplace > Preferences > Explorer Tab > Dateien pro Seite = Unbegrenzt
12. Switch start page for the web server#
Change/replace <tomee_home>/webapps/ROOT/index.htmlRedirection:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Refresh" content="0;URL=/opencms/<site>" /> </head> <body> <h3>Einen Augenblick bitte ...</h3> <h3>One moment please ...</h3> </body> </html>
13 Own icon at the Url (Favicon)#
You can upload an icon under
Workplace: Verwaltungsansicht > Webseiten Verwaltung > "F" column.
This will put the uploaded image under the site root as image file with the name favicon.ico.
BUT:
- Firefox and Chrome do not show any favicons anymore next to the URL, but in the tab only !
- IE and Safari do show it next to URL and tab !
?: just place the favicon.ico file in the top level folder in your war file
? Add the following code in the <head> to your index.html in you webapp/projectName/
<link rel="shortcut icon" href="http://example.com/favicon.ico" type="image/x-icon" /> <link rel="icon" href="http://example.com/favicon.ico" type="image/x-icon">
? There are several websites (use google) that generate .ico files from pictures (gif / jpeg etc)
<link rel="icon" type="image/gif" href="/img/image.gif">
14. Change locale from en to de (switch language)#
Note: Testing mode !
Changing languages, edit <opencms>/WEB-INF/config/opencms-system.xml
Default:
<internationalization> <localehandler class="org.opencms.i18n.CmsDefaultLocaleHandler"/> <localesconfigured> <locale>en</locale> <locale>de</locale> </localesconfigured> <localesdefault> <locale>en</locale> <locale>de</locale> </localesdefault> <timezone>GMT+01:00</timezone> </internationalization>
Adding language:
<localesconfigured> ... <locale>it</locale> ... </localesconfigured> <localesdefault> ... <locale>it</locale> ... </localesdefault>
To set another default language, put it to the top under <localesdefault>
Do not remove "en" in <localesconfigured> and <localesdefault> !
Copy content
Workplace > View=Administration > Content Werkzeuge > Sprachknoten kopieren
Ressource= /ebel/yoursite
Lösche den Quellsprachknoten = X
Qelle = Englisch
Ziel = Deutsch
Switch site locale\
Right-Click Subsitemap Folder > Properties > All properties Tab
locale = de
=> Publish
15. Skinndriva#
How to integrate and use skinndriva for OpenCmsNote: -- Incomplete and not tested ---
- Read nice presentation at slideshare
- Download SkinnDriva
- Unzip and get three zip files:
- com.diawara.opencms.commons_0.0.9.0.zip
- net.componio.opencms.modules.eight.skinndriva.rd.skins.base_0.0.9.0.zip
- net.componio.opencms.modules.eight.skinndriva.rd_0.0.9.0.zip
- Workplace > View=Administration > Modul Verwaltung > Modul per HTTP importieren
- Choose zip file from disk > OK
- Check in View=Explorer > Path/system/modules for a/m packages
16. Removing "/opencms/opencms" prefix#
The general solutions is to use a url rewrite library, that redirect you internally to the right url. There is one for Apache (httpd), but you can use UrlReqriteFilter with Tomcat alone, see here.Generally the URL looks like
http:// | yourserver/ | opencms/ | opencms/ | demo/ | start/ |
protocol | servername | context | servlet | site | page |
To remove the servlet part (opencms/) inside, you can do the following:
a. Download urlrewritefilter-4.0.3.jar and put it into <tomcat>\lib
b. Add to <opencms>/WEB-INF/web.xml:
<filter> <filter-name>UrlRewriteFilter</filter-name> <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class> </filter> <filter-mapping> <filter-name>UrlRewriteFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping>Note: "REQUEST" is used for general url requests, "FORWARD" is used when a rule was processed (outcome) or when a page is reloaded (Ctrl+R or F5).
c) Edit <opencms>\WEB-INF\config\opencms-importexport.xml and remove /opencms (/$SERVLET_NAME}) in vfs-prefix
<rendersettings> <rfs-prefix>${CONTEXT_NAME}/export</rfs-prefix> <!--OLD: <vfs-prefix>${CONTEXT_NAME}/${SERVLET_NAME}</vfs-prefix>--> <vfs-prefix>${CONTEXT_NAME}</vfs-prefix> <userelativelinks>false</userelativelinks> ...
d) Create <opencms>\WEB-INF\urlrewrite.xml and add rule to add /opencms internally again (see UrlRewriteUrl Docu)
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN" "http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd"> <!-- Configuration file for UrlRewriteFilter http://urlrewritefilter.googlecode.com/svn/trunk/src/doc/manual/4.0/index.html#configuration --> <urlrewrite> <rule> <name>Add "opencms/" internally again</name> <condition type="request-uri" operator="notequal">^/opencmsPlay/export/.*$</condition> <condition type="request-uri" operator="notequal">^/opencmsPlay/resources/.*$</condition> <condition type="request-uri" operator="notequal">^/opencmsPlay/opencms-errorhandler/.*$</condition> <condition type="request-uri" operator="notequal">^/opencmsPlay/webdav/.*$</condition> <condition type="request-uri" operator="notequal">^/opencmsPlay/opencms/.*$</condition> <from>^/(.*)$</from> <to last="true" type="forward">/opencms/$1</to> </rule> </urlrewrite>Note 1: <from> and <to> exclude the context
Note 2: each part separated with slash in <from> can be used as parameter $1, $2 in <to> ...
e) Optional: For debugging you can add several additional parameters to <opencms>\WEB-INF\web.xml inside the <filter> tag
<filter> <filter-name>UrlRewriteFilter</filter-name> <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class> <!-- set the amount of seconds the conf file will be checked for reload can be a valid integer (0 denotes check every time, -1 denotes no reload check, default -1) --> <init-param> <param-name>confReloadCheckInterval</param-name> <param-value>60</param-value> </init-param> <!-- sets up log level (will be logged to context log) can be: slf4j, TRACE, DEBUG, INFO (default), WARN, ERROR, FATAL, sysout:{level} (ie, sysout:DEBUG) if you are having trouble using normal levels use sysout:DEBUG (default WARN) --> <init-param> <param-name>logLevel</param-name> <param-value>DEBUG</param-value> </init-param> </filter>
Note 1: To remove also the context you may install opencms under the ROOT context of the web server.
Note 2: To use multiple sites with different webnames you can also use UrlRedirectFilter to forward/redirect to the proper site in your opencms setup.
17. Bootstrap Demo Color Theme#
There is a variable "bs.page.color" set in
/system/modules/com.alkacon.bootstrap.formatters/templates/bootstrap-page.jsp
<c:set var="colortheme"><cms:property name="bs.page.color" file="search" default="blue" /></c:set> <c:set var="pagelayout"><cms:property name="bs.page.layout" file="search" default="9" /></c:set> <link rel="stylesheet" href="<cms:link>/system/modules/com.alkacon.bootstrap.formatters/resources/css/themes/${colortheme}.css</cms:link>"> <link rel="stylesheet" href="<cms:link>/system/modules/com.alkacon.bootstrap.formatters/resources/css/themes/headers/header1-${colortheme}.css</cms:link>"> <link rel="stylesheet" href="<cms:link>%(link.weak:/system/modules/com.alkacon.bootstrap.formatters/resources/css/page.css:52f716c6-20f8-11e3-b4d8-000c297c001d)</cms:link>">This refers to
/system/modules/com.alkacon.bootstrap.formatters/resources/css/themes/
- headers - blue.css - default.css - light.css - orange.css - red.css
18. org.opencms.file.CmsVfsResourceNotFoundException#
When you have selected site = "/" (root) then you get this error. Select your real site. Then you do not get this error anymore. I prefer navigating in the root folder, then I use a two browsers (Firefox + Chrome). One for the workplace and the other for viewing and editing directly.19. Edit tips#
- Do NOT delete any content from the system folder!
20. Reset password#
UPDATE CMS_USERS SET USER_PASSWORD='xyz123' WHERE USER_NAME='Admin';