1 of 1 people found this helpful
so you are claiming that WebUtils.getRealPath() does not work properly.
I really don't know what that code does, the proper way of doing it is what you did for "manual" parsing it.
so real question is does servletContext.getRealPath("/config-data/TESTDEV") return proper path?
also you could use servletContext.getResourceAsStream(path) to directly get inputStream to that file.
also can you try with WildFly nighly build (we are currently just before beta1 release)
there ware some changes in this area and i am not sure if it will help your problem.
yes, as you said , The basic question is that servletContext.getRealPath("/config-data/TESTDEV") can not return proper path , but when i deployed web application in websphere or tomcat , it can get the proper path . there are some code pictures :
when i start up the wildfly and visit the servlet , get the answer as following:
it can't get the true path , it returns null , but in tomcat , the same web application , get answer as following :
No matter how, I really appreciate your answer !
Can you try with WildFly nightly build?
I think it should be fixed there
Thank you very much ! If you could give me an example that is better for me !
1 of 1 people found this helpful
The WildFly nightly build that Tomaz mentions is available here WildFly nightly builds available. Just download the binary like you would do with any released version and start using it with your applications.
ok , thank you !
Did it work for you with nightly build?
No , It doesn't work . Though i use the latest version of wildfly-8.0.0.Beta1 , it also can not parse "/config-data" in windows . That is to say , It can't parse the backslash followed by a string . but in linux/unix is ok .
Make sure that you're aware that this method is not required to return anything useful at all. A portable application should not rely upon it. Many JavaEE implementations explode deployments onto the file system, but they're not required to do that.
That said, if it does return anything then it should be a path consistent with the platform on which the application is running. Windows paths should use "\" separators. It's a bug if it's not doing that.
First , Thanks for your answer .
The question is that I had been to deploy applications on wildfly server of Linux environment . It can run normally . But when i try to deploy the same application on windows , The application can't be deployed , After i look for reasons carefully , I found the line of code error is "WebUtils.getRealPath(config-data/TESTDEV)" .
In the application , The function of this method is expected to return a true path string according to i specified virtual path "config-data/TESTDEV" and then according to the returned string to create the corresponding local directory when the server start up . However , In the Windows environment ,When i deployed the application on Wildfly , The method of "WebUtils.getRealPath(config-data/TESTDEV)" can not work correctly . Error message appears when the server start up . As followings :
"Caused by: java.io.FileNotFoundException: ServletContext resource [/config-data/TESTDEV] cannot be resolved to absolute file path - web application archive not expanded"
Your code is just fine.
It is a bug in undertow, that should be addressed properly now.
You can try it by building undertow from github and replacing it in wildfly distro.
Yes , I'm trying do it . If i have any questions , I'll describe in the community . Thanks !
Hi , Tomaz .
I'm sorry so long to reply to you , According to what you said, In these days , I download the undetow from https://github.com/undertow-io/undertow and rebuild it again and again .
Util now , Even though I deployed my peoject on wildfly-8.0.0.Beta2-SNAPSHOT , This method "WebUtils.getRealPath(/config-data)" also can not be resolved correctly . In addition , I replaced the undertow in wildfly-8.0.0.Beta2-SNAPSHOT with rebuild undertow from github , The problem still exist .
I'm not sure whether i do is correct or not, But I just think ,under the undertow-core , The class of FileResourceManager whtin io.undertow.server.handlers.resource , there is a method of getResource() in FileResourceManager , The logic of if conditional has some problems , Here attached two artwork :