This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Web Services and the fly likes WS and tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "WS and tomcat" Watch "WS and tomcat" New topic
Author

WS and tomcat

Paulo Carvalho
Ranch Hand

Joined: Nov 12, 2008
Posts: 56
Hello

I have a little web service that works fine when i deploy it on a tomcat 6.0 server using eclipse.
It is used to transform a XML file (that contains a reference to a file img/logo.gif) into a PDF file. The PDF file is generated with that logo.
The img/logo.gif file is into a JAR file used the WS.

Now, I have created a WAR file to put my WS on a server.
The web service is deployed correctly, i can see the WSDL when I type is URL on a browser, and when I execute it the PDF is correctly generated. The only problem is that the logo image is not put on the file. In the tomcat console a message indicating that the image has not been found is displayed.

Remember: the image file is on a JAR file that is on the WAR file. When I open the jar file on the MyWebservice/WEB-INF/lib directory, I can see clearly that the image file is there with the correct name and correct path.

Just to try, I put the img/logo.gif directory/file on the tomcat root directory, and like this, the image has been found and the PDF generated with the image.

I hope that I have explained well my problem.

What am I missing for the image been found?

Thanks

Best regards
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39576
    
  27
How is the code accessing the image? It needs to use the class loading/resource mechanism, not standard file I/O.


Ping & DNS - updated with new look and Ping home screen widget
Paulo Carvalho
Ranch Hand

Joined: Nov 12, 2008
Posts: 56
Hello

Thanks for your answer.

However, the image path is only indicated on the XML file. No code is used to access it...



Ulf Dittmer wrote:How is the code accessing the image? It needs to use the class loading/resource mechanism, not standard file I/O.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39576
    
  27
OK, so it's not your code that uses the image then, it's some library? Maybe check the library's documentation/forum for cases like this, then.
Paulo Carvalho
Ranch Hand

Joined: Nov 12, 2008
Posts: 56
I dont think its a library problem, because everything works fine:
- when i deploy and use the web service using eclipse + tomcat
or
- when i deploy and use my application normally with the command line and I put the img directory on the root directory of tomcat installation

Paulo Carvalho
Ranch Hand

Joined: Nov 12, 2008
Posts: 56
Maybe you were right about the problem coming from a library that I use. (maybe

For the transformation XML to PDF, I use FOP.
In the log file of my application the error message generated is the following one:

2010-02-15 14:27:29,267 ERROR org.apache.fop.fo.FONode - ExternalGraphic.java:70 - Image not available: url(img\\logo.gif)

So now, if the problem is related with FOP, why FOP can access the message when the web service as been deployed eclipse and why he cannot when the web service as been deployed using standard command line?

Thanks

Best regards
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39576
    
  27
why FOP can access the message when the web service as been deployed eclipse and why he cannot when the web service as been deployed using standard command line?

Does Eclipse use the war file directly, or does it explode it into a directory tree? If the latter, then I can see how it could work.

The FOP docs talk about this at http://xmlgraphics.apache.org/fop/fo.html#external-resources. It is possible to create URLs that point into jar files using a syntax like "jar:..."; that should help in this case.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
Maybe the way you are giving a ref to the image is incorrect. Try an absolute address.

Bill


Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: WS and tomcat
 
Similar Threads
J2ME-WEBSERVICE
JSP and deployment
web service wich calls another web service
Deployment issue
J2EE Web App Deployment questions