-
1. Re: How to give relative path in seam?
mwohlf Mar 9, 2009 5:43 PM (in response to ssahni)afaik META-INF is not for storing parts of your application, the only thing I keep there is persistence.xml, and MANIFEST.MF is generated by the war packer I think...
you can get the path for a file
config.xml
in WEB-INF like this:ServletContext ctx = ServletLifecycle.getServletContext(); String path = ctx.getRealPath("WEB-INF/config.xml");
let me know if
/
in the path works on windows though, maybe you have to use java.io.File.pathSeparator -
2. Re: How to give relative path in seam?
ssahni Mar 12, 2009 10:56 AM (in response to ssahni)Is there no other way of doing so?
As when I did as suggested I got the following compile time error.
package javax.servlet does not exist
I searched this on net. Tried all the solutions but I am not able to get away with this error.
I am using Netbeans 6.5, jboss 4.2.0 GA, seam etc. I could not find servlet.jar in anywhere on my machine. So,I put the servlet-api.jar in classpath but could not proceed.
I found servlet-api.jar in jboss-4.2.0.GA\server\default\lib directory. I even put servlet-api.jar in WEB-INF\lib and included it in classpath but still could not get this error removed.Please let me know is there any other way or I have to try on this only?
-
3. Re: How to give relative path in seam?
luxspes Mar 12, 2009 3:55 PM (in response to ssahni)if package javax.servlet does not exist your applications should not even run, javax.servlet is a core requirement for any web based java application (with or without Seam)
Are you sure you correctly created a web project in netbeans?
-
4. Re: How to give relative path in seam?
ssahni Mar 13, 2009 7:29 AM (in response to ssahni)I imported an existing project and the project which I imported is 'Web Free-Form Application'
And since the project already contains the build folder so I am not able to create a 'Web Application with existing resources'.
When I access the application using 'http:////localhost:8080//' I am able to access its pages.
So please let me know where is the mistake. Does for 'Web Free-Form Application' it is not supposed to work?
Thanks
-
5. Re: How to give relative path in seam?
luxspes Mar 13, 2009 11:21 PM (in response to ssahni)What IDE was used to create that
existing project
? Or is it compiled using a custom ant file? -
6. Re: How to give relative path in seam?
ssahni Mar 16, 2009 4:59 AM (in response to ssahni)Netbeans was used to create that existing project. It has an custom ant file which is used to build that project.
Does that matter?
Thanks
-
7. Re: How to give relative path in seam?
keeper Dec 4, 2009 3:05 PM (in response to ssahni)Simple test:
If you are using jbosstools, try creating a blank seam project and run it to test your environment. You should then import the classes and views from the other project.
-
8. Re: How to give relative path in seam?
mikkus70 Dec 4, 2009 5:20 PM (in response to ssahni)When I have config files I need to retrieve from code, I usually put them under
WEB-INF/classes
and load them as classpath resources:DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); Document doc = docBuilder.parse(new File(this.getClass().getClassLoader(). getResourceAsStream("/Try.xml"));
This also works if you put the file in a subdir of
WEB-INF/classes
(just specify its path relative toWEB-INF/classes
).