Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

com.sun.xml.internal.ws.developer.JAXWSProperties not found at compile

Tags:

java

jax-ws

We used the class JAXWSProperties from the com.sun.* package in the code in order to set timeout properties like this:

import com.sun.xml.internal.ws.developer.JAXWSProperties;
...
Map<String, Object> ctxt = ((BindingProvider) port).getRequestContext();
ctxt.put(JAXWSProperties.CONNECT_TIMEOUT, 10000);

It compiles fine in the local Eclipse, but not on a continuous integration system (both using JDK 1.6). From researching this problem, I learned that the com.sun.* package should be avoided.

So my questions are:

  • What causes the failed import at compile time?
  • What should be used instead of JAXWSProperties?
like image 726
Alexander Rühl Avatar asked Sep 09 '11 08:09

Alexander Rühl


1 Answers

I've just had pretty much the same problem while converting one of our projects to run under Maven.

The solution I found, isn't really an ideal solution, in fact it's more of a "cludge" than a "fix," although it does run through the compiler OK. Like you I did a bit of research on this issue, and found a comment from Sun saying that these packages are hidden from the compiler, but are available to the JVM.

So, the solution I found was to simply find the string to which the constant was pointing, and use that locally.

In your case it would be:

final static String CONNECT_TIMEOUT = "com.sun.xml.internal.ws.connect.timeout";
....
Map<String, Object> ctxt = ((BindingProvider) port).getRequestContext();
ctxt.put(CONNECT_TIMEOUT, 10000);

As I mentioned, this isn't ideal, and can not be guaranteed to work in future compiler releases, so use with care.

like image 117
Crollster Avatar answered Oct 20 '22 01:10

Crollster