简体   繁体   中英

Getting the Path to WEB-INF on Openshift Tomcat 6 - JBoss EWS 1.0

I previously used the following to get my context path on Tomcat-5.0.28 and earlier: String context_path = context.getRealPath("/WEB-INF/"); This worked to return the path to that folder. But on OpenShift (Tomcat 6 - JBoss EWS 1.0) this returns

/var/lib/openshift/53.*context_id_here*..18/jbossews/null

The null should be:

work/Catalina/localhost/_/WEB-INF

How can I get the path to the WEB-INF folder on OpenShift using JBOSS/Tomcat?

A little background information: When I ran this struts webapp on my own Tomcat server, I deployed a appname.war file in the webapps directory and waited for it to expand (since I had set that option in the server.xml file). Then I move a folder to webapps/appname/ folder with xml files I need to read and write to for my app to work. On OpenShift I used jar xvf appname.war to extract the war file by hand (because that's the default and I don't know how to change it), and then moved the files folder (from the same directory as the war file in my folder after a git add and push) to work/Catalina/localhost/_/WEB-INF/ This is causing a NullPointerException for me when trying to use that path as shown above.

I think you should be using something like getServletContext or getRealPath, and reading it from the web root instead of trying to find the file on the physical disk. That way your war file can run anywhere without issue. Try looking up both of those and see if one fits your use case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM