cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nicky123 <>
Subject Annotation based WS-SecurityPolicy throwing exception
Date Thu, 20 Jun 2013 05:28:09 GMT

I am working on annotation base ws-securityPolicy and have the following
annotation on the service bean.
Note: using cxf version of 2.7.5

@WebService(endpointInterface = "")
@Policy(uri = "policies/TestImplPolicy.xml")
public class HelloWorldServiceBean implements HelloWorldService {

	public String sayHello() {
		System.out.println("Hello World!!!");
		return "Hello my service is working";


The bean configuration file have just the bean definition of the above bean.
Rest all required data is in place.

When I run this i get following exception
java.lang.ClassCastException: java.lang.String cannot be cast to
from UsernameTokenProcessor at line

Validator validator = data.getValidator(WSSecurityEngine.USERNAME_TOKEN);

which gets the validator from UsernameTokenInterceptor.getPrincipal() method

On debugging, it seems that the CustomUserTokenValidator is not loaded via

If the same example i did with bean configuration it works fine. Bean
configuration as follows
<bean id="helloWorldService"
class="" />

 	<jaxws:endpoint id="helloWorld" 
    <entry key="ws-security.ut.validator" 
    	   value-ref="customUserTokenValidator" />
    	<ref bean="loggingInInterceptor" />	
		<ref bean="logOutInterceptor" />

Please advise for any missing step.

View this message in context:
Sent from the cxf-user mailing list archive at

View raw message