Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.lang.NoClassDefFoundError: com/sun/xml/ws/developer/WSBindingProvider

bdzevelDec 13 2013 — edited Dec 13 2013

Hello,

I was seeing the following error:

java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName()Ljava/lang/String;

I did some googling and found that I needed to specify the endorsed directory java option:

java -Djava.endorsed.dirs="/mypathtoendorseddir" -jar myjar.jar

This directory contained my jaxws-rt.jar file. It was kind of tricky but I was eventually able to get past this error. Now I'm stuck with the following nonsensical error:

java.lang.NoClassDefFoundError: com/sun/xml/ws/developer/WSBindingProvider

This error occurs when I try to cast a binding as that com.sun.xml.ws.developer.WSBindingProvider (a few lines down from the original "java/lang/String" error). I've downloaded the latest jaxws-rt.jar, but no luck. How is it unable to find this WSBindingProvider class when my project compiles and builds a jar file successfully? Granted, the code is being run on another machine (I'm building locally obviously), but the jaxws-rt.jar file is THERE. I even modified the class-path entry in the jar manifest to include "endorseddir/jaxws-rt.jar" (previously, I had this in a "lib" folder and was just referencing "jaxws-rt.jar" in the class-path).

Again, it's able to resolve the WSBindingProvider class from the code, and when I go to the definition it throws me into jaxws-rt.jar (without any sources of course, but it does understand that the class is in there).

I'm lost. Any ideas?

P.S. After pulling my hair out for a while trying to figure this out, I figured I'd just take all the references to WSBindingProvider out of my code and replace it with BindingProvider. Unfortunately, BindingProvider doesn't expose a setOutboundHeaders function which is used in certain parts of our code. BindingProvider, by the way, properly resolves.

Comments

Frank Kulash
Answer

Hi, BeefStu

Select REGEXP_SUBSTR('one Two three four','\w+',1,2) wordN  from dual

You're close! You said you want the words separated by spaces, but \w' will get words separated by other chracters (like commas) as well. '\S' (with a capital S) means any non-space character. To get the x-th character, use SUBSTR.
If table_x contains a string column called str, you can get the n-th word and the x-th character of that word like this:

WITH  got_wordn  AS
(
	SELECT REGEXP_SUBSTR ( str
			     , '\S+'
			     , 1
			     , &word_num
			     ) AS wordn
	FROM	table_x
)
SELECT  wordn
,	SUBSTR (wordn, &char_num, 1)	AS charx
FROM	got_wordn
;

Of course, you don't need to use substitution variables like &word_num and &char_num. You can use any kind of expression in those places.

Marked as Answer by BeefStu · Oct 28 2021
BeefStu

@frank-kulash perfect thanks. To satisfy my curiosity could my original test CASE be expanded to include the substr too? For example, find the Nth word and from that word find the Nth character in one statement? I just couldn't get that too work so I posted the question. Thanks for your help and expertise its greatly appreciated

Frank Kulash

Hi, BeefStu
So, you want a single regular expression that returns a given character from a given word, is that right?
Here's one way:

SELECT REGEXP_SUBSTR ( str
		     , '(\S+\s+){' || TO_CHAR (&word_num - 1)
		    		   || '}.{'
				   || TO_CHAR (&char_num - 1)
				   || '}(.)'
		     , 1
		     , 1
		     , NULL
		     , 2
		     ) AS charx
FROM	table_x
;

If &word_num = 1 and &char_num = 2, then the second argument to REGEXP_SUBSTR is

 '(\S+\s+){0}.{1}(.)'
mathguy

undefined (0 Bytes)The solution proposed by Mr. Kulash for this last request is in the correct general direction, but it has one significant mistake. After reading past the first n - 1 words (defined as non-empty substrings separated by whitespace), it starts counting characters regardless of whether they are "word" characters or whitespace. This causes incorrect results when the n'th word is shorter than m characters - the query will return the m'th character counting from the first character of the n'th word, regardless of whether that m'th character is still in the same word. It may be a whitespace character, or a word character from a different word further down (to the right) in the input string.
This is easy to fix. Instead of "dot" use \S in all places. Or, if you really meant \w for "word characters" (meaning that words may also be delimited by dash, comma, etc. - not just by whitespace), you can rewrite the whole thing using \w and \W instead of \S and \s. Something like this (using bind variables for n and m, instead of substitution variables):

select str,
       regexp_substr(str, '\w+', 1, :n) as wordN,
       regexp_substr(str,
         '^\W*(\w+\W+){' || to_char(:n - 1) || '}\w{' || to_char(:m - 1) || '}(\w)'
         , 1, 1, null, 2)
         as wordN_charM
from   (select 'one Two three four' as str from dual);

Note also that I anchored the regexp at the beginning of the input string (so I had to allow for 0 or more non-word characters at the beginning, too). If n is larger than the number of words in the string, the regexp matching starting from the beginning of the string will fail. If we don't anchor at the beginning of the string (with the ^ anchor), the regexp engine will try again, attempting to match from the second character, then from the third, ... - wasting a huge amount of time for no reason. The regexp engine doesn't use logic (like we do), to figure out that the additional attempts will also automatically fail - it will just blindly try them all.
For testing, try all combinations where m may be 1, or 2, or the word count, or GREATER THAN the word count, and n may be 1, or 2, or the length of the n'th word, or GREATER THAN the length of the n'th word. Make sure you get the correct answer in all cases (including NULL when n is too great or m is too great).

1 - 4
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jan 10 2014
Added on Dec 13 2013
1 comment
4,208 views