Forums

RSS RSS
Deploying liferay war under different context than ROOT Flat View
Threads
Hi,

for what I have read, this may not be possible, but can I deploy the liferay-portal-4.2.0.war under a different context PATH than ROOT?

if possible, how should I configure that? ideally, I would like to use an external file, do not wnat to mess up with the war contents

thank you very much

Alberto
Flag Flag
RE: Deploying liferay war under different context than ROOT
12/22/06 1:04 PM as a reply to Alberto Labarga.
Hi Alberto,

You'll be glad to hear that it is possible. You can see how in the following FAQ entry in LiferayPedia:

http://wiki.liferay.com/index.php/Liferay_FAQ#How_do_I_deploy_Liferay_to_a_context_different_than_the_root_one
Flag Flag
RE: Deploying liferay war under different context than ROOT
1/9/07 7:46 AM as a reply to Alberto Labarga.
This is how I have deployed multiple wars of version 4.1.3 to 1 tomcat.

 1
 2A. Configure tomcat
 31. create conf/jaas.config
 4
 5PortalRealm {
 6    com.liferay.portal.kernel.security.jaas.PortalLoginModule required;
 7};
 8
 92. modify bin/catalina.sh to include
10
11JAVA_OPTS="-Xms128m -Xmx512m -Dfile.encoding=UTF8 -Duser.timezone=EST -Djava.security.auth.login.config=$CATALINA_BASE/conf/jaas.config"
12
13
143. Copy Libs   
15     cp mysql-connector-java-3.1.13-bin.jar $CATALINA_HOME/common/lib
16
17    ( From liferay-portal-dependencies-4.1.3.zip )
18    cp portlet.jar $CATALINA_HOME/common/lib
19    cp portal-kernel.jar $CATALINA_HOME/common/lib
20
21    ( From liferay-portal-4.1.3.war )
22    mv liferay-portal-4.1.3/WEB-INF/lib/* into $CATALINA_HOME/shared/lib
23
24B. Configure the war
251. mkdir myPortal
26
272. cd myPortal
28
293. jar -xvf ../liferay-portal-4.1.3.war
30
314. rm index.html
32
335. create META-INF/context.xml
34    <Context path="/myPortal" reloadable="true" >
35   
36    <Resource
37        name="jdbc/LiferayPool"
38        auth="Container"
39        type="javax.sql.DataSource"
40        driverClassName="com.mysql.jdbc.Driver"
41        url="jdbc:mysql://localhost/lportal?useUnicode=true&amp;characterEncoding=UTF-8"
42        username="root"
43        password=""
44        maxActive="100"
45        maxIdle="30"
46        maxWait="10000"
47    />
48
49    <Resource
50                name="mail/MailSession"
51                auth="Container"
52                type="javax.mail.Session"
53                mail.transport.protocol="smtp"
54                mail.smtp.host="localhost"
55    />
56
57    <Realm
58                className="org.apache.catalina.realm.JAASRealm"
59                appName="PortalRealm"
60                userClassNames="com.liferay.portal.security.jaas.PortalPrincipal"
61                roleClassNames="com.liferay.portal.security.jaas.PortalRole"
62                debug="99"
63                useContextClassLoader="false"
64    />
65</Context>
66
67
68
696. modify WEB-INF/web.xml
70    - change company_id
71    - change root_path
72
737. mkdir WEB-INF/classes
74
758. cd classes
76
779. create WEB-INF/classes/portal-ext.properties
78   portal.release=professional
79
80   portal.ctx=/myPortal
81
82   auto.deploy.dest.dir=../webapps
83
84   portal.instances=1
85
86   lucene.dir=/var/liferay/lucene/
87
88   jcr.jackrabbit.repository.root=/var/liferay/jackrabbit
89
90   omniadmin.users=
91
9210. jar -cvf ../myPortal.war *
93
9411. copy myPortal.war to tomcats webapp directory



Now http://localhost:8080/myPortal/c should now work.

If you want to create a second instance, change the items in red
to yourPortal.

Remove the items in blue

Now you can deploy yourPortal.war to tomcat.
Flag Flag
RE: Deploying liferay war under different context than ROOT
12/24/06 8:07 AM as a reply to Stephen More.
Hi everybody,

Had been working for version 4.1.2,

But without success for version 4.2.0

The problem is :
on the main page the portlets are not visible, keeps loading without success,

Has anyone faced this problem with version 4.2.0

Br,
Amokrane,
Flag Flag
RE: Deploying liferay war under different context than ROOT
12/26/06 6:14 AM as a reply to Amokrane Belloui.
I've got the same problem, looks like the portlets are still trying to access from the ROOT context instead of the new portal context: http://localhost:8080/c/portal/render_portlet
instead of what it should be
http://localhost:8080/myportal/c/portal/render_portlet

Any liferay guru's know where the config for that is? Or is just a version bug?

Thanx
Flag Flag
RE: Deploying liferay war under different context than ROOT
12/26/06 12:19 PM as a reply to Glenn Michael Keith.
I think that is a bug. I have the same problem and i haven't it with previous versions.

I investigate the bug, and detect in the file portal-web/docroot/html/portal/load_render_portlet.jsp in the 4.2.0 source code this fragment of code for the javascript render:


...
function <%= namespace %>loadPortlet() {
var path = "/c/portal/render_portlet";
var queryString = "p_l_id=<%= plid %>&p_p_id=<%= portlet.getPortletId() %>&p_p_action=0&p_p_state=normal&p_p_mode=view&p_p_col_id=<%= columnId %>&p_p_col_pos=<%= columnPos %>&p_p_col_count=<%= columnCount %>";
...


I find this file only in the last version 4.2.0, you see the variable path, which don't use our context path modified. I solve it patching the file like this:


...
function <%= namespace %>loadPortlet() {
var path = "<%=PropsUtil.get(PropsUtil.PORTAL_CTX)%>/c/portal/render_portlet";
var queryString = "p_l_id=<%= plid %>&p_p_id=<%= portlet.getPortletId() %>&p_p_action=0&p_p_state=normal&p_p_mode=view&p_p_col_id=<%= columnId %>&p_p_col_pos=<%= columnPos %>&p_p_col_count=<%= columnCount %>";
...


I add PropsUtil.get(PropsUtil.PORTAL_CTX) in the definition of var path, for add property portal.ctx, which we have modified previously.

For solve the problem if you don't use source code, you go to the webapps directory in the server, navigate in your webapp to ...html/portal/load_render_portlet.jsp, find the var path and change it.
Flag Flag
RE: Deploying liferay war under different context than ROOT
12/27/06 11:09 AM as a reply to Borxa Varela Bouzas.
I found, a similiar solution by simply finding the load_render_portlet.jsp file and hardcoding the new context.

I thought I'd add a little note here as well for newbie's to liferay like myself. When you modify the company_id in the WEB.xml you'll notice that you will loose the default communities and pages inside liferays orignal configuration.

If you want to keep these setting and still change the company_id you'll need to go digging inside the lportal database create script to alter the primary key inside the insert statement into the table company from the liferay.com to your new company_id.
Flag Flag
RE: Deploying liferay war under different context than ROOT
12/29/06 11:06 AM as a reply to Glenn Michael Keith.
Hi,

This issue is already solved in SVN and will be included in 4.2.1. Thanks for noticing emoticon
Flag Flag
RE: Deploying liferay war under different context than ROOT
1/9/07 7:33 AM as a reply to Jorge Ferrer.
Dear Jorge,

please, could you help me to understand if Liferay can run in multiple instances on one Tomcat server, each Liferay instance poiting to a separate database?

Since many times I'm running three separate Liferay servers on three separate Tomcat 5.5 servers.

Each portal points to a separate database in one MySql server instance. I don't used 'lportal' unique database, but 'companyA' 'companyB' 'companyC' databases running on a MySql 5 server.

Now I have to setup more Liferay portals so I'm trying to run one only Tomcat server and multiple Liferay instances.

I successfully setup three instances of Liferay following the High Availability Guide published on wiki.liferay.com

Then I changed:

C:\Java\tomcat-liferay\conf\Catalina\localhost\ROOT.xml to point to the 'companyA' MySql database

C:\Java\tomcat-liferay\conf\Catalina\localhost2\ROOT.xml to point to the 'companyB' MySql database

C:\Java\tomcat-liferay\conf\Catalina\localhost3\ROOT.xml to point to the 'companyC' MySql database

To do the above I changed:
name="jdbc/LiferayPool"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
-----> url="jdbc:mysql://localhost/companyA / companyB / companyC <--
....
...
/>

But now I understand that Liferay use the "jdbc/LiferayPool" of the first instance (localhost) for the all instances, so it point only to the 'companyA' database!!

Please, could you tell me if different instance of Liferay can read data from different jdbc/LiferayPool sources?

In professional and/or ASP environment, a Company can ask to separate their corporate data from other Companies.

If this is impossible, there is a path to follow to merge the contents of the actual 'companyA' 'companyB' 'companyC' databases?

Thank you in advance for your help!

Ivano C.
Flag Flag
RE: Deploying liferay war under different context than ROOT
1/11/07 4:52 AM as a reply to Ivano Carrara.
Liferay has support for Application Server Provider hosting environments. The data of each company (called Enterprise in the web interface) is isolated from each other although only one database is required. Addition of new companies is done by deploying new portal WARS and changing the company_id parameter in the web.xml. The exact procedure depends on the application server.

If the databases must be different the best way to do it is to have several Tomcat instances.
Flag Flag
RE: Deploying liferay war under different context than ROOT
1/11/07 7:44 AM as a reply to Jorge Ferrer.
Jorge, thank you for your reply!

Also, I wrote the multiple-db problem in the Support site - see LEP-1975.

Brian Chan updated the record setting in Version 4.2.2 a probable fix of the problem, as you can see here: http://support.liferay.com/browse/LEP-1975?page=all

Thank you for your valuable support!

Ivano C.
Flag Flag
RE: Deploying liferay war under different context than ROOT
1/21/07 8:07 AM as a reply to Ivano Carrara.
In this other Post there's also information to this topic

Portlets not rendered when running liferay on other context than root

This one is fixed in liferay 4.2.1

BUT:
I think I encountered another Problem:
When using a different context than root no images are shown in articles based on Structure/Template Basic-Image-Text emoticon

Here's what I have done to change context from Root to myPortal. As soon as I can confirm my eMail adress I will also change the Wiki Article Jorge mentioned.

1. stop tomcat and change $CATALINA_HOME/webapps/ROOT to $CATALINA_HOME/webapps/myportal

2. (TOMCAT 5.5) change $CATALINA_HOME/conf/localhost/ROOT.xml to $CATALINA_HOME/conf/localhost/myportal.xml

3. In myportal.xml change/add ...Context ... docBase="/myportal" ...

4. In $CATALINA_HOME/webapps/myportal/index.html redirect to /myportal/c instead of /c

5. In portal-ext.properties add portal.ctx=/myportal

6. modify $CATALINA_HOME/webapps/myportal/WEB_INF/web.xml:
change the root_path from / to /myportal

7. start tomcat

By the way: Uploading the Images again AFTER changing the context did not help.

The source of the rendered HTML Page shows: ...img src="/image/journal/article?...

My System:
Tomcat 5.5.20
Liferay 4.2.1 with classic theme
MySQL 5
Flag Flag
RE: Deploying liferay war under different context than ROOT
1/19/07 8:00 AM as a reply to Andre Kreienbring.
Andre Kreienbring:

This one is fixed in liferay 4.2.1

BUT:
When using a different context than root no images are shown in articles based on Structure/Template Basic-Image-Text emoticon



Has this been documented in JIRA ?

I looked but did not see one....

If you are running apache httpd infront of tomcat there is a workaround:

1
2      RewriteEngine On
3      RewriteRule ^/image/(.*)$   /myportal/image/$1 [PT]
Flag Flag
RE: Deploying liferay war under different context than ROOT
1/19/07 12:46 PM as a reply to Stephen More.
Not sure if this is a misconfiguration or a bug!

Thats why I not reported it to Jira.

André
Flag Flag
RE: Deploying liferay war under different context than ROOT
1/20/07 9:50 AM as a reply to Stephen More.
Stephen More:
Andre Kreienbring:

This one is fixed in liferay 4.2.1

BUT:
When using a different context than root no images are shown in articles based on Structure/Template Basic-Image-Text emoticon



Has this been documented in JIRA ?

I looked but did not see one....

If you are running apache httpd infront of tomcat there is a workaround:

1
2      RewriteEngine On
3      RewriteRule ^/image/(.*)$   /myportal/image/$1 [PT]


No need, just tweak the journal.transformer.listener in portal-ext.properties with the following line

journal.transformer.listener=com.liferay.portlet.journal.util.TokensTransformerListener,com.liferay.portlet.journal.util.PropertiesTransformerListener,com.liferay.portlet.journal.util.ContentTransformerListener,com.liferay.portlet.journal.util.LocaleTransformerListener


It is found that the default active journal.transformer.listener in portal.properties omits the ContentTransformerListener in the chain, while the correct one is commented out. Therefore the /image/ token is not updated correctly in the web page.

Liferay guys, please double check and accept the fix.
Flag Flag
RE: Deploying liferay war under different context than ROOT
1/21/07 8:06 AM as a reply to Vincent Wong.
YES!

This was only the second Post of this guy. Man, you should post more often...

Great!

André
Flag Flag
RE: Deploying liferay war under different context than ROOT
1/22/07 11:11 AM as a reply to Vincent Wong.
See http://support.liferay.com/browse/LEP-2075

Thanks Vincent.
Flag Flag
RE: Deploying liferay war under different context than ROOT
2/4/07 12:48 PM as a reply to Brian Chan.
YESS !!! It works !
Thanks Vincent and other guys ;)

emoticon

just another throuble on this theme:
When pointing the browser to :
http://localhost:8080/portal

(my context path)

it redirects to:
http://localhost:8080/c

instead of :
http://localhost:8080/portal/c

Anyone has an hint to solve this problem ?

emoticon


[I applyed all the above fix , and followed the installation guide ... I run on Tomcat 6]
Flag Flag
RE: Deploying liferay war under different context than ROOT
2/5/07 3:05 AM as a reply to Miche Pitt.
Please check Step 4 in my list above!

André
Flag Flag
RE: Deploying liferay war under different context than ROOT
2/6/07 5:12 AM as a reply to Andre Kreienbring.
Following above works. I deployed to myportal context under tomcat 5.5.20. After signing in, portal looks like is functioning fine.
On start though, I get the following errors. Are these by design, or did I miss a step somewhere? I assume such content is not bundled in the .war - and this is the expected?

[JournalContentUtil:82] Uanble to get content for liferay.com 1 FRONTPA
GE-AD en_US
com.liferay.portlet.journal.NoSuchArticleException

...


12:59:41,137 ERROR [JournalContentUtil:82] Uanble to get content for liferay.com 1 ABOUT-L
IFERAY en_US
com.liferay.portlet.journal.NoSuchArticleException

.....

Along with a few others.
Flag Flag
RE: Deploying liferay war under different context than ROOT
2/7/07 8:12 AM as a reply to Marshall Thompson.
Hello,

i´ve got the same problem, i read there´s a Problem with Clob datatype and/or with the sql scripts.

In this forum, category:installation.database is explained that the use of ojdbc14.jar (10g) will solve this Problem.

I have to proof it, but have no time for, maybe can you try it.

An other Problem by me is the characterEncoding=UTF-8, specials characters in french or german and other languages are out of order...
Do you have this Problem too?
Flag Flag
RE: Deploying liferay war under different context than ROOT
2/7/07 8:09 AM as a reply to stephane Manou.
I already use oracle 10 (oracle xe) and the ojdbc14.jar. Had not noticed any issues with other languages since only using english at the moment.
Flag Flag
RE: Deploying liferay war under different context than ROOT
2/8/07 7:38 AM as a reply to Marshall Thompson.
ah, for those of us using oracle instead of the hypersonic db. The create-oracle.sql script does not populate the JournalArticle table with data. The hypersonic sql script does. There may be other tables that would need to be populated. Have not done an in-depth analysis.

Liferay guys, do you update all the sql scripts in the bundle when you add data for the bundle demo?
Flag Flag
RE: Deploying liferay war under different context than ROOT
2/15/07 12:35 PM as a reply to Marshall Thompson.
Andre, I used your guide to install liferay but when I start tomcat and access the link http://localhost8080/myPortal/c/ it throws me this exception in the log file:

 12007-02-15 18:14:44 StandardWrapperValve[MainServlet]: Servlet.service() for servlet MainServlet threw exception
 2java.lang.NullPointerException
 3    at com.liferay.portal.struts.StrutsUtil.forward(StrutsUtil.java:72)
 4    at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:865)
 5    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 6    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
 7    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
 8    at com.liferay.filters.secure.SecureFilter.doFilter(SecureFilter.java:143)
 9    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
10    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
11    at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.doFilter(VirtualHostFilter.java:152)
12    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
13    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
14    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
15    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
16    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
17    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
18    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
19    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
20    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
21    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
22    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
23    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
24    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
25    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
26    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
27    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
28    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
29    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
30    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
31    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
32    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
33    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
34    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
35    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
36    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
37    at java.lang.Thread.run(Thread.java:534)


do you or someone have any idea of what Im missing? I have tried many times and always the same error.
Flag Flag
RE: Deploying liferay war under different context than ROOT
2/16/07 2:19 AM as a reply to Andres Gutierrez.
Andres

are you sure that your liferay runs smoothly in the root context?

You get a NullPointer in the Struts forward.

Did you make any changes to struts-config.xml or other configuration files?

André
Flag Flag
RE: Deploying liferay war under different context than ROOT
2/16/07 6:33 AM as a reply to Andre Kreienbring.
emoticon

Hi Andre,

I first use the bundle version and work on it, then I needed to install it in a server in where the tomcat have more applications, so I need that liferay work in a different context than ROOT, thats why I use the guide yo posted, but I havent done any thing different from what you post (didnt change struts-config.xml or other configuration file), so I'm kind of confuse, am I missing some basic configurations. I already read the tutorial for installing the war in tomcat but I recieve the same response (Null Pointer Exception in the forward).

emoticon help haaaaaaaaaaaa
Flag Flag
RE: Deploying liferay war under different context than ROOT
2/16/07 9:01 AM as a reply to Andres Gutierrez.
Sorry,

I can't help you with this. I've no idea where this comes from.

Maybe anybody else?

André
Flag Flag
RE: Deploying liferay war under different context than ROOT
2/21/07 7:14 AM as a reply to Brian Chan.
Brian Chan:
See http://support.liferay.com/browse/LEP-2075

Thanks Vincent.


Thanks Brian.
I find the Journal's content editor does not display image correctly in its editor because the image's url doesn't take the web context into account. Here is my guess to fix to the issue. Hope it helps others as well. I'm new to Liferay so not sure if it is the best fix to the problem, please double-check.

Locate the following lines in ROOT/html/portlet/journal/edit_article_content_xsd_el.jsp:
1<%@ include file="/html/portlet/journal/init.jsp" %>
2<%
3String languageId = LanguageUtil.getLanguageId(request);
4
5String groupId = (String)request.getAttribute(WebKeys.JOURNAL_ARTICLE_GROUP_ID);
6
7Element el = (Element)request.getAttribute(WebKeys.JOURNAL_STRUCTURE_EL);

Add the second line of code
1String groupId = (String)request.getAttribute(WebKeys.JOURNAL_ARTICLE_GROUP_ID);
2String portalCTX = PropsUtil.get(PropsUtil.PORTAL_CTX).trim();


Then find the following fragment in the same file:
 1            if ((i + 1) == elPathNames.length) {
 2                elContent = GetterUtil.getString(tempEl.elementText("dynamic-content"));
 3
 4                if (!elType.equals("text_area")) {
 5                    elContent = Html.toInputSafe(elContent);
 6                }
 7
 8                Element dynConEl = tempEl.element("dynamic-content");
 9
10                if (dynConEl != null) {
11                    elLanguageId = dynConEl.attributeValue("language-id", StringPool.BLANK);
12                }
13                else {
14                    elLanguageId = languageId;
15                }
16            }

Add the following first 3 lines of code to fix the URL.
1                if (elType.equals("image")) {
2                    elContent = portalCTX + elContent;
3                }
4
5                if (!elType.equals("text_area")) {
6                    elContent = Html.toInputSafe(elContent);
7                }
Flag Flag
RE: Deploying liferay war under different context than ROOT
3/14/07 2:14 PM as a reply to Vincent Wong.
Vincent I used your guess but it didnt work well, it generated an error and didnt show the information in the Home page, it just appeared the language options and the menu in the top side of the page.
Flag Flag
RE: Deploying liferay war under different context than ROOT
3/15/07 2:46 AM as a reply to Vincent Wong.
Hi Vincent,
your contribution is truly precious.

I have a new questions.

In the multi-contex configuration on same Tomcat I have a problem with locales configured in the portlet-ext.properties or portlet-(companyId).properties.
I have the company “A” with locales=en_US,it_IT and company “B” with locales=it_IT.

Being LanguageUtil a Singleton, the locales visualized by the Language Portlet will depend on the context used for first. And this status not change until restart tomcat.

How I can resolve this problem? This is a BUG? Exists a way in order to by-pass the problem?

Thanks in advance for your help.

Cheers,
Pier Paolo
Flag Flag
RE: Deploying liferay war under different context than ROOT
3/15/07 3:32 AM as a reply to Vincent Wong.
Hi all,
I have an other problem with the locales, this time with the “local” property in the file system-ext.properties.

In this configuration multi-site the file system-ext.properties does not come loaded.

I have had to directly injected the modification of “local” property in the file system.properties in the jar portal-ejb.jar.

Is there an other solution?

Thanks in advance.

Cheers,
Pier Paolo.
Flag Flag
RE: Deploying liferay war under different context than ROOT
3/16/07 1:03 AM as a reply to Vincent Wong.
Vincent Wong:

No need, just tweak the journal.transformer.listener in portal-ext.properties with the following line


But ... this fix only seems to work for "the" Content Image ("/image/journal..."), not for images from the image gallery I embed using the html editor ("/image/image_gallery") ...

Is this a bug too or am I doing something wrong?

Regards,

Marcus.
Flag Flag
RE: Deploying liferay war under different context than ROOT
3/16/07 3:21 AM as a reply to Marcus Schmidke.
Marcus Schmidke:

not for images from the image gallery I embed using the html editor ("/image/image_gallery") ...


As an workaround, I patched ImageCommandReceiver.java:

in method _getFiles(), I changed the following lines:

fileEl.setAttribute("size", getSize(image.getSize()));
String ctx=PropsUtil.get(PropsUtil.PORTAL_CTX).trim();
fileEl.setAttribute(
"url", ctx+"/image/image_gallery?img_id=" + image.getImageId());

For now, it works, but the result is having the absolute image path in the journal article object so that after eventually changing the root context path, all images are lost once again.
Flag Flag
RE: Deploying liferay war under different context than ROOT
3/16/07 6:10 AM as a reply to Marcus Schmidke.
Marcus Schmidke:
but the result is having the absolute image path in the journal article object


Now I've found a solution for this, but I am not sure if it is a bad hack.

It took the following steps:

Once again, I've changed ImageCommandReceiver.

1
2fileEl.setAttribute("size", getSize(image.getSize()));
3fileEl.setAttribute(
4    "url", "image/image_gallery?img_id=" + image.getImageId());


Actually, yet the only difference to the original version is the removed slash at the beginning of the url.

Then, I've changed the fckconfig.js to have a BaseHref:

FCKConfig.BaseHref = 'http://localhost:8080/mycontext/' ;

(Perhaps this could be coded in some dynamic way sice it's JavaScript). With these changes, the editor works fine, and the URLs in the journal database are relative to the context root.

Lastly, I had to write another TransformerListener and appended it to the journal.transformer.listener property containing code like the following:

 1    @Override
 2    public String onXml(String s) {
 3        StringBuffer r=new StringBuffer(s.length());
 4        if (s!=null) {
 5            String context_root=PropsUtil.get(PropsUtil.PORTAL_CTX);
 6            int start=0;
 7            int pos;
 8            while (start<s.length()) {
 9                pos=s.indexOf("src=\"image/",start);
10                if (pos>=0) {
11                    r.append(s.substring(start,pos));
12                    r.append("src=\"");
13                    r.append(context_root);
14                    r.append("/");
15                    start=pos+5;
16                } else break;
17            }
18            r.append(s.substring(start));
19        }
20        return r.toString();
21    }
Flag Flag
RE: Deploying liferay war under different context than ROOT
3/18/07 5:52 PM as a reply to Stephen More.
Stephen,

What about configuring Tomcat so that it has multiple instances, each instance running in its own JVM, then installing one Liferay instance per Tomcat instance? This will give the benefit of managing each Liferay instance independent of the other instances, such as starting, stopping, allocating JVM heap size, etc.

I have been trying to do this with some luck. I created multiple instances of Tomcat and now having trouble with Liferay.

Thanks!

Jamal


Stephen More:
This is how I have deployed multiple wars of version 4.1.3 to 1 tomcat.

 1
 2A. Configure tomcat
 31. create conf/jaas.config
 4
 5PortalRealm {
 6    com.liferay.portal.kernel.security.jaas.PortalLoginModule required;
 7};
 8
 92. modify bin/catalina.sh to include
10
11JAVA_OPTS="-Xms128m -Xmx512m -Dfile.encoding=UTF8 -Duser.timezone=EST -Djava.security.auth.login.config=$CATALINA_BASE/conf/jaas.config"
12
13
143. Copy Libs   
15     cp mysql-connector-java-3.1.13-bin.jar $CATALINA_HOME/common/lib
16
17    ( From liferay-portal-dependencies-4.1.3.zip )
18    cp portlet.jar $CATALINA_HOME/common/lib
19    cp portal-kernel.jar $CATALINA_HOME/common/lib
20
21    ( From liferay-portal-4.1.3.war )
22    mv liferay-portal-4.1.3/WEB-INF/lib/* into $CATALINA_HOME/shared/lib
23
24B. Configure the war
251. mkdir myPortal
26
272. cd myPortal
28
293. jar -xvf ../liferay-portal-4.1.3.war
30
314. rm index.html
32
335. create META-INF/context.xml
34    <Context path="/myPortal" reloadable="true" >
35   
36    <Resource
37        name="jdbc/LiferayPool"
38        auth="Container"
39        type="javax.sql.DataSource"
40        driverClassName="com.mysql.jdbc.Driver"
41        url="jdbc:mysql://localhost/lportal?useUnicode=true&amp;characterEncoding=UTF-8"
42        username="root"
43        password=""
44        maxActive="100"
45        maxIdle="30"
46        maxWait="10000"
47    />
48
49    <Resource
50                name="mail/MailSession"
51                auth="Container"
52                type="javax.mail.Session"
53                mail.transport.protocol="smtp"
54                mail.smtp.host="localhost"
55    />
56
57    <Realm
58                className="org.apache.catalina.realm.JAASRealm"
59                appName="PortalRealm"
60                userClassNames="com.liferay.portal.security.jaas.PortalPrincipal"
61                roleClassNames="com.liferay.portal.security.jaas.PortalRole"
62                debug="99"
63                useContextClassLoader="false"
64    />
65</Context>
66
67
68
696. modify WEB-INF/web.xml
70    - change company_id
71    - change root_path
72
737. mkdir WEB-INF/classes
74
758. cd classes
76
779. create WEB-INF/classes/portal-ext.properties
78   portal.release=professional
79
80   portal.ctx=/myPortal
81
82   auto.deploy.dest.dir=../webapps
83
84   portal.instances=1
85
86   lucene.dir=/var/liferay/lucene/
87
88   jcr.jackrabbit.repository.root=/var/liferay/jackrabbit
89
90   omniadmin.users=
91
9210. jar -cvf ../myPortal.war *
93
9411. copy myPortal.war to tomcats webapp directory



Now http://localhost:8080/myPortal/c should now work.

If you want to create a second instance, change the items in red
to yourPortal.

Remove the items in blue

Now you can deploy yourPortal.war to tomcat.
Flag Flag
RE: Deploying liferay war under different context than ROOT
3/20/07 9:55 AM as a reply to Jamal Najmi.
Jamal Najmi:

What about configuring Tomcat so that it has multiple instances, each instance running in its own JVM, then installing one Liferay instance per Tomcat instance? This will give the benefit of managing each Liferay instance independent of the other instances, such as starting, stopping, allocating JVM heap size, etc.

I have been trying to do this with some luck. I created multiple instances of Tomcat and now having trouble with Liferay.

I would think this would be very easy to do....what type of errors are you getting ?
Flag Flag
RE: Deploying liferay war under different context than ROOT
3/20/07 6:37 PM as a reply to Stephen More.
Well,

To give you a little bit of a background. I installed tomcat 5.5.20 on Linux. I followed instructions at http://www.linuxjournal.com/article/8561 to configure two tomcat instances listening on different ports.

Then I borrowed instructions from http://wiki.liferay.com/index.php/High_Availability_Guide to install and configure Liferay. There were some differences though. For example there is one server.xml per Tomcat instance.

One thing I have noticed is that if I place Liferay jar files in CATALINA_HOME/common/lib/ext, these jar files are not picked up by tomcat and tomcat throws class not found exception. So I had to keep all jars in their own liferay WEB-INF/lib folders.

And here is the error I am getting. I am not sure if this error has anything to do with the fact that I am running tomcat instances. I will appreciate any help I can get.

Thanks!

Jamal


Mar 19, 2007 11:49:35 PM org.apache.catalina.realm.JAASRealm setUseContextClass
Loader
INFO: Setting useContextClassLoader = false
log4j:WARN No appenders could be found for logger (org.apache.catalina.startup.
TldConfig).
log4j:WARN Please initialize the log4j system properly.
Mar 19, 2007 11:49:37 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Mar 19, 2007 11:49:37 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [] startup failed due to previous errors
Mar 19, 2007 11:49:37 PM org.apache.catalina.core.StandardContext processTlds
SEVERE: Error reading tld listeners java.lang.NullPointerException
java.lang.NullPointerException
at org.apache.log4j.Category.isEnabledFor(Category.java:746)
at org.apache.commons.logging.impl.Log4JLogger.isTraceEnabled(Log4JLogg
er.java:327)
at org.apache.catalina.startup.TldConfig.tldScanResourcePaths(TldConfig
.java:581)
at org.apache.catalina.startup.TldConfig.execute(TldConfig.java:282)
at org.apache.catalina.core.StandardContext.processTlds(StandardContext
.java:4302)
Flag Flag
RE: Deploying liferay war under different context than ROOT
3/21/07 8:07 AM as a reply to Jamal Najmi.
Hi

Jamal Najmi:
One thing I have noticed is that if I place Liferay jar files in CATALINA_HOME/common/lib/ext, these jar files are not picked up by tomcat and tomcat throws class not found exception. So I had to keep all jars in their own liferay WEB-INF/lib folders.


If you want them to be in the directory "CATALINA_HOME/common/lib/ext" you have to configure the file "CATALINA_HOME/conf/catalina.properties" and in this line:

common.loader= ${catalina.home}/common/classes, ...

add in the last part this code:

${catalina.home}/common/lib/ext/*.jar

this makes that the server also search for .jar's in the ext/ directory.

For the error, it looks like the problem is the context.xml of your liferay instance, where do you have your context, in conf/Catalina/localhost/ or in webapp/"your portal"/META-INF/ ? and what info does this file have ?

I also recommend you to read the liferay 4 installation guide that can be downloaded from this page.

hf

Andres G
Flag Flag