Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9141757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:41:15+00:00 2026-06-17T09:41:15+00:00

In a webapp deployed in tomcat with security manager, this works: URL url =

  • 0

In a webapp deployed in tomcat with security manager, this works:

URL url = servletContext.getResource("/WEB-INF/internal/tika/tika-app-1.2.jar");
// test to see if the content can be read
String test = IOUtils.toString(url);

Tomcat uses jndi for internal URLs. According to tomcat documentation about security manager (link here), there is an implicit permission granted to resources inside the war file.

However, this doesn’t work:

URL url = servletContext.getResource("/WEB-INF/internal/tika/tika-app-1.2.jar");
ClassLoader cl = new URLClassLoader(new URL[] { url }, this.getClass().getClassLoader());
// load a class from the jar
Class<TextExtractor> clz = (Class) cl.loadClass(" ... some class ...");
delegate = clz.newInstance();

The exception that I get is this:

Caused by: java.security.AccessControlException: access denied (org.apache.naming.JndiPermission jndi:/localhost/my_webapp/WEB-INF/internal/tika/tika-app-1.2.jar)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.net.URLClassLoader$4.run(URLClassLoader.java:515)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.getPermissions(URLClassLoader.java:513)
at java.security.SecureClassLoader.getProtectionDomain(SecureClassLoader.java:235)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at com.sample.myClass.afterPropertiesSet(TikaWrapper.java:38)

I guess my first question is: why?

If I add this to catalina.policy file then it works:

permission org.apache.naming.JndiPermission "jndi:/localhost/my_webapp/WEB-INF/internal/tika/tika-app-1.2.jar";

However, the client is not willing or can’t change his policy file.

My second question is: any idea what to do? I can’t put the jar under /WEB-INF/lib, otherwise I’d done it already.
I can put it outside tomcat all together and load it with a file:// based URL, but I am trying to avoid it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:41:16+00:00Added an answer on June 17, 2026 at 9:41 am

    As for your first question, there is a small note about class loading when running under a security manager in the documentation, citing it here for convenience:

    When running under a security manager the locations from which classes are permitted to be loaded will also depend on the contents of your policy file.

    So it appears that by default a webapp classloader is allowed to load classes from WEB-INF/lib and WEB-INF/classes directories only. In your case, it looks like you’re assigning the webapp classloader as a parent to your custom classloader, and therefore the latter, same as its parent, is only able to load classes from WEB-INF/lib and WEB-INF/classes.

    As for what to do, since client doesn’t want or can’t change the policy file, consider trying to change the policy programmatically. There is a good example here. However, it will only work if the current set of permissions allows to call java.security.Permission.setPolicy() method, and I bet it doesn’t because that would set a JVM-system wide policy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two different security constraints in my web app deployed on Apache tomcat
I've got a Java web app (WAR) deployed to Tomcat on a remote Solaris
I copy-paste-deployed a webapp to a local installation of Tomcat 6 (I place my-app
I have a web app deployed with Tomcat Server and i have an exception.
I have a web app deployed on Tomcat on Windows 7. I have various
I've deployed, after some struggle, a web-app on a (remote) Tomcat 5.5 server (Turnkey
We are experiencing some slowdowns on our web-app deployed on a Tomcat 5.5.17 running
We are performing some JMeter tests on a JBoss 4.0.5 deployed web app. We
I am developing a webapp using PHP and MongoDB. In this app I keep
I'm using spring and acegi in a webapp that's deployed in tomcat 5.5.26. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.