views:

232

answers:

1

Hi.

I'm developing a Jboss web service that requires to access files which are in a folder of the project. When I deploy the web service, it creates a .jar, but the folder doesn't go inside of it, even if I added it to build path.

How do i tell jboss to place the folder inside of the .jar?

Thanks in advance.

+1  A: 

I assume, because you explicitely say "jar" that your webservices are ejb endpoints, and not JAX-RPC servlet based webservices (because those would be packaged in a .war).

Unlike servlets, who are somewhat capable of finding files inside the project (as long as you can express their location as an offset to the web folder you can determine theire real location with ServletContext's getRealPath() EJB's don't have any "automatic" notion of directories.

So even if you could convince Eclipse to deploy files for you, I doubt it would help you much.

EDIT: in a web-archive (.war) everything inside the web folder will be accessible by the servlets at runtime via the mechanism explained before. Do note however that files inside web are accessible via the web interface, except those inside the WEB-INF folder, so I'd suggest to at least store your files somewhere in a subdirectory of WEB-INF.

On a more global scale you should also ask yourself the question if you really must deploy these files with the application - and redeploy them with each redeployment. One solution in that case is to create some directory on the server (say c:/applicationfiles), create a JVM option e.g. -Dserverfilestore=c:/applicationfiles and have your application determine that directory with

String storebase=System.getProperty("serverfilestore");

The rest should be quite obvious. This solution will also work with you EJB services btw.

fvu
Yes, I am using EJB endpoints. So if I wanna a file folder, I need to use JAX-RPC, which will be deployed as .war, right?
nunolourenco
Yeah, I know that. That was the first solution I made. But this project is to a course I am taking and i didn't find polite as the teacher to do this. But thanks.
nunolourenco
If you're satisfied with the answer you should accept it.
fvu