*
The moose likes Struts and the fly likes File path after deployment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "File path after deployment" Watch "File path after deployment" New topic
Author

File path after deployment

Gaurav Pawar
Ranch Hand

Joined: Sep 12, 2006
Posts: 37
The bean(model) in my struts application uses the following statements

...
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document domDoc = docBuilder.parse("Records.xml");
...


and further returns the values in XML file.

THis executes fine as a standalone java application.
After deploying my app in Tomcat while debugging the program stops at
'Document domDoc = docBuilder.parse("Records.xml");'

I have placed Records.xml in the classes folder under WEB-INF.

Any suggestions how I should specify tomcat specific path??

Thanks,
Gaurav.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
There are undoubtedly other classes upon with this class is dependent. You need to find out what the dependencies are and either include the class files themselves in WEB-INF/classes or the jar files in WEB-INF/lib. In order to find out the dependencies, I'd start by looking at what is in the classpath of your stand-alone application.


Merrill
Consultant, Sima Solutions
Gaurav Pawar
Ranch Hand

Joined: Sep 12, 2006
Posts: 37
Hey Thanks for the reply.
Actually i have just 3 classes.
1. LoginAction.class
2. LoginForm.class
3. LoginBean.class
and on xml file -- records.xml

Login Bean reads the "records.xml" file, checks node values and returns result to the LoginForm.

I have all these placed in WEB-INF/classes.

Still do not get it right...

Gaurav

Gaurav Pawar
Ranch Hand

Joined: Sep 12, 2006
Posts: 37


Hi all,
The solution to this is,
Place the file in classes under webapps (this is what my requirement was)
and then use the command

InputStream in = myLALoginBean.class.getResourceAsStream("/Records.xml");
---- followed by

DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document domDoc = docBuilder.parse(in);

Thanks,
Gaurav Pawar
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File path after deployment
 
Similar Threads
requested resource() not found for simple HTML?
From .Net DataTable to Java which object?
build DOM Object of a file whose path is given
XML file Location
disappearing web apps