Open raafaar opened 8 years ago
I'm not sure we can easily replicate this with a unit test - but the change makes total sense (that project was created before Boot existed).
Could you send a PR for this?
Thank you for your answer. I'm new to github's terminology. I'll assume PR is a pull request... So, Is that ok to send a PR in this project even if I have no tests for that change?
Hello, I have a problem deploying a spring-boot project using springmvc-router. To solve this problem, I made changes in a class of springmvc-router. It worked for me, but I would like to contribute with the project making a fork and a series of tests for this change.
Here is where I'd like to ask for your help: I tried, but I don't know how to properly create tests which covers this aspect.
Description of the issue
I've a spring-boot project which uses springmvc-router. I can run it with
gradle bootRun
and deploy it in Tomcat without problems, but the web application doesn't start in WebLogic 12c.This is a simple project, it only has two or three actions.
When I try to deploy it in weblogic, it causes the following error:
This is due a weblogic feature that creates the
_wl_cls_gen.jar
package where all my classes and configuration files are kept. Looking at the log, I browsed the Router code and I found that it tries to usegetFile()
in theparse(Resource fileResource)
method of theRouter
class, but since my routes.conf is inside the jar (created by weblogic), then spring cannot access it causing a FileNotFoundException.So I found that if I change this line
String fileAbsolutePath = fileResource.getFile().getAbsolutePath();
to thisString fileAbsolutePath = fileResource.getURL().getPath();
in the Router class, then I can stop the exception to occur and my application works as expected.Although it worked for me, I would like to contribute with the project making a fork and a series of tests for this change. I am not sure if I should make a unit test or a cucumber case. I tried adding a case into
handler_mapping.feature
and changing the test context xml to load amappingroutes.conf
file which is inside a jar, but I couldn't get the same exception (actually I've got a failing test instead of an error).Additional information
I don't like the idea of making a test after the code has changed, but I had to.
Before changing the springmvc-router code, I found another solution; but more than a solution, is a kind of hack: I manually put the
mappingroutes.conf
file into the WEB-INF directory (instead of the/WEB-INF/classes/
which is the default for spring-boot). Then I told springmvc-router to load it from/WEB-INF/mappingroutes.conf
.I've read that is always better not to use a
getFile()
method if it is a 'InputString' equivalent, but, please tell me if I am making a mistake of is there a better solution.