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

Make Tomcat allow a .JAR file that contains a webapp #146

Merged
merged 1 commit into from
Apr 20, 2016

Conversation

trustin
Copy link
Member

@trustin trustin commented Apr 19, 2016

Motivation:

  1. Tomcat does not allow us to use a JAR file whose extention is not
    '.war' as a web application:
  1. When TomcatService is created via forClassPath(Class, String), the
    service construction fails if the specified class is packaged in a .JAR
    file. forClassPath(Class, String) currently requires the specified class
    to exist in a directory, which is not always true.

Modifications:

  • Replace Tomcat's StandardRoot with ArmeriaWebResourceRoot to accept
    any JAR files
  • Add JarSubsetResourceSet which allows a user to specify non-root web
    application path in a JAR file
    • Note that the upstream JarResourceSet is used unless specified
      explicitly.
  • Add TomcatConfig.jarRoot()
  • Add TomcatUtil.isJar() to determine if the specified path is really a
    JAR-compatible archive file
  • Add the tests for the issue (2) in the Motivations section

Result:

A user can use TomcatService.forClassPath(Class, String) even when the
specified class is packaged in a JAR file.

@trustin trustin added the defect label Apr 19, 2016
@trustin trustin added this to the 0.14.0.Final milestone Apr 19, 2016
@trustin trustin force-pushed the tomcat_allow_jar_webapp branch 2 times, most recently from 300b45c to 49b9991 Compare April 19, 2016 07:59
for (Enumeration<JarEntry> i = jar.entries(); i.hasMoreElements();) {
final JarEntry e = i.nextElement();
if (!e.isDirectory()) {
numEntries++;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked you for check intend. It's for check all entry is fine?
I think we also possible return true this line , if this method just checks jar is not empty.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I wanted to check if all entries are OK, but I guess it's not the responsibility of this method. Let me update it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@inch772
Copy link
Contributor

inch772 commented Apr 20, 2016

LGTM!

Motivation:

1) Tomcat does not allow us to use a JAR file whose extention is not
'.war' as a web application:

- https://github.com/apache/tomcat/blob/4166a2b96f482f8bf7b0024836dab53d3594710e/java/org/apache/catalina/webresources/StandardRoot.java#L722

2) When TomcatService is created via forClassPath(Class, String), the
service construction fails if the specified class is packaged in a .JAR
file. forClassPath(Class, String) currently requires the specified class
to exist in a directory, which is not always true.

Modifications:

- Replace Tomcat's StandardRoot with ArmeriaWebResourceRoot to accept
  any JAR files
- Add JarSubsetResourceSet which allows a user to specify non-root web
  application path in a JAR file
  - Note that the upstream JarResourceSet is used unless specified
    explicitly.
- Add TomcatConfig.jarRoot()
- Add TomcatUtil.isZip() to determine if the specified path is really a
  ZIP-based archive file
- Add the tests for the issue (2) in the Motivations section

Result:

A user can use TomcatService.forClassPath(Class, String) even when the
specified class is packaged in a JAR file.
@inch772
Copy link
Contributor

inch772 commented Apr 20, 2016

👍

@inch772 inch772 merged commit 7c08f44 into line:master Apr 20, 2016
@trustin trustin deleted the tomcat_allow_jar_webapp branch April 20, 2016 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants