Forum Stats

  • 3,827,045 Users
  • 2,260,736 Discussions
  • 7,897,150 Comments

Discussions

Load a File from resource in Servlet - Webcenter Portal

Jack Issac
Jack Issac Member Posts: 78 Blue Ribbon
edited Apr 11, 2019 10:30AM in WebCenter Portal

Hi,

I am using JDev 12.2.1.3 and working on Webcenter Portal is 12.2.1.3.0 (Bundle Patch 12.2.1.3.190115)

I am developing adf applications for wc portal in portal extension project. There are servlet and xslt file and xslt is using in servlet class with getServletContext().getResourceAsStream("resource/util/xslt/XSLT001.xslt");

there is no problem in testing, my test page is working on integrated weblogic and file is loading.

Also file is XSLT001.xslt and in PortalExtensionProject/public_html/resource/util/xslt/

But when I develop it as a shared library with PortalSharedLibrary project; file is not loading / not finding by servlet class

Now,

When we develop as a shared library extension project to webcenter portal; is resource path or something like this changing on webcenter portal for access to extension project's resources folder under public_html?

How can access this resource folder in public_html?

Is it wrong approach with getServletContext().getResourceAsStream() for access a file from servlet class in webcenter portal? How I must use it for access?

Or what is right approach for store xslt file in extension project and access it in webcenter portal ?

If you can help, I would appreciate.

Thanks

Jack

Tagged:

Best Answer

  • Daniel Merchán
    Daniel Merchán Enterprise Achitect Member Posts: 2,192 Gold Trophy
    edited Apr 9, 2019 5:23AM Answer ✓

    Hi Jack,

    Already solved? Or do you need me to run a quick test case?.

    • When deploying in WCP are you sure is in the Classpath your XLS file?
    • Have you tried Thread.getCurrentThread().getContextClassLoader().getResourceAsStream() instead?
    • Is it fully need to be part of the PortalSharedLibrary? Cannot you load it by a call to Oracle WebCenter Content or place it in file system? You can configure a JVM startup argument to point a folder where is it or include a folder as part of the Classpath of WebCenter Portal.

    Kind regards.

Answers

  • Daniel Merchán
    Daniel Merchán Enterprise Achitect Member Posts: 2,192 Gold Trophy
    edited Apr 9, 2019 5:23AM Answer ✓

    Hi Jack,

    Already solved? Or do you need me to run a quick test case?.

    • When deploying in WCP are you sure is in the Classpath your XLS file?
    • Have you tried Thread.getCurrentThread().getContextClassLoader().getResourceAsStream() instead?
    • Is it fully need to be part of the PortalSharedLibrary? Cannot you load it by a call to Oracle WebCenter Content or place it in file system? You can configure a JVM startup argument to point a folder where is it or include a folder as part of the Classpath of WebCenter Portal.

    Kind regards.

  • BSRT
    BSRT Member Posts: 8
    edited Apr 11, 2019 4:24AM

    Hi Jack,

    I have had this issue; and it solved with class loader,

    ClassLoader will locate run root path of jar and it will find resource folder.

    ClassLoader cloader = this.getClass().getClassLoader();

    pXSLT = cloader.getResourceAsStream("resource/util/xslt/XSLTransform001.xslt");

    Have  a nice day.

    Burak

    Jack Issac
  • Daniel Merchán
    Daniel Merchán Enterprise Achitect Member Posts: 2,192 Gold Trophy
    edited Apr 11, 2019 4:50AM

    Thanks for sharing this with us

  • Jack Issac
    Jack Issac Member Posts: 78 Blue Ribbon
    edited Apr 11, 2019 10:30AM

    Hi,

    Thanks much for your helps.

    it is working both of

    Thread.getCurrentThread().getContextClassLoader().getResourceAsStream()

    and

    this.getClass().getClassLoader().getResourceAsStream("resource/util/xslt/XSLTransform001.xslt")