[MAGNOLIA-2487] Empty servlet mapping causes error upon installation Created: 30/Nov/08  Updated: 13/Mar/12  Resolved: 15/Jun/10

Status: Closed
Project: Magnolia
Component/s: None
Affects Version/s: None
Fix Version/s: 4.3.3, 4.4

Type: Bug Priority: Minor
Reporter: Brian Bowman Assignee: Ondrej Chytil
Resolution: Fixed Votes: 0
Labels: installation, mapping, module, servlet
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

ubuntu 8.04 x64, tomcat 5.5, java 1.5 x64


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:

 Description   

If a servlet mapping is left empty:

<mappings>
<mapping></mapping>
</mappings>

There is a null error upon module installation via the web interface and installation does not complete. The error message is:

ERROR info.magnolia.module.ui.ModuleManagerWebUI ModuleManagerWebUI.java(run:124) 28.11.2008 14:08:11 Could not perform installation: null
java.lang.NullPointerException
at java.lang.StringBuffer.<init>(StringBuffer.java:104)
at info.magnolia.cms.core.Path.getValidatedLabel(Path.java:347)
at info.magnolia.module.delta.RegisterServletTask.execute(RegisterServletTask.java:80)
at info.magnolia.module.delta.ArrayDelegateTask.execute(ArrayDelegateTask.java:117)
at info.magnolia.module.delta.RegisterModuleServletsTask.execute(RegisterModuleServletsTask.java:63)
at info.magnolia.module.ModuleManagerImpl.applyDeltas(ModuleManagerImpl.java:455)
at info.magnolia.module.ModuleManagerImpl.installOrUpdateModule(ModuleManagerImpl.java:435)
at info.magnolia.module.ModuleManagerImpl$1.exec(ModuleManagerImpl.java:262)
at info.magnolia.context.MgnlContext.doInSystemContext(MgnlContext.java:411)
at info.magnolia.module.ModuleManagerImpl.performInstallOrUpdate(ModuleManagerImpl.java:257)
at info.magnolia.module.ui.ModuleManagerWebUI$2.run(ModuleManagerWebUI.java:122)
at java.lang.Thread.run(Thread.java:595)
ERROR info.magnolia.module.InstallContextImpl InstallContextImpl.java(error:83) 28.11.2008 14:08:11 > Could not perform installation: null
java.lang.NullPointerException
at java.lang.StringBuffer.<init>(StringBuffer.java:104)
at info.magnolia.cms.core.Path.getValidatedLabel(Path.java:347)
at info.magnolia.module.delta.RegisterServletTask.execute(RegisterServletTask.java:80)
at info.magnolia.module.delta.ArrayDelegateTask.execute(ArrayDelegateTask.java:117)
at info.magnolia.module.delta.RegisterModuleServletsTask.execute(RegisterModuleServletsTask.java:63)
at info.magnolia.module.ModuleManagerImpl.applyDeltas(ModuleManagerImpl.java:455)
at info.magnolia.module.ModuleManagerImpl.installOrUpdateModule(ModuleManagerImpl.java:435)
at info.magnolia.module.ModuleManagerImpl$1.exec(ModuleManagerImpl.java:262)
at info.magnolia.context.MgnlContext.doInSystemContext(MgnlContext.java:411)
at info.magnolia.module.ModuleManagerImpl.performInstallOrUpdate(ModuleManagerImpl.java:257)
at info.magnolia.module.ui.ModuleManagerWebUI$2.run(ModuleManagerWebUI.java:122)
at java.lang.Thread.run(Thread.java:595)

One fix for this is to add a null check in the execute() method of info.magnolia.module.delta.RegisterServletTask:

if (pattern != null)

{ String mappingNodeName = Path.getUniqueLabel(mappingsNode, Path.getValidatedLabel(pattern)); final Content mappingNode = mappingsNode.createContent(mappingNodeName, ItemType.CONTENTNODE); NodeDataUtil.getOrCreateAndSet(mappingNode, "pattern", pattern); }

 Comments   
Comment by Magnolia International [ 01/Dec/08 ]

While I agree the error handling there could be improved, what's your use case for having such an (non-) mapping? Sounds to me like it should throw some IllegalArgumentException instead of silently ignoring it.

Comment by Magnolia International [ 11/Dec/08 ]

Brian, any opinion ?

Comment by Brian Bowman [ 11/Dec/08 ]

Hi Gregory,

I am not the developer of the servlet, so I may not be able to answer all of your questions regarding it. The servlet contains the connection information to a unique JDBC connection. It also loads some data from this connection into application scope. Some of its parameters are referenced by other classes.

The exception sounds like the right solution.

Thanks,
Brian

Comment by Magnolia International [ 11/Dec/08 ]

That wouldn't happen to a loadOnStartup kind of servlet now would it? If so, it's simply not supported and will not be loaded on startup by Magnolia anyway. If you'd really need it you'd have to add it to your web.xml instead.

Comment by Brian Bowman [ 01/Jan/09 ]

This is a load-on-startup servlet. You are correct, we had to add this to our web.xml instead of our module descriptor after upgrading to 3.6.3.

Generated at Mon Feb 12 03:37:11 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.