1

I have two applications: a client in flex and a server in Java. When I deploying the application inside flex builder with the tomcat server inside as well, everything works fine. But now I'm trying to deploy in apache tomcat outside the flex/eclipse builder and I have a problem.

I think the problem is with relative/absolute paths but I do not know how to resolve it. In my Java application I have to access a database and a get a file from it. I use a properties to set a path where I want to download that files like this:

pacs.ruta=C:\\resources\\

And then I need to access to that file so in use this code:

fin = new FileInputStream(pacsRuta+""+f.getName());

where f.getName() gives me the name of the file so I get the path of the file with the path I set in pacs.ruta and the files name. I do not know why it does not work. I tried to put

pacs.ruta=/resources/

to associate with a folder in my application but It does not work.

Could someone give me an advice? Do you think it is the problem? Because the whole application works fine deploying in a tomcat server outside the flex/eclipse builder but when this code is called the application does not work.

2 Answers 2

1

Try putting it in WEB-INF/classes so it's in CLASSPATH and use getResourceAsStream() to read it from the servlet context.

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for your quick reply but I tried to do it but probably I do not know how to do it. I do not use servlets, it's just a java a application. Is it needed to set something in server.xml inside catalina?? I read something about context-path but i do not also where I have to put it. I just copy my webContent files inside the webapps in the tomcat and trying to deploy.
I trying using String s=ConsultaPACS.class.getResource("");s = s.substring(6); to set the path. ConsultaPACS is the class where I made the call to receive the file and that's the path where my databases files are downloaded.
What good is a Java application running on Catalina without servlets or JSPs? No, you should be loading it from the servlet context. I'd also recommend doing it using a ServletContextLoaderListener that you configure in your web.xml
Sorry I thougth you mean servlet applet.Its true I have to used servlets to get blazeds work and I configure them in web.xml: <servlet><servlet-name>RDSDispatchServlet</servlet-name> <display-name>RDSDispatchServlet</display-name> <servlet-class>flex.rds.server.servlet.FrontEndServlet</servlet-class> <init-param> <param-name>useAppserverSecurity</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>messageBrokerId</param-name> <param-value>_messageBroker</param-value> </init-param> <load-on-startup>10</load-on-startup></servlet>
Can you explain me more how I can use getResourceAsStream()? I make a .xml file with the context path and put it inside catalina/localhost but it does not work. Probably it's something of configuration...
0

Finally I get it works, it was a problem with permisions.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.