[jboss-dev-forums] [JBoss Web Services Development] - org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sts': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError:

Anu Raj do-not-reply at jboss.com
Fri Jul 5 09:41:05 EDT 2013


Anu Raj [https://community.jboss.org/people/mpag1980] created the discussion

"org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sts': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError:"

To view the discussion, visit: https://community.jboss.org/message/826599#826599

--------------------------------------------------------------
Hi, I am trying to publish Apache CXF STS in Jboss soa-p 5.1.3 G.A. I am following the sample program in the below link.

 https://community.jboss.org/wiki/WS-TrustWithJBossWS-CXFOnJBossAS71/diff?secondVersionNumber=4 https://community.jboss.org/wiki/WS-TrustWithJBossWS-CXFOnJBossAS71/diff?secondVersionNumber=4

I am getting the following error when I try to access my token service wsdl endpoint

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sts': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V

My web.xml looks like this

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance" xmlns=" http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee" xmlns:web=" http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>CXFworkingSTS</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>



    <description>Apache CXF Endpoint</description>  
    <display-name>cxf</display-name>  
    <servlet-name>cxf</servlet-name>  
    <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>  
    <load-on-startup>1</load-on-startup>  
  </servlet>  
  <servlet-mapping>  
    <servlet-name>cxf</servlet-name>  
    <url-pattern>/services/*</url-pattern>  
  </servlet-mapping>  

  <session-config>  
    <session-timeout>60</session-timeout>  
  </session-config>  

  <context-param>  
    <param-name>contextConfigLocation</param-name>  
    <param-value>WEB-INF/cxf-servlet.xml</param-value>  
  </context-param>  
  <servlet>  
      <servlet-name>SecurityTokenService</servlet-name>  
      <servlet-class>STS.SampleSTS</servlet-class>  
   </servlet>  
   <servlet-mapping>  
      <servlet-name>SecurityTokenService</servlet-name>  
      <url-pattern>/SecurityTokenService/*</url-pattern>  
   </servlet-mapping>  
  <listener>  
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
  </listener>  
</web-app>  


My cxf-servlet.xml looks like this

<?xml version="1.0" encoding="UTF-8"?>  
<beans xmlns=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans"  
    xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws=" http://cxf.apache.org/jaxws http://cxf.apache.org/jaxws"  
    xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/beans/spring-beans-2.5.xsd  http://cxf.apache.org/jaxws http://cxf.apache.org/jaxws  http://cxf.apache.org/schemas/jaxws.xsd http://cxf.apache.org/schemas/jaxws.xsd">  

    <jaxws:endpoint xmlns:tns=" http://docs.oasis-open.org/ws-sx/ws-trust/200512/ http://docs.oasis-open.org/ws-sx/ws-trust/200512/"  
        id="sts" implementor="STS.SampleSTS"  
        wsdlLocation="wsdl/ws-trust-1.4-service.wsdl" endpointName="tns:UT_Port"  
        serviceName="tns:SecurityTokenService" address="/UT_Port">  
        <jaxws:features>  
            <bean class="org.apache.cxf.feature.LoggingFeature" />  
        </jaxws:features>  
    </jaxws:endpoint>  
</beans> 



SampleSTS.java
+++++++++++++++
/*
 * JBoss, Home of Professional Open Source.
 * Copyright 2012, Red Hat Middleware LLC, and individual contributors
 * as indicated by the @author tags. See the copyright.txt file in the
 * distribution for a full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site:  http://www.fsf.org http://www.fsf.org.
 */
package STS;


import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;


import javax.servlet.annotation.WebServlet;
import javax.xml.ws.WebServiceProvider;


import org.apache.cxf.annotations.EndpointProperties;
import org.apache.cxf.annotations.EndpointProperty;
import org.apache.cxf.interceptor.InInterceptors;
import org.apache.cxf.sts.StaticSTSProperties;
import org.apache.cxf.sts.operation.TokenIssueOperation;
import org.apache.cxf.sts.operation.TokenValidateOperation;
import org.apache.cxf.sts.service.ServiceMBean;
import org.apache.cxf.sts.service.StaticService;
import org.apache.cxf.sts.token.provider.SAMLTokenProvider;
import org.apache.cxf.sts.token.validator.SAMLTokenValidator;
import org.apache.cxf.ws.security.sts.provider.SecurityTokenServiceProvider;
import org.jboss.wsf.stack.cxf.client.configuration.JBossWSBusFactory;




@WebServiceProvider(serviceName = "SecurityTokenService",
      portName = "UT_Port",
      targetNamespace = " http://docs.oasis-open.org/ws-sx/ws-trust/200512/ http://docs.oasis-open.org/ws-sx/ws-trust/200512/",
      wsdlLocation = "WEB-INF/wsdl/ws-trust-1.4-service.wsdl")
@EndpointProperties(value = {
      @EndpointProperty(key = "ws-security.signature.username", value = "mystskey"),
      @EndpointProperty(key = "ws-security.signature.properties", value = "stsKeystore.properties"),
      @EndpointProperty(key = "ws-security.callback-handler", value = "STSCallbackHandler")      
})
@InInterceptors(interceptors = {"org.jboss.wsf.stack.cxf.security.authentication.SubjectCreatingPolicyInterceptor"})
@WebServlet(name = "SampleSTSServlet", urlPatterns = "/*")
public class SampleSTS extends SecurityTokenServiceProvider
{
   @SuppressWarnings("deprecation")
public SampleSTS() throws Exception
   {
      super();

      StaticSTSProperties props = new StaticSTSProperties();
      props.setSignaturePropertiesFile("stsKeystore.properties");
      props.setSignatureUsername("mystskey");
      props.setCallbackHandlerClass(STSCallbackHandler.class.getName());
      props.setIssuer("DoubleItSTSIssuer");

      List<ServiceMBean> services = new LinkedList<ServiceMBean>();
      StaticService service = new StaticService();
      service.setEndpoints(Arrays.asList(" http://localhost:9090/CXFworking/services/SecurityServicePort http://localhost:9090/CXFworking/services/SecurityServicePort"));
      services.add(service);

      TokenIssueOperation issueOperation = new TokenIssueOperation();
      issueOperation.setServices(services);
      issueOperation.getTokenProviders().add(new SAMLTokenProvider());
      issueOperation.setStsProperties(props);

      TokenValidateOperation validateOperation = new TokenValidateOperation();
      validateOperation.getTokenValidators().add(new SAMLTokenValidator());
      validateOperation.setStsProperties(props);

      this.setIssueOperation(issueOperation);
      this.setValidateOperation(validateOperation);
   }

}

I have a callback handler.

/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package STS;


import java.io.IOException;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException;
import org.apache.ws.security.WSPasswordCallback;


public class STSCallbackHandler implements CallbackHandler {


    public void handle(Callback[] callbacks) throws IOException,
            UnsupportedCallbackException {
        for (int i = 0; i < callbacks.length; i++) {
            if (callbacks[i] instanceof WSPasswordCallback) {
                WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
                if ("mystskey".equals(pc.getIdentifier())) {
                    pc.setPassword("stskpass");
                    break;
                } else if ("alice".equals(pc.getIdentifier())) {
                    pc.setPassword("clarinet");
                    break;
                }
            }
        }
    }
}

I see there is an issue with my web.xml file. Please help me out.

Thanks,
Abarna
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/826599#826599]

Start a new discussion in JBoss Web Services Development at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2047]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-dev-forums/attachments/20130705/f84b29b5/attachment-0001.html 


More information about the jboss-dev-forums mailing list