0 Replies Latest reply on Apr 27, 2011 6:11 AM by gressho

    CXF Client in JBoss AS 6 problem

    gressho Newbie

      Hello,

       

      I have a webservice running in JBossAS 6 using a WS-SecurityPolicy. It works great! I also have a perfectly well running client using the JBossWS Native Stack on JBossAS 4.7.2. Now I need another client on JBossAS 6 using the CXF stack. So I installed the spring libraries and did some testing according to the examples from the test suite:

       

      @WebServlet(name = "CxfClient", urlPatterns = {"/CxfClient"})
      public class CxfClient extends HttpServlet {
      
          private PINbnManagementEndpoint nbnManagementEndpoint;
      
          @Inject
          @Resource("WEB-INF/server.properties")
          private Properties serverProperties;
      
          @Inject
          @Resource("WEB-INF/nbnManagementClient.properties")
          private URL nbnManagementClientProperties;
      
          public void observeServletContextInitialized(@Observes @Initialized ServletContext context) {
              System.out.println(context.getServerInfo() + " initialized");
          }    
      
          public PINbnManagementEndpoint getPINbnManagementEndpoint() {
              if (nbnManagementEndpoint == null) {
                  try {
                      PINbnManagementService nbnManagementService =
                              new PINbnManagementService(new URL("http://" + serverProperties.getProperty("server.name2") +
                              serverProperties.getProperty("piManagementService")));
                      nbnManagementEndpoint = nbnManagementService.getPINbnManagementEndpointPort();
                      ((BindingProvider) nbnManagementEndpoint).getRequestContext().put(
                              SecurityConstants.CALLBACK_HANDLER, new KeystorePasswordCallback());
                      ((BindingProvider) nbnManagementEndpoint).getRequestContext().put(
                              SecurityConstants.SIGNATURE_PROPERTIES, nbnManagementClientProperties);
                      ((BindingProvider) nbnManagementEndpoint).getRequestContext().put(
                              SecurityConstants.ENCRYPT_PROPERTIES, nbnManagementClientProperties);
                  } catch (MalformedURLException ex) {
                      System.err.println("Die URL der WSDL-Datei ist ungültig! Dies ist sehr ernst!");
                  }
              }
              return nbnManagementEndpoint;
          }
      
          /** 
           * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
           * @param request servlet request
           * @param response servlet response
           * @throws ServletException if a servlet-specific error occurs
           * @throws IOException if an I/O error occurs
           */
          protected void processRequest(HttpServletRequest request, HttpServletResponse response)
                  throws ServletException, IOException {
              response.setContentType("text/html;charset=UTF-8");
              PrintWriter out = response.getWriter();
              try {
                  getPINbnManagementEndpoint();
                  out.println("<html>");            out.println("<head>");
                  out.println("<title>Servlet CxfClient</title>");  
                  out.println("</head>");
                  out.println("<body>");
                  out.println("<h1>Servlet CxfClient at " + request.getContextPath () + "</h1>");
                  if (nbnManagementEndpoint != null) {
                      for (Namespace namespace : nbnManagementEndpoint.GetNamespaces()) {
                          out.println("<h3>" + namespace.getPrefix() + "</h3>");
                      }
                  } else {
                      out.println("Initialisierung hat nicht funktioniert");
                  }
                  out.println("</body>");
                  out.println("</html>");
              } finally {            
                  out.close();
              }
          }
      
          /** 
           * Handles the HTTP <code>GET</code> method.
           * @param request servlet request
           * @param response servlet response
           * @throws ServletException if a servlet-specific error occurs
           * @throws IOException if an I/O error occurs
           */
          @Override
          protected void doGet(HttpServletRequest request, HttpServletResponse response)
                  throws ServletException, IOException {
              processRequest(request, response);
          }
      
          /** 
           * Handles the HTTP <code>POST</code> method.
           * @param request servlet request
           * @param response servlet response
           * @throws ServletException if a servlet-specific error occurs
           * @throws IOException if an I/O error occurs
           */
          @Override
          protected void doPost(HttpServletRequest request, HttpServletResponse response)
                  throws ServletException, IOException {
              processRequest(request, response);
          }
      }
      
      

       

      When calling the servlet this leads to the following exceptions:

       

       

      11:46:50,274 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/cxfClient].[CxfClient]] Servlet.service() for servlet CxfClient threw exception: javax.xml.ws.soap.SOAPFaultException: Error creating bean with name 'org.apache.cxf.ws.policy.PolicyInterceptorProviderRegistry' defined in URL [vfs:/home/gressho/Programme/jboss-6.0.0.Final/common/lib/cxf-rt-ws-policy.jar/META-INF/cxf/cxf-extension-policy.fixml]: Cannot create inner bean 'org.apache.cxf.configuration.spring.SpringBeanQNameMap#2209ad9a' of type [org.apache.cxf.configuration.spring.SpringBeanQNameMap] while setting constructor argument; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.cxf.configuration.spring.SpringBeanQNameMap] for bean with name 'org.apache.cxf.configuration.spring.SpringBeanQNameMap#2209ad9a' defined in URL [vfs:/home/gressho/Programme/jboss-6.0.0.Final/common/lib/cxf-rt-ws-policy.jar/META-INF/cxf/cxf-extension-policy.fixml]; nested exception is java.lang.ClassNotFoundException: org.apache.cxf.configuration.spring.SpringBeanQNameMap
          at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:146) [:2.3.1]
          at $Proxy598.GetNamespaces(Unknown Source)    at de.wwu.ulb.cxfclient.CxfClient.processRequest(CxfClient.java:92) [:]
          at de.wwu.ulb.cxfclient.CxfClient.doGet(CxfClient.java:116) [:]
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) [:1.0.0.Final]
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [:1.0.0.Final]
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:6.0.0.Final]
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]
          at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67) [:6.0.0.Final]
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.0.0.Final]
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]
          at org.jboss.seam.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:62) [:3.0.0.Final]
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.0.0.Final]
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]
          at org.jboss.seam.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:72) [:3.0.0.Final]
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.0.0.Final]
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:6.0.0.Final]
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [:6.0.0.Final]
          at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.0.0.Final]
          at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.Final]
          at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.Final]
          at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.0.0.Final]
          at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.0.0.Final]
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [:6.0.0.Final]
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.0.0.Final]
          at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.0.0.Final]
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.0.0.Final]
          at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.0.0.Final]
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.0.0.Final]
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.0.0.Final]
          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [:6.0.0.Final]
          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.0.0.Final]
          at java.lang.Thread.run(Thread.java:636) [:1.6.0_20]
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.cxf.ws.policy.PolicyInterceptorProviderRegistry' defined in URL [vfs:/home/gressho/Programme/jboss-6.0.0.Final/common/lib/cxf-rt-ws-policy.jar/META-INF/cxf/cxf-extension-policy.fixml]: Cannot create inner bean 'org.apache.cxf.configuration.spring.SpringBeanQNameMap#2209ad9a' of type [org.apache.cxf.configuration.spring.SpringBeanQNameMap] while setting constructor argument; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.cxf.configuration.spring.SpringBeanQNameMap] for bean with name 'org.apache.cxf.configuration.spring.SpringBeanQNameMap#2209ad9a' defined in URL [vfs:/home/gressho/Programme/jboss-6.0.0.Final/common/lib/cxf-rt-ws-policy.jar/META-INF/cxf/cxf-extension-policy.fixml]; nested exception is java.lang.ClassNotFoundException: org.apache.cxf.configuration.spring.SpringBeanQNameMap
          at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:281) [:3.0.3.RELEASE]
          at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:120) [:3.0.3.RELEASE]
          at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:621) [:3.0.3.RELEASE]
          at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:143) [:3.0.3.RELEASE]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:993) [:3.0.3.RELEASE]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:897) [:3.0.3.RELEASE]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485) [:3.0.3.RELEASE]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) [:3.0.3.RELEASE]
          at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) [:3.0.3.RELEASE]
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) [:3.0.3.RELEASE]
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) [:3.0.3.RELEASE]
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) [:3.0.3.RELEASE]
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:398) [:3.0.3.RELEASE]
          at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1146) [:3.0.3.RELEASE]
          at org.apache.cxf.bus.spring.SpringBeanLocator.getBeansOfType(SpringBeanLocator.java:59) [:2.3.1]
          at org.apache.cxf.bus.CXFBusImpl.getExtension(CXFBusImpl.java:99) [:2.3.1]
          at org.apache.cxf.ws.policy.PolicyEngineImpl.supportsAlternative(PolicyEngineImpl.java:521) [:2.3.1]
          at org.apache.cxf.ws.policy.selector.MinimalAlternativeSelector.selectAlternative(MinimalAlternativeSelector.java:45) [:2.3.1]
          at org.apache.cxf.ws.policy.EndpointPolicyImpl.chooseAlternative(EndpointPolicyImpl.java:161) [:2.3.1]
          at org.apache.cxf.ws.policy.EndpointPolicyImpl.finalizeConfig(EndpointPolicyImpl.java:146) [:2.3.1]
          at org.apache.cxf.ws.policy.EndpointPolicyImpl.initialize(EndpointPolicyImpl.java:142) [:2.3.1]
          at org.apache.cxf.ws.policy.PolicyEngineImpl.createEndpointPolicyInfo(PolicyEngineImpl.java:504) [:2.3.1]
          at org.apache.cxf.ws.policy.PolicyEngineImpl.getEndpointPolicy(PolicyEngineImpl.java:255) [:2.3.1]
          at org.apache.cxf.ws.policy.PolicyEngineImpl.getClientEndpointPolicy(PolicyEngineImpl.java:237) [:2.3.1]
          at org.apache.cxf.transport.http.policy.PolicyUtils.getClient(PolicyUtils.java:150) [:2.3.1]
          at org.apache.cxf.transport.http.HTTPConduit.initializeConfig(HTTPConduit.java:359) [:2.3.1]
          at org.apache.cxf.transport.http.HTTPConduit.<init>(HTTPConduit.java:327) [:2.3.1]
          at org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory.getConduit(ClientOnlyHTTPTransportFactory.java:63) [:2.3.1]
          at org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory.getConduit(ClientOnlyHTTPTransportFactory.java:50) [:2.3.1]
          at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:223) [:2.3.1]
          at org.apache.cxf.endpoint.AbstractConduitSelector.getSelectedConduit(AbstractConduitSelector.java:78) [:2.3.1]
          at org.apache.cxf.endpoint.UpfrontConduitSelector.prepare(UpfrontConduitSelector.java:61) [:2.3.1]
          at org.apache.cxf.endpoint.ClientImpl.prepareConduitSelector(ClientImpl.java:802) [:2.3.1]
          at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:510) [:2.3.1]
          at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:313) [:2.3.1]
          at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:265) [:2.3.1]
          at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73) [:2.3.1]
          at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124) [:2.3.1]
          ... 33 more
      Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.cxf.configuration.spring.SpringBeanQNameMap] for bean with name 'org.apache.cxf.configuration.spring.SpringBeanQNameMap#2209ad9a' defined in URL [vfs:/home/gressho/Programme/jboss-6.0.0.Final/common/lib/cxf-rt-ws-policy.jar/META-INF/cxf/cxf-extension-policy.fixml]; nested exception is java.lang.ClassNotFoundException: org.apache.cxf.configuration.spring.SpringBeanQNameMap
          at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1235) [:3.0.3.RELEASE]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:433) [:3.0.3.RELEASE]
          at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270) [:3.0.3.RELEASE]
          ... 70 more
      Caused by: java.lang.ClassNotFoundException: org.apache.cxf.configuration.spring.SpringBeanQNameMap
          at java.net.URLClassLoader$1.run(URLClassLoader.java:217) [:1.6.0_20]
          at java.security.AccessController.doPrivileged(Native Method) [:1.6.0_20]
          at java.net.URLClassLoader.findClass(URLClassLoader.java:205) [:1.6.0_20]
          at java.lang.ClassLoader.loadClass(ClassLoader.java:321) [:1.6.0_20]
          at java.lang.ClassLoader.loadClass(ClassLoader.java:266) [:1.6.0_20]
          at org.springframework.util.ClassUtils.forName(ClassUtils.java:257) [:3.0.3.RELEASE]
          at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:408) [:3.0.3.RELEASE]
          at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1256) [:3.0.3.RELEASE]
          at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1227) [:3.0.3.RELEASE]
          ... 72 more
      

       

      cxf-common-utilities.jar is present in JBOSS_HOME/common/lib and JBOSS_HOME/client but not in my war (no cxf classes at all there!).

      So this is a class loading issue with all classes available?

      I'm looking for every hint I can get.

       

      Thanks in advance

       

      Werner