[MAGNOLIA-5379] NullPointerException when server name does not resolve in DNS Created: 10/Oct/13  Updated: 25/Oct/13  Resolved: 16/Oct/13

Status: Closed
Project: Magnolia
Component/s: core
Affects Version/s: 5.1
Fix Version/s: 4.5.13, 5.1.1

Type: Bug Priority: Major
Reporter: Archie Cobbs Assignee: Milan Divilek
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
relates to MAGNOLIA-4486 fails to launch with tomcat bundle an... Closed
relates to MAGNOLIA-4466 Print proper error message in case of... Closed
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)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Sprint: 5.1.1

 Description   

Running Magnolia on a box that has a non-resolvable hostname.

In this case, the server name should fall back to "default".

It appears to do that, but there is a subsequent NullPointerException:

INFO: Deploying web application directory /srv/tomcat/webapps/magnolia
2013-10-10 15:21:33,198 ERROR info.magnolia.init.DefaultMagnoliaInitPaths       : nested: nested: Name or service not known
2013-10-10 15:21:33,205 WARN  info.magnolia.init.MagnoliaServletContextListener : Failed to obtain server name, please check your configuration. Using 'default' as server name instead.
2013-10-10 15:21:33,714 ERROR info.magnolia.init.MagnoliaServletContextListener : Oops, Magnolia could not be started
java.lang.NullPointerException
        at java.util.Hashtable.put(Hashtable.java:514)
        at info.magnolia.init.properties.InitPathsPropertySource$1.<init>(InitPathsPropertySource.java:55)
        at info.magnolia.init.properties.InitPathsPropertySource.<init>(InitPathsPropertySource.java:52)
        at info.magnolia.init.DefaultMagnoliaConfigurationProperties.makeSources(DefaultMagnoliaConfigurationProperties.java:94)
        at info.magnolia.init.DefaultMagnoliaConfigurationProperties.init(DefaultMagnoliaConfigurationProperties.java:82)
        at info.magnolia.init.MagnoliaServletContextListener.contextInitialized(MagnoliaServletContextListener.java:157)
        at info.magnolia.init.MagnoliaServletContextListener.contextInitialized(MagnoliaServletContextListener.java:126)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        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:1113)
        at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1671)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:724)


 Comments   
Comment by Daniel Lipp [ 11/Oct/13 ]

On first sight it looks like the fix from MAGNOLIA-4466 (4.5.x) is not working for 5.x versions because there we read the server name several times (at least twice) from the DefaultMagnoliaInitPaths singleton.

I guess that moving

    if (serverName == null) {
        log.warn("Failed to obtain server name, please check your configuration. Using 'default' as server name instead.");
        serverName = "default";
    }

from ServletContextListener#contextInitialized(ServletContextEvent, boolean) to DefaultMagnoliaInitPaths#determineServerName(ServletContext) should be sufficient.

Comment by Tobias Mattsson [ 16/Oct/13 ]

Needs backport to 4.5.13, please also update fix-version.

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