cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ganesh Kalanadhabhatla (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CXF-6325) java.lang.NoSuchMethodError: org.apache.cxf.jaxrs.JAXRSServerFactoryBean.addToBeans
Date Tue, 31 Mar 2015 16:28:52 GMT
Ganesh Kalanadhabhatla created CXF-6325:
-------------------------------------------

             Summary: java.lang.NoSuchMethodError: org.apache.cxf.jaxrs.JAXRSServerFactoryBean.addToBeans
                 Key: CXF-6325
                 URL: https://issues.apache.org/jira/browse/CXF-6325
             Project: CXF
          Issue Type: Bug
          Components: JAX-RS
    Affects Versions: 3.0.4
         Environment: Jboss Enterprise Application Platform 6.1+ (runtime environment)
            Reporter: Ganesh Kalanadhabhatla


I am trying to use CXF 3.0.4 REST + spring data JPA + SPRING  with java configuration (no
XML).

Getting the following runtime error in JBOS EAP 6.1+ server.

Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Factory method
[public org.apache.cxf.endpoint.Server com.webconsults.concurrent.batch.AppConfig.jaxRsServer(org.springframework.context.ApplicationContext)]
threw exception; nested exception is java.lang.NoSuchMethodError: org.apache.cxf.jaxrs.JAXRSServerFactoryBean.addToBeans(Ljava/util/Collection;Ljava/lang/Object;)V
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:188)
[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:586)
[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
	... 25 more
Caused by: java.lang.NoSuchMethodError: org.apache.cxf.jaxrs.JAXRSServerFactoryBean.addToBeans(Ljava/util/Collection;Ljava/lang/Object;)V
	at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.setServiceBeans(JAXRSServerFactoryBean.java:341)
[cxf-rt-frontend-jaxrs-3.0.4.jar:3.0.4]
	at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.setServiceBean(JAXRSServerFactoryBean.java:330)
[cxf-rt-frontend-jaxrs-3.0.4.jar:3.0.4]
	at com.webconsults.concurrent.batch.AppConfig.jaxRsServer(AppConfig.java:61) [classes:]
	at com.webconsults.concurrent.batch.AppConfig$$EnhancerBySpringCGLIB$$3a969f88.CGLIB$jaxRsServer$0(<generated>)
[spring-core-4.0.5.RELEASE.jar:]
	at com.webconsults.concurrent.batch.AppConfig$$EnhancerBySpringCGLIB$$3a969f88$$FastClassBySpringCGLIB$$e2d0b8b9.invoke(<generated>)
[spring-core-4.0.5.RELEASE.jar:]
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) [spring-core-4.0.5.RELEASE.jar:4.0.5.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:312)
[spring-context-4.0.5.RELEASE.jar:4.0.5.RELEASE]
	at com.webconsults.concurrent.batch.AppConfig$$EnhancerBySpringCGLIB$$3a969f88.jaxRsServer(<generated>)
[spring-core-4.0.5.RELEASE.jar:]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_80-ea]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_80-ea]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_80-ea]
	at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_80-ea]

My pom dependencies are:

<dependencies>
		<!-- cxf -->
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-frontend-jaxrs</artifactId>
			<version>${cxf.version}</version>
		</dependency>
		
		<!--  required to avoid ... -->
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-core</artifactId>
			<version>2.7.15</version>
		</dependency>
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-ws-policy</artifactId>
			<version>${cxf.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-webmvc</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-beans</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-tx</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.data</groupId>
			<artifactId>spring-data-commons-core</artifactId>
			<version>${spring.data.commons-core.version}</version>
			<exclusions>
				<exclusion>
					<artifactId>spring-core</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-beans</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.springframework.data</groupId>
			<artifactId>spring-data-jpa</artifactId>
			<version>${spring.data.jpa.version}</version>
		</dependency>
		<!--  
		<dependency>
			<groupId>org.springframework.data</groupId>
			<artifactId>spring-data-rest-webmvc</artifactId>
			<version>${spring.data.rest.webmvc.version}</version>
		</dependency>
		-->
		
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-entitymanager</artifactId>
			<version>${hibernate.version}</version>
		</dependency>
		<!-- JSON Provider -->

		<dependency>
			<groupId>com.fasterxml.jackson.jaxrs</groupId>
			<artifactId>jackson-jaxrs-json-provider</artifactId>
			<version>2.5.1</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
			<version>${slf4j.version}</version>
		</dependency>
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>javax.servlet-api</artifactId>
			<version>3.1.0</version>
		</dependency>

		<!-- commons dbcp -->
		<dependency>
			<groupId>commons-dbcp</groupId>
			<artifactId>commons-dbcp</artifactId>
			<version>1.4</version>
		</dependency>

		<!-- Hibernate -->
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-core</artifactId>
			<version>${hibernate.version}</version>
		</dependency>

		<!-- H2 Database -->
		<dependency>
			<groupId>com.h2database</groupId>
			<artifactId>h2</artifactId>
			<version>${h2.version}</version>
		</dependency>

		<!-- Gemfire XD -->

		<!-- <dependency> <groupId>com.pivotal</groupId> <artifactId>gfxd-client</artifactId>

			<version>1.0</version> <scope>system</scope> <systemPath>C:/opt/app/Pivotal_GemFireXD_140_b50226_Windows/lib/gemfirexd-client.jar</systemPath>

			</dependency> -->
		<!--  
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-transports-http-jetty</artifactId>
			<version>${cxf.version}</version>
		</dependency>
		-->
		<!-- logging -->
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
			<version>${slf4j.version}</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
			<version>${slf4j.version}</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>jcl-over-slf4j</artifactId>
			<version>${slf4j.version}</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
			<version>${slf4j.version}</version>
		</dependency>



		<!-- <dependency> <groupId>com.pivotal</groupId> <artifactId>gfxd-dialect</artifactId>

			<version>1.0</version> <scope>system</scope> <systemPath>/opt/app/Pivotal_GemFireXD_140_b50226_Windows/lib/gfxdHibernateDialect.jar</systemPath>

			</dependency> ... -->


		<!-- TESTS -->
		<dependency>
			<groupId>org.hamcrest</groupId>
			<artifactId>hamcrest-all</artifactId>
			<version>1.3</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.11</version>
			<scope>test</scope>
			<exclusions>
				<exclusion>
					<artifactId>hamcrest-core</artifactId>
					<groupId>org.hamcrest</groupId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-test</artifactId>
			<version>4.0.5.RELEASE</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>com.github.springtestdbunit</groupId>
			<artifactId>spring-test-dbunit</artifactId>
			<version>1.2.0</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.dbunit</groupId>
			<artifactId>dbunit</artifactId>
			<version>2.4.9</version>
			<scope>test</scope>
			<exclusions>
				<exclusion>
					<artifactId>junit</artifactId>
					<groupId>junit</groupId>
				</exclusion>
			</exclusions>
		</dependency>

	</dependencies>


My WebAppInitializer (replacement for web.xml)
@Configuration
public class WebAppInitializer implements WebApplicationInitializer {
	 
    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
    	System.out.println("ON STARTUP BEGIN");
        servletContext.addListener(new ContextLoaderListener(createWebAppContext()));
        addApacheCxfServlet(servletContext);
        System.out.println("ON STARTUP END");
    }
 
    private void addApacheCxfServlet(ServletContext servletContext) {
        CXFServlet cxfServlet = new CXFServlet();
        //org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet cxfServlet = new CXFNonSpringJaxrsServlet();
 
        ServletRegistration.Dynamic appServlet = servletContext.addServlet("CXFServlet", cxfServlet);
        appServlet.setLoadOnStartup(1);
 
        Set<String> mappingConflicts = appServlet.addMapping("/cxf/*");
    }
 
    private WebApplicationContext createWebAppContext() {
    	// AnnotationConfigWebApplicationContext to avoid using beans xml files.
        AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext();
        appContext.register(AppConfig.class);
        return appContext;
    }
 
}


My AppConfig.xml (replacement for beans.xml)

import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.jaxrs.JAXRSBindingFactory;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Import;

import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
import com.webconsults.concurrent.batch.resource.ExceptionResource;
import com.webconsults.concurrent.batch.resource.MemberResource;

@Configuration
@ComponentScan("com.webconsults.concurrent.batch")
@Import({SpringDBConfig.class})
//@EnableWebMvc
public class AppConfig {
 
	//org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet$ApplicationImpl
	/*
    @ApplicationPath("/")
    public class MomsRsApiApplication extends Application { }
 	*/
	
	
    @Bean(destroyMethod = "shutdown")
    public SpringBus cxf() {
        return new SpringBus();
    }
 	
	
    @Bean
    @DependsOn("cxf")
    public Server jaxRsServer(ApplicationContext appContext) {
         //factory = RuntimeDelegate.getInstance().createEndpoint(momsRsApiApplication(),
JAXRSServerFactoryBean.class);
        JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
         //factory.setTransportId("http://cxf.apache.org/transports/http");
        
        /*
         //use this if CXF to manage the resource
        
        factory.setResourceClasses(MemberResource.class);
        
        */
        
        
        //use this if spring manages the resource
        
        List<Object> objects = Arrays.<Object>asList
        (memberResource());
        System.out.println("objects.sz:"+objects.size());
        //factory.setServiceBeans();
        factory.setServiceBean((Object)memberResource());
         
        
        //factory.setAddress("/" + factory.getAddress());
        factory.setAddress("http://localhost:8080/");
        factory.setProvider(jsonProvider());
        factory.setBindingId(JAXRSBindingFactory.JAXRS_BINDING_ID);
        return factory.create();
    }
    /*
    @Bean
    public Endpoint memberResource() {
        EndpointImpl endpoint = new EndpointImpl(cxf(), new MemberResource(), new EndpointInfo());
        endpoint.setAddress("/memberservice");
      
        return endpoint;
    }
    */
 	
    	/*
    @Bean
    public MomsRsApiApplication momsRsApiApplication() {
        return new MomsRsApiApplication();
    }
    */
	
    @Bean
    public JacksonJsonProvider jsonProvider() {
        return new JacksonJsonProvider();
    }
 
    /*
    @Bean
    public BatchServiceIf<Member> batchService() {
        return new BatchService();
    }
    */
 
    
    @Bean
    public MemberResource memberResource() {
        return new MemberResource();
    }
    
 
    
    @Bean
    public ExceptionResource exceptionResource() {
        return new ExceptionResource();
    }
    
}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message