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

ResourceUtils.getFile(java.net.URL, java.lang.String) throws FileNotFoundException if the URL has protocol of jar [SPR-994] #5705

Closed
spring-projects-issues opened this issue May 30, 2005 · 4 comments
Assignees
Labels
status: declined A suggestion or change that we don't feel we should currently apply

Comments

@spring-projects-issues
Copy link
Collaborator

Antony Sohal opened SPR-994 and commented

I think this is a bug because when this method is called, if the URL object does not have a protocol of file, it throws an FileNotFoundException. In my instance, my URL object was a location of a jar file within an EAR. After some debugging, i found that it would be better to check that the URL string start with file:// rather then check the protcol.

I came across this bug, when I was trying to add Mapping Jar Locations to a org.springframework.orm.hibernate.LocalSessionFactoryBean.
My hibernate config files are in the jar files.

public static File getFile(URL resourceUrl, String description) throws FileNotFoundException {
	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);
	}
	return new File(URLDecoder.decode(resourceUrl.getFile()));
}

Antony


Affects: 1.1.5

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Indeed, resolution of a resource as java.io.File is currently just supported for URLs with "file:" protocol. I'm not aware of a way to create a java.io.File object for any other resource: if the specified resource resides within a JAR/WAR/EAR file, we can't create a file system reference for it...

Note that Hibernate's Configuration.addJar(File) method requires a java.io.File object to be passed in - that is, it expects the jar file to reside in the file system... As long as that doesn't change, I see no way to enable this for non-file URLs in Spring.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

As I indicated, this would require some Hibernate Configuration method that allows for registering a jar file with something other than a java.io.File reference.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

ferrenq commented

Hello,
We are facing the same issue ie FileNotFoundException but through a different use case:
Using Spring web flow and WebLogic 10, flow xml file definitions are deployed within jar files under WLS working folder.
This leads to referenced error.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues added type: bug A general bug status: declined A suggestion or change that we don't feel we should currently apply labels Jan 10, 2019
@spring-projects-issues spring-projects-issues removed the type: bug A general bug label Jan 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

No branches or pull requests

2 participants