[MAGNOLIA-5816] Magnolia doesn't start on IBM Liberty Profile Created: 19/Jun/14  Updated: 08/Aug/14  Resolved: 23/Jul/14

Status: Closed
Project: Magnolia
Component/s: None
Affects Version/s: 5.2, 5.3, 5.3.1
Fix Version/s: 5.3.2

Type: Improvement Priority: Neutral
Reporter: Daniel Lipp Assignee: Daniel Lipp
Resolution: Fixed Votes: 0
Labels: quickwin
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Date of First Response:

 Description   

IBM's Liberty Profile as both - a standalone product and the base for Websphere Application Server. IBM uses it as it's default runtime when hosting Apps in their BlueMix Cloud Platform (based on Cloud Foundry).

Unfortunately Magnolia will always throw a RuntimeException ("Magnolia is not configured properly and therefore unable to start: real path can't be obtained...") when starting up the system on Liberty.

Caution: make sure to deploy as exploded war - else ServletContext#getRealPath(String) will always return <null> (see the spec)



 Comments   
Comment by Daniel Lipp [ 19/Jun/14 ]

It turned out that DefaultMagnoliaInitPaths#determineRootPath from

ServletContext.getRealPath(StringUtils.EMPTY)

always returns null on IBM Liberty (even when deployed as exploded war) where as
to

ServletCntext.getRealPath("/")

works as expected.

Obviously most other servers (Tomcat, Jetty, ...) support getRealPath(StringUtils.EMPTY).

Comment by Daniel Lipp [ 19/Jun/14 ]

Some test results with ServletContext.getRealPath(String) "" vs. "/"

Container "" "/"
Tomcat 7 path path/
Jetty 6 path path
Liberty null path

In other words: calling getRealPath(String) with "/" instead of "" could do the trick for many servers but we cannot be sure it would work for all servers. The spec isn't precise enough and there's no documentation on which server behaves how.
-> to be 100% backwards compatible, we should fallback to "/" in case "" returned null

Comment by Daniel Lipp [ 19/Jun/14 ]

https://www.ibm.com/developerworks/community/forums/html/topic?id=eb04c8ae-02d4-421b-af2c-2ef626a3db1b&ps=25 - related?

Generated at Mon Feb 12 04:08:39 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.