Cannot load file in a java Web Service
I have a Web service developed in Java. One of my services doesn't work. After investigating the problem I found out that [probably] when I try to load a file, I get an exception so it throws a java.lang.reflect.InvocationTargetException
. I tried running this piece of code and every time I got False.
java.io.File f = new java.io.File("svncache.collection");
System.out.println(f.exists());
I tried copying the file in the Tomcat's root (\webapps\ROOT) but it didn't work. I ran this:
System.getProperty("user.dir")
and copied the file to the folder returned by this function. After this, the function returned true
so I guess this is the root folder I should work with. But when I run the service again, I get the same exception. I run this service on Windows 7 x64 and Eclipse for Java EE Helios.
Any suggestions on what I should do?
Thanks.
Edit: I should mention that this was 开发者_Python百科originally a Java project (not a Web application). I had to use it as a Web Service. The first suggestion was to use Endpoint.publish. Here:
Add a web service to a already available Java project
After conversion [and a little edit] it ran perfectly without any problems. But I needed to log user activity and as suggested I converted the project to a Dynamic Web project and created a new Web service: Java - Rich logging in web services and Java - Create a web service from an available class
So basically I'm running in circles. Using Endpoint.publish doesn't support logging, using Web Services won't allow me to load files and the original Java project cannot be used as a Web Service for my Silverlight application.
Please help me. I'm so frustrated. Thanks. PS: Sorry I had to change the question to clarify my problem and the title to match that.
You need to run that test in your webapp, not just from within an ordinary Java application. If it works in your webapp, you have definitely misdiagnosed the problem. If it doesn't... well, you can fix that.
精彩评论