Topic
  • 7 replies
  • Latest Post - ‏2014-01-31T14:32:00Z by bergmark
Graham Ashby
Graham Ashby
5 Posts

Pinned topic File Serving from a different location

‏2014-01-21T14:48:01Z |

I have an existing application where the static content is not under the context root.  The layout looks like:

install/webapps/context/WEB-INF/ [etc]

install/webcontent/aaa

/install/webcontnet/bbb

I have a server that has an application that has the location as the webaaps/context

Now, I know that I could do this with symbolic links, but that's difficult, since this has to work on all sorts of platforms.  I was hoping that I could do some sort of additional configuration in the server.xml to pull in the webcontent, but I haven't found a magic recipe yet.

Perhaps I have to create an extension, but I don't know how to go about that.

Thanks

Graham Ashby

  • bergmark
    bergmark
    42 Posts

    Re: File Serving from a different location

    ‏2014-01-21T15:22:03Z  

    I believe the extended document root support should help with what you are trying to accomplish:

    http://pic.dhe.ibm.com/infocenter/wasinfo/v8r0/index.jsp?topic=%2Fcom.ibm.websphere.nd.doc%2Finfo%2Fae%2Fae%2Fcweb_flserv.html

    and a little more detail here:

    http://pic.dhe.ibm.com/infocenter/wasinfo/v8r0/index.jsp?topic=%2Fcom.ibm.websphere.express.doc%2Finfo%2Fexp%2Fae%2Frweb_jspengine.html

    As your content appears to be outside of the application, you will have to provide the fully qualified path to the webcontent.

  • Graham Ashby
    Graham Ashby
    5 Posts

    Re: File Serving from a different location

    ‏2014-01-21T21:13:40Z  

    This is exactly what I was looking for.  However, the attribute seems to be accepted, but I'm getting errors.

    I have the following in my server.xml:

      <webContainer skipMetaInfResourcesProcessing="true" deferServletLoad="false" extendedDocumentRoot="${install.dir}/webcontent"/>

    ($install.dir is defined, since I use this for my application.)

    However, when I make a request for "host:port/context/ps/portal/js/cc.js" I get the error:

    [1/21/14 15:50:38:597 EST] 00000484 com.ibm.ws.webcontainer.extension                            W SRVE0190E: File not found: /ps/portal/js/cc.js

    I get the feeling I'm almost there, but I must be missing something.  It doesn't help that this isn't documented directly in the Liberty documentation

    Thanks

    G

     

  • bergmark
    bergmark
    42 Posts

    Re: File Serving from a different location

    ‏2014-01-21T21:45:40Z  

    This is exactly what I was looking for.  However, the attribute seems to be accepted, but I'm getting errors.

    I have the following in my server.xml:

      <webContainer skipMetaInfResourcesProcessing="true" deferServletLoad="false" extendedDocumentRoot="${install.dir}/webcontent"/>

    ($install.dir is defined, since I use this for my application.)

    However, when I make a request for "host:port/context/ps/portal/js/cc.js" I get the error:

    [1/21/14 15:50:38:597 EST] 00000484 com.ibm.ws.webcontainer.extension                            W SRVE0190E: File not found: /ps/portal/js/cc.js

    I get the feeling I'm almost there, but I must be missing something.  It doesn't help that this isn't documented directly in the Liberty documentation

    Thanks

    G

     

    I do not believe the properties in ibm-web-ext.xmi support expanding liberty config variables.  Could you try the fully qualified path without the ${install.dir}.

  • Graham Ashby
    Graham Ashby
    5 Posts

    Re: File Serving from a different location

    ‏2014-01-21T22:19:25Z  
    • bergmark
    • ‏2014-01-21T21:45:40Z

    I do not believe the properties in ibm-web-ext.xmi support expanding liberty config variables.  Could you try the fully qualified path without the ${install.dir}.

    I changed it to the following, but the result was the same:

      <webContainer skipMetaInfResourcesProcessing="true" deferServletLoad="false" extendedDocumentRoot="c:/ib6000.44/webcontent"/>

  • bergmark
    bergmark
    42 Posts

    Re: File Serving from a different location

    ‏2014-01-21T22:28:48Z  

    I changed it to the following, but the result was the same:

      <webContainer skipMetaInfResourcesProcessing="true" deferServletLoad="false" extendedDocumentRoot="c:/ib6000.44/webcontent"/>

    If it doesn't work even with a fully qualified path, then that sounds like a possible bug.  The best way to proceed is probably to open a PMR so we can investigate and if necessary provide a fix.

  • Graham Ashby
    Graham Ashby
    5 Posts

    Re: File Serving from a different location

    ‏2014-01-30T19:55:51Z  

    No luck yet.  The documentation is a little confusing.  It seems to refer to the ibm-web-ext.xmi.

    There is also an "extendedDocumentRoot" in the server.xml, but under jspEngine.

    So, I set them all.  In server.xml, I have:

      <webContainer skipMetaInfResourcesProcessing="true" deferServletLoad="false" extendedDocumentRoot="c:/ib6000.44/webcontent" fileServingEnabled="true"/> 
      <fileServingAttributes name="extendedDocumentRoot" value="${install.dir}/webcontent"/>
      <jspEngine extendedDocumentRoot="c:/ib6000.44/webcontent"/>

    In ibm-web-ext.xmi, I have:

       <jspAttributes xmi:id="JSPAttribute_3" name="extendedDocumentRoot" value="c:/ib6000.44/webcontent"/>
      <fileServingAttributes xmi:id="FSA_1" name="extendedDocumentRoot" value="c:/ib6000.44/webcontent"/>
    

    I turned on trace logging, and I see this:

    [1/30/14 11:46:48:554 EST] 0000001a webcontainer  1   ServiceEvent REGISTERED
                                     ServiceRef:[com.ibm.ws.container.service.app.deploy.ModuleRuntimeContainer, com.ibm.wsspi.http.VirtualHostListener](id=180, pid=com.ibm.ws.webcontainer)
                                     Event:org.osgi.framework.ServiceEvent[source={com.ibm.ws.container.service.app.deploy.ModuleRuntimeContainer, com.ibm.wsspi.http.VirtualHostListener}={enableJspMappingOverride=false, service.vendor=IBM, enableDefaultIsElIgnoredInTag=false, symbolicLinksCacheSize=1000, metaInfResourcesCacheSize=20, ignoreSessiononStaticFileRequest=false, logServletContainerInitializerClassLoadingErrors=false, directoryBrowsingEnabled=false, component.id=125, fileServingEnabled=true, disableXPoweredBy=false, defaultTraceRequestBehavior=false, serveServletsByClassnameEnabled=false, defaultHeadRequestBehavior=false, dispatcherRethrowsEr=true, adapterFactoryDependency.target=(containerToType=com.ibm.ws.webcontainer.osgi.webapp.WebAppConfiguration), enableErrorExceptionTypeFirst=false, decodeUrlPlusSign=false, skipMetaInfResourcesProcessing=true, component.name=com.ibm.ws.webcontainer, service.pid=com.ibm.ws.webcontainer, parseUtf8PostData=false, disallowAllFileServing=false, asyncTimerThreads=2, disallowServeServletsByClassName=false, exposeWebInfOnDispatch=false, allowIncludeSendError=false, tolerateSymbolicLinks=false, copyAttributesKeySet=false, config.overrides=true, enableMultiReadOfPostData=false, decodeUrlAsUtf8=true, channelWriteType=async, invokeFilterInitAtStartup=true, config.source=file, extendedDocumentRoot=c:/ib6000.44/webcontent, asyncPurgeInterval=30000, doNotServeByClassName=, deferServletLoad=false, listeners=, trustHostHeaderPort=false, asyncMaxSizeTaskPool=5000, asyncTimeoutDefault=30000, httpsIndicatorHeader=, trusted=true, suppressHtmlRecursiveErrorOutput=false, extractHostHeaderPort=false, fileWrapperEvents=false, type=web, service.id=180}]
    [ ... removed ...]
    [1/30/14 11:46:48:626 EST] 0000001a jsp           1   ServiceEvent REGISTERED
                                     ServiceRef:[com.ibm.wsspi.webcontainer.extension.ExtensionFactory](id=187, pid=com.ibm.ws.jsp.2.2)
                                     Event:org.osgi.framework.ServiceEvent[source={com.ibm.wsspi.webcontainer.extension.ExtensionFactory}={keepGenerated=false, component.name=com.ibm.ws.jsp.2.2, config.source=file, useImplicitTagLibs=true, service.vendor=IBM, recompileJspOnRestart=false, useInMemory=false, service.pid=com.ibm.ws.jsp.2.2, extendedDocumentRoot=c:/ib6000.44/webcontent, config.overrides=true, component.id=134, disableResourceInjection=false, disableJspRuntimeCompilation=false, jdkSourceLevel=15, service.id=187}]
    [1/30/14 11:47:09:876 EST] 0000001d util          1 com.ibm.ws.webcontainer.util.DocumentRootUtils getRoot Attribute name = extendedDocumentRoot, type = staticFile, value = null
    [1/30/14 11:47:09:876 EST] 0000001d util          1 com.ibm.ws.webcontainer.util.DocumentRootUtils getRoot Attribute name = preFragmentExtendedDocumentRoot, type = staticFile, value = null
    [1/30/14 11:47:09:877 EST] 0000001d util          1 com.ibm.ws.webcontainer.util.DocumentRootUtils Document Root Utils created with context and config. type = staticFile
    [1/30/14 11:47:09:877 EST] 0000001d util          1 com.ibm.ws.webcontainer.util.DocumentRootUtils getRoot Attribute name = extendedDocumentRoot, type = jsp, value = null
    [1/30/14 11:47:09:877 EST] 0000001d util          1 com.ibm.ws.webcontainer.util.DocumentRootUtils getRoot Attribute name = preFragmentExtendedDocumentRoot, type = jsp, value = null
    [1/30/14 11:47:09:877 EST] 0000001d util          1 com.ibm.ws.webcontainer.util.DocumentRootUtils Document Root Utils created with context and config. type = jsp
    [ --- chomp ---]
    [1/30/14 11:48:06:731 EST] 00000047 srt           1 com.ibm.ws.webcontainer.srt.SRTServletRequest getEncodedRequestURI  uri --> /p2pd/ps/portal/js/cc.js
    [1/30/14 11:48:06:732 EST] 00000047 srt           1 com.ibm.ws.webcontainer.srt.SRTServletRequest getRequestURI  uri --> /p2pd/ps/portal/js/cc.js
    [1/30/14 11:48:06:732 EST] 00000047 srt           1 com.ibm.ws.webcontainer.srt.SRTServletRequest getWebAppDispatcherContext
    [1/30/14 11:48:06:732 EST] 00000047 srt           1 com.ibm.ws.webcontainer.srt.SRTServletRequest getAttribute this->com.ibm.ws.webcontainer.srt.SRTServletRequest@2d8d5d85:  name --> javax.servlet.include.request_uri
    [1/30/14 11:48:06:732 EST] 00000047 extension     1 com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor handleRequest relative uri -->[/ps/portal/js/cc.js]
    [1/30/14 11:48:06:732 EST] 00000047 extension     1 com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor handleRequest servletPath [] pathInfo [/ps/portal/js/cc.js]
    [1/30/14 11:48:06:733 EST] 00000047 extension     1 com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor handleRequest  after resolving the uri: path ---> /ps/portal/js/cc.js
    [1/30/14 11:48:06:733 EST] 00000047 extension     1 com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor handleRequest file does not exist --> /ps/portal/js/cc.js
    [1/30/14 11:48:06:733 EST] 00000047 util          1 com.ibm.ws.webcontainer.util.DocumentRootUtils Document Root Utils created with context. pfEDR = null, edr = null
    [1/30/14 11:48:06:734 EST] 00000047 extension     1 com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor isDirectoryTraverse returningfalse , matchstring :/ps/portal/js/cc.js
    [1/30/14 11:48:06:736 EST] 00000047 extension     W com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor handleRequest SRVE0190E: File not found: /ps/portal/js/cc.js
    
    
  • bergmark
    bergmark
    42 Posts

    Re: File Serving from a different location

    ‏2014-01-31T14:32:00Z  

    No luck yet.  The documentation is a little confusing.  It seems to refer to the ibm-web-ext.xmi.

    There is also an "extendedDocumentRoot" in the server.xml, but under jspEngine.

    So, I set them all.  In server.xml, I have:

      <webContainer skipMetaInfResourcesProcessing="true" deferServletLoad="false" extendedDocumentRoot="c:/ib6000.44/webcontent" fileServingEnabled="true"/> 
      <fileServingAttributes name="extendedDocumentRoot" value="${install.dir}/webcontent"/>
      <jspEngine extendedDocumentRoot="c:/ib6000.44/webcontent"/>

    In ibm-web-ext.xmi, I have:

    <pre dir="ltr"> <jspAttributes xmi:id="JSPAttribute_3" name="extendedDocumentRoot" value="c:/ib6000.44/webcontent"/> <fileServingAttributes xmi:id="FSA_1" name="extendedDocumentRoot" value="c:/ib6000.44/webcontent"/> </pre>

    I turned on trace logging, and I see this:

    <pre dir="ltr">[1/30/14 11:46:48:554 EST] 0000001a webcontainer 1 ServiceEvent REGISTERED ServiceRef:[com.ibm.ws.container.service.app.deploy.ModuleRuntimeContainer, com.ibm.wsspi.http.VirtualHostListener](id=180, pid=com.ibm.ws.webcontainer) Event:org.osgi.framework.ServiceEvent[source={com.ibm.ws.container.service.app.deploy.ModuleRuntimeContainer, com.ibm.wsspi.http.VirtualHostListener}={enableJspMappingOverride=false, service.vendor=IBM, enableDefaultIsElIgnoredInTag=false, symbolicLinksCacheSize=1000, metaInfResourcesCacheSize=20, ignoreSessiononStaticFileRequest=false, logServletContainerInitializerClassLoadingErrors=false, directoryBrowsingEnabled=false, component.id=125, fileServingEnabled=true, disableXPoweredBy=false, defaultTraceRequestBehavior=false, serveServletsByClassnameEnabled=false, defaultHeadRequestBehavior=false, dispatcherRethrowsEr=true, adapterFactoryDependency.target=(containerToType=com.ibm.ws.webcontainer.osgi.webapp.WebAppConfiguration), enableErrorExceptionTypeFirst=false, decodeUrlPlusSign=false, skipMetaInfResourcesProcessing=true, component.name=com.ibm.ws.webcontainer, service.pid=com.ibm.ws.webcontainer, parseUtf8PostData=false, disallowAllFileServing=false, asyncTimerThreads=2, disallowServeServletsByClassName=false, exposeWebInfOnDispatch=false, allowIncludeSendError=false, tolerateSymbolicLinks=false, copyAttributesKeySet=false, config.overrides=true, enableMultiReadOfPostData=false, decodeUrlAsUtf8=true, channelWriteType=async, invokeFilterInitAtStartup=true, config.source=file, extendedDocumentRoot=c:/ib6000.44/webcontent, asyncPurgeInterval=30000, doNotServeByClassName=, deferServletLoad=false, listeners=, trustHostHeaderPort=false, asyncMaxSizeTaskPool=5000, asyncTimeoutDefault=30000, httpsIndicatorHeader=, trusted=true, suppressHtmlRecursiveErrorOutput=false, extractHostHeaderPort=false, fileWrapperEvents=false, type=web, service.id=180}] [ ... removed ...] [1/30/14 11:46:48:626 EST] 0000001a jsp 1 ServiceEvent REGISTERED ServiceRef:[com.ibm.wsspi.webcontainer.extension.ExtensionFactory](id=187, pid=com.ibm.ws.jsp.2.2) Event:org.osgi.framework.ServiceEvent[source={com.ibm.wsspi.webcontainer.extension.ExtensionFactory}={keepGenerated=false, component.name=com.ibm.ws.jsp.2.2, config.source=file, useImplicitTagLibs=true, service.vendor=IBM, recompileJspOnRestart=false, useInMemory=false, service.pid=com.ibm.ws.jsp.2.2, extendedDocumentRoot=c:/ib6000.44/webcontent, config.overrides=true, component.id=134, disableResourceInjection=false, disableJspRuntimeCompilation=false, jdkSourceLevel=15, service.id=187}] [1/30/14 11:47:09:876 EST] 0000001d util 1 com.ibm.ws.webcontainer.util.DocumentRootUtils getRoot Attribute name = extendedDocumentRoot, type = staticFile, value = null [1/30/14 11:47:09:876 EST] 0000001d util 1 com.ibm.ws.webcontainer.util.DocumentRootUtils getRoot Attribute name = preFragmentExtendedDocumentRoot, type = staticFile, value = null [1/30/14 11:47:09:877 EST] 0000001d util 1 com.ibm.ws.webcontainer.util.DocumentRootUtils Document Root Utils created with context and config. type = staticFile [1/30/14 11:47:09:877 EST] 0000001d util 1 com.ibm.ws.webcontainer.util.DocumentRootUtils getRoot Attribute name = extendedDocumentRoot, type = jsp, value = null [1/30/14 11:47:09:877 EST] 0000001d util 1 com.ibm.ws.webcontainer.util.DocumentRootUtils getRoot Attribute name = preFragmentExtendedDocumentRoot, type = jsp, value = null [1/30/14 11:47:09:877 EST] 0000001d util 1 com.ibm.ws.webcontainer.util.DocumentRootUtils Document Root Utils created with context and config. type = jsp [ --- chomp ---] [1/30/14 11:48:06:731 EST] 00000047 srt 1 com.ibm.ws.webcontainer.srt.SRTServletRequest getEncodedRequestURI uri --> /p2pd/ps/portal/js/cc.js [1/30/14 11:48:06:732 EST] 00000047 srt 1 com.ibm.ws.webcontainer.srt.SRTServletRequest getRequestURI uri --> /p2pd/ps/portal/js/cc.js [1/30/14 11:48:06:732 EST] 00000047 srt 1 com.ibm.ws.webcontainer.srt.SRTServletRequest getWebAppDispatcherContext [1/30/14 11:48:06:732 EST] 00000047 srt 1 com.ibm.ws.webcontainer.srt.SRTServletRequest getAttribute this->com.ibm.ws.webcontainer.srt.SRTServletRequest@2d8d5d85: name --> javax.servlet.include.request_uri [1/30/14 11:48:06:732 EST] 00000047 extension 1 com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor handleRequest relative uri -->[/ps/portal/js/cc.js] [1/30/14 11:48:06:732 EST] 00000047 extension 1 com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor handleRequest servletPath [] pathInfo [/ps/portal/js/cc.js] [1/30/14 11:48:06:733 EST] 00000047 extension 1 com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor handleRequest after resolving the uri: path ---> /ps/portal/js/cc.js [1/30/14 11:48:06:733 EST] 00000047 extension 1 com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor handleRequest file does not exist --> /ps/portal/js/cc.js [1/30/14 11:48:06:733 EST] 00000047 util 1 com.ibm.ws.webcontainer.util.DocumentRootUtils Document Root Utils created with context. pfEDR = null, edr = null [1/30/14 11:48:06:734 EST] 00000047 extension 1 com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor isDirectoryTraverse returningfalse , matchstring :/ps/portal/js/cc.js [1/30/14 11:48:06:736 EST] 00000047 extension W com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor handleRequest SRVE0190E: File not found: /ps/portal/js/cc.js </pre>

    If you are trying to serve up static content from the extended document root, then it needs to be added as a file-serving-attribute in the ibm-web-ext.xml or ibm-web-ext.xmi.  

    If your web.xml is servlet 2.5 or greater, then it uses ibm-web-ext.xml.  If its =< 2.4 then it uses ibm-web-ext.xmi.

    If you are trying to serve jsp content from inside the extendDocumentRoot, then you'll also need a jsp-attribute.

    There are examples of both the ibm-web-ext.xml and ibm-web-ext.xmi format for extended document root here:

    http://pic.dhe.ibm.com/infocenter/wasinfo/v8r0/topic/com.ibm.websphere.nd.doc/info/ae/ae/rweb_jspengine.html