You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by anjan bacchu <an...@gmail.com> on 2022/08/22 17:56:58 UTC
Find the effective classpath in a spring webapp's Controller
Hi there,
I have a Controller in a spring webapp deployed to tomcat as a .war
file(this is not a boot app).
I have this code in the Controller
this.getClass().getClassLoader().getResourceAsStream(licenseFile)
The licenseFile is a 3rd party license file in our artifactory repository
and gets deployed by the gradle build to the WEB-INF\lib directory.
As expected, this licenseFile is not accessible to the Controller and this
fails.
2 Questions
============
1) How do I find the effective classpath for this webapp at runtime ? (I
read the howto at
https://tomcat.apache.org/tomcat-9.0-doc/class-loader-howto.html )
2) Is there a way to read this licenseFile in the WEB-INF\lib directory
from the Controller ?
Thank you,
BR,
~A
Re: Find the effective classpath in a spring webapp's Controller
Posted by Mark Thomas <ma...@apache.org>.
On 22/08/2022 18:56, anjan bacchu wrote:
> Hi there,
>
> I have a Controller in a spring webapp deployed to tomcat as a .war
> file(this is not a boot app).
>
> I have this code in the Controller
>
> this.getClass().getClassLoader().getResourceAsStream(licenseFile)
>
>
> The licenseFile is a 3rd party license file in our artifactory repository
> and gets deployed by the gradle build to the WEB-INF\lib directory.
>
> As expected, this licenseFile is not accessible to the Controller and this
> fails.
>
> 2 Questions
> ============
> 1) How do I find the effective classpath for this webapp at runtime ? (I
> read the howto at
> https://tomcat.apache.org/tomcat-9.0-doc/class-loader-howto.html )
>
> 2) Is there a way to read this licenseFile in the WEB-INF\lib directory
> from the Controller ?
ServletContext.getResource("/WEB-INF/lib/licenseFile");
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org