Skip to content

Support for last-modified resolution in Tomcat's unpackwar=false mode [SPR-13393] #17434

Closed
@spring-projects-issues

Description

@spring-projects-issues

Gaurav Rawat opened SPR-13393 and commented

Hi I am using spring data rest provided HAL browser to view my sprign data rest HAL based api .So far things have been good when I am running it via eclipse or as a spring boot app for testing in my local tomcat on windows.Though when I deploy on aws on a tomcat container (as a spring boot war) I get this weird error as below when I browse to the root or the address of the hal browser /browser/index.html#

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Mon Aug 24 07:05:46 UTC 2015
There was an unexpected error (type=Internal Server Error, status=500).
Jar URL cannot be resolved to absolute file path because it does not reside in the file system: war:jar:file:/deployment/wars/hfds.1.3.war!/WEB-INF/lib/spring-data-rest-hal-browser-2.4.0.BUILD-SNAPSHOT.jar

-I am still not able to find a valid justification on why its not being able to find the provided hal browser though things work fine in local .Am I missing something can someone please help .Is this a bug with spring framework or otherwise-

This works if unpackwar=true but doesnt if unpackwar is set to false - That seems to cause the real issue
UPDATE

The stack trace shows the issue coming from the code below when unpackw=false ,I get war:jar:file which causes the issue due to this code section in org.springframework.util.ResourceUtils

public static File getFile(URL resourceUrl, String description) throws FileNotFoundException {
    Assert.notNull(resourceUrl, "Resource URL must not be null");
    if (!URL_PROTOCOL_FILE.equals(resourceUrl.getProtocol())) {
        throw new FileNotFoundException(
                description + " cannot be resolved to absolute file path " +
                "because it does not reside in the file system: " + resourceUrl);
    }
    try {
        return new File(toURI(resourceUrl).getSchemeSpecificPart());
    }
    catch (URISyntaxException ex) {
        // Fallback for URLs that are not valid URIs (should hardly ever happen).
        return new File(resourceUrl.getFile());
    }
}

Not sure it should go to the Spring data bucket or Spring framework in general .

+UPDATE NEW+

ALso after more analysis seems this is not an environment specific issue but it occurs if a resource like HAL_Browser is packed inside a jar and tomcat unpackwar is set to false .In this situation somehow spring is not able to extract contents from the jar file and render them .


Affects: 4.1.7, 4.2 GA

Reference URL: http://stackoverflow.com/questions/32176383/not-able-to-open-spring-default-hal-browser-provided-by-spring-data-rest-on-aws

Issue Links:

Referenced from: commits 302a069, 1c3a668, 155bbf5

Backported to: 4.1.8

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)in: dataIssues in data modules (jdbc, orm, oxm, tx)status: backportedAn issue that has been backported to maintenance branchestype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions