1

I am trying to access a JAX-WS 2.2 service from Tomcat6 with Java6. For what I have researched there is a problem with this, as Java tries to use first some of its default javax.xml.ws libraries which doesn't have the WebFault.messageName method. So it fails with this error:

GRAVE: javax.xml.ws.WebFault.messageName()Ljava/lang/String;
java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName()Ljava/lang/String;
at com.sun.xml.ws.model.RuntimeModeler.processExceptions(RuntimeModeler.java:1162)
...

The solution seems to be creating an "endorsed" directory in JAVA_HOME/jre/lib/ (or in TOMCAT_HOME) and putting there the required libraries.

However, some people say the library needed is webservices-api.jar, for example, here (#Issue 3):

https://www.fromdev.com/2010/01/trying-to-run-jax-ws-sample-application.html

And other people talk about jaxb-api-2.2.jar and jaxws-api.jar, for example here:

Grizzly - java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName

I have downloaded all three of them and placed them in both directories (inside JAVA_HOME and TOMCAT_HOME).

My problems:

· I have no issues accessing this service from a standalone java6 application, both from Netbeans or running the .jar from command-line, it fails only from Tomcat. So I am not sure if the stated above is the cause of my problems. Because, shouldn't it also fail from command line?

· I am not being able to test the above solutions, because Tomcat does not seem to know the "endorsed" directory. When I run this in the standalone application:

System.out.println(System.getProperty("java.endorsed.dirs"));

It prints:

/usr/lib/jvm/jdk1.6.0_45/jre/lib/endorsed

However, Tomcat prints a blank line.

I have tried to modify tomcat6.conf, with this (and restarting, of course):

JAVA_OPTS="-Djava.endorsed.dirs=/usr/share/tomcat6/endorsed -Djavax.sql.DataSource.Factory=org.apache.commons.dbcp.BasicDataSourceFactory -Djava.awt.headless=true -Xms1024m -Xmx1024m -XX:PermSize=1024m -XX:MaxPermSize=1024m"

But it still doesn't seem to know that property.

So, how can I tell Tomcat where the endorsed directory is located? Do you think that my problem can be another than the stated, as it works from a standalone application?

Marcos Fernandez
  • 556
  • 9
  • 22

1 Answers1

0

So, the solution:

Do you think that my problem can be another than the stated, as it works from a standalone application?

No, that was exactly the problem.

how can I tell Tomcat where the endorsed directory is located?

It seems that setting this option in tomcat6.conf:

-Djava.endorsed.dirs=/usr/share/tomcat6/endorsed

is not enough. It is required to create a variable called JAVA_ENDORSED_DIRS. So these two lines are needed in tomcat6.conf:

JAVA_ENDORSED_DIRS="/usr/share/tomcat6/endorsed"
JAVA_OPTS="-Djava.endorsed.dirs=$JAVA_ENDORSED_DIRS [-Djava....]"

Not really well documented issue, I think.

Marcos Fernandez
  • 556
  • 9
  • 22