Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Al Hobbs
  • salvin francis

WSHandler: cannot create instance of password callback

Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am a newbie to axis2 and rampart. I am using tomcat and axis2-1.2. I am trying to secure a web service using username token

My service is as follows:

public class MyHello {
public String sayHello(String s){
return "HELLO"+" "+s;
} }

CallbackHandler is as follows :

public class PwdCallBackHandler implements CallbackHandler{
public void handle(Callback[] callbacks) throws IOException,UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
String id = pwcb.getIdentifer();
if("myname".equals(id)) {
} } }

service.xml looks as follows:

<service name="MyHello" >
Sample Web Service for Username Token
<operation name="sayHello">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
<parameter name="ServiceClass" locked="false">testpack.MyHello</parameter>
<module ref="rampart" />
<parameter name="InflowSecurity">
<items>UsernameToken Timestamp</items>

I also created client.axis2.xml similar to given in samples where i changed the existing values to:

<module ref="rampart" />
<parameter name="OutflowSecurity">
<items>UsernameToken Timestamp</items>

I created stubs for my service. my Client is as follows:

public class MyHelloClient{
public static void main(String[] args) {
MyHelloMyHelloSOAP11PortStub stub = new MyHelloMyHelloSOAP11PortStub("http://localhost:8080/axis2/services/MyHello");
MyHelloMyHelloSOAP11PortStub.SayHello sayHello = new MyHelloMyHelloSOAP11PortStub.SayHello();
MyHelloMyHelloSOAP11PortStub.SayHelloResponse resp = stub.sayHello(sayHello);
System.out.println("Response from Web Service -->"+resp.get_return());
}catch(Exception ex){

I get the following exception when i run the client :

org.apache.axis2.AxisFault: WSHandler: cannot create instance of password callback: testpack.PwdCallBackHandler; nested exception is:

java.lang.ClassCastException: testpack.PwdCallBackHandler

at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(

at org.apache.axis2.description.OutInAxisOperationClient.send(

at org.apache.axis2.description.OutInAxisOperationClient.execute(

at testpack.MyHelloMyHelloSOAP11PortStub.sayHello(

at testpack.MyHelloClient.main(
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic