1 Reply Latest reply on Oct 24, 2017 9:25 AM by Luis Pastre

    java.lang.ClassNotFoundException: org.apache.wss4j.common.ext.WSPasswordCallback (Wildfly-10.1.0)

    Luis Pastre Newbie

      Dear,

       

      I'm implementing WSSecurity im my webservices, but the wildfly 10 is returning "Class Not Found in my callback (java.lang.ClassNotFoundException: org.apache.wss4j.common.ext.WSPasswordCallback), I searched in some forums, and did many things but without success. Could anyone help me?!

       

      My structucture is below, i'm using maven:

       

      - Ear:

           - War  //where is my WS (jax-ws)

                     - KeystorePasswordCallback.java

                     - SendDossierUpdateWS.java

                 /WEB-INF

                     -jaxws-endpoint-config.xml

                     /wsdl

                          -send_dossier_update-ws.wsdl

       

                pom.xml(War)

      -----------------------------------------------------------------------------------------------

      -> KeystorePasswordCallback.java

       

      import javax.security.auth.callback.Callback;

      import javax.security.auth.callback.CallbackHandler;

      import javax.security.auth.callback.UnsupportedCallbackException;

      import org.apache.wss4j.common.ext.WSPasswordCallback;

       

      public class KeystorePasswordCallback implements CallbackHandler {

         private Map<String, String> passwords = new HashMap<String, String>();

       

         public KeystorePasswordCallback() {

            passwords.put("myservicekey", "skpass");

         }

       

         /**

          * It attempts to get the password from the private

          * alias/passwords map.

          */

         public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {

            for (int i = 0; i < callbacks.length; i++) {

               WSPasswordCallback pc = (WSPasswordCallback)callbacks[i];

       

               String pass = passwords.get(pc.getIdentifier());

               if (pass != null) {

                  pc.setPassword(pass);

                  return;

               }

         

            }

         }

      ...

      ---------------------------------------------------------------------------------------------

      -> jboss-deployment-structure.xml

       

      <?xml version="1.0" encoding="UTF-8"?>

      <jboss-deployment-structure>

          <subsystem xmlns="urn:jboss:domain:ee:1.0" >           

        <ear-subdeployments-isolated>false</ear-subdeployments-isolated>

      </subsystem>

          <deployment>

              <dependencies>

                  <module name="org.apache.ws.security" export="true" />

                  <module name="org.apache.cxf" export="true" /> 

        <module name="org.apache.cxf.impl" export="true" />

              </dependencies>

          </deployment>

      </jboss-deployment-structure>

       

      --------------------------------------------------------------------------------------------

      -> pom.xml

      ...

      <dependency>

           <groupId>javax</groupId>

           <artifactId>javaee-web-api</artifactId>

           <version>7.0</version>

           <scope>provided</scope>

      </dependency>

       

      <dependency>

           <groupId>org.jboss.ws</groupId>

           <artifactId>jbossws-api</artifactId>

           <version>1.0.3.Final</version>

           <scope>provided</scope>

      </dependency>

       

      <dependency>

           <groupId>org.apache.cxf</groupId>

           <artifactId>cxf-rt-ws-security</artifactId>

           <version>3.0.4</version>

           <scope>provided</scope>

      </dependency>

      ...

      ---------------------------------------------------------------------------------------------

      -> SendDossierUpdateWS.java

       

      @WebService(name="send_dossier_update-ws", serviceName="send_dossier_update-ws", wsdlLocation="WEB-INF/wsdl/send_dossier_update-ws.wsdl")

      @EndpointConfig(configFile = "WEB-INF/jaxws-endpoint-config.xml", configName = "Custom WS-Security Endpoint")

      public class SendDossierUpdateWS extends BaseService{

      ...

       

       

      thanks

        • 1. Re: java.lang.ClassNotFoundException: org.apache.wss4j.common.ext.WSPasswordCallback (Wildfly-10.1.0)
          Luis Pastre Newbie

          Hei mates.....

           

          It works, i put an entry in manifest(war) in pom.xml:

           

          <build>

             <plugins>

          <plugin>

                 <groupId>org.apache.maven.plugins</groupId>

                 <artifactId>maven-war-plugin</artifactId>

                 <configuration>

                    <archive>

                       <manifestEntries>

                          <Dependencies>org.apache.ws.security, org.apache.cxf</Dependencies>

                       </manifestEntries>

                    </archive>

                 </configuration>

               </plugin>

               </plugins>

              

               </build>

           

           

          Thanks a lot