Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support allowLinkng and cache setting on tomcat 8+ #99

Closed
terwer opened this issue Nov 9, 2022 · 4 comments
Closed

Support allowLinkng and cache setting on tomcat 8+ #99

terwer opened this issue Nov 9, 2022 · 4 comments

Comments

@terwer
Copy link

terwer commented Nov 9, 2022

Is your feature request related to a problem? Please describe.
Sometimes,we will deploy a app path with symbol links,how ever, tomcat default load the real filesyatem,this path with throw file not found Exception.

Describe the solution you'd like
tomcatdir/conf/Catalina/localhost/appname.xml is configurable to fix this as a best practice,See https://stackoverflow.com/a/43673455/4037224

But SmartTomcat now create appname.xml without this.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Context docBase="mydocpath">
  <Resources>
 </Resources >
</Context>

What expected is

<Context docBase="mydocpath">
  <Resources allowLinking="true" cacheMaxSize="100000" cachingAllowed="true">
 </Resources >
</Context>

Go through the source ,I found a solution

Change com.poratu.idea.plugins.tomcat.conf.TomcatCommandLineState.java createResourcesElementIfNecessary() mthod should add this

private Element createResourcesElementIfNecessary(Document doc, Element contextRoot) {
    Element resources = (Element) contextRoot.getElementsByTagName("Resources").item(0);
    if (resources == null) {
        resources = doc.createElement("Resources");
        // fix cache and linking
        resources.setAttribute("allowLinking", "true");
        resources.setAttribute("cachingAllowed", "true");
        resources.setAttribute("cacheMaxSize", "100000");
        contextRoot.appendChild(resources);
    }
    return resources;
}

Describe alternatives you've considered
The above options can be configuable.This is just a example to show how to suit this suitation.

@yuezk
Copy link
Collaborator

yuezk commented Nov 18, 2022

Thanks for the report and look into this.

According to the documentation (https://tomcat.apache.org/tomcat-9.0-doc/config/resources.html
), cachingAllowed is true by default. And the default value for cacheMaxSize is 10240 (10 M). Is the default configuration good for you?

allowLinking is false by default, but it's not commonly used, for your case, I'm going to add a registry so that you can enable it on your needs.

Any questions?

@terwer
Copy link
Author

terwer commented Nov 19, 2022

Thanks , my company project is so large, in my case, 10240 is not enough, so also add a registry for cacheMaxSize will be better.

yuezk added a commit to yuezk/SmartTomcat that referenced this issue Nov 19, 2022
yuezk added a commit that referenced this issue Nov 19, 2022
@terwer
Copy link
Author

terwer commented Nov 21, 2022

I tried thhe latest updated version 4.3.8. it works great!
Thanks very much!

@terwer terwer closed this as completed Nov 21, 2022
@yuezk
Copy link
Collaborator

yuezk commented Mar 1, 2023

How to configure cacheMaxSize and allowLinking for SmartTomcat?

Search the Registry action then:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants