cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sumit Arora <sumit1...@gmail.com>
Subject Re: Apache CXF Helpful materials for NewBie / Because org.springframework.beans.factory.BeanCreationException: Error creating bean with name
Date Sun, 11 Oct 2015 09:51:16 GMT
I figured out the problem, thanks for reading it , Its kind of solved, I
would write additional question if any soon. Certain changes in
ApplciaitonContext.xml, URL Patten, and annotations on Service helped.

This Link actually helped :

https://idodevjobs.wordpress.com/2014/08/30/develop-a-simple-restful-webservices-using-apache-cxf-and-spring-framework/

Thanks

On Sun, Oct 11, 2015 at 3:19 PM, Sumit Arora <sumit1234@gmail.com> wrote:

> Dear All,
>
> I have recently started the development of Restful web services with
> Apache CXF/Spring. Its a little bit difficult for me to configure the
> requisite config files even for a *HelloWorld Program*.
>
> *Here is my Dir Structure*
>
>   src/main/java/com.esumit.all/SimpleQAImpl.Java
>   resources - empty
>   webapp/WEB-INF/
>     -- applicationContext.xml
>     -- web.xml
>  index.jsp
>
> *Content of SimpleQAImpl.Java*
>
> package com.esumit.all;
> import javax.ws.rs.GET;
> import javax.ws.rs.Path;
> import javax.ws.rs.Produces;
> import javax.ws.rs.core.MediaType;
> import java.util.List;
> import org.springframework.stereotype.Service;
> /** * Created by eSumit on 10/9/15. */
>
> @Service
> @Path("/simpleqa")
> public class SimpleQAImpl {
>    @GET
>    @Produces(MediaType.APPLICATION_JSON)
>    public String getText() {
>        return "Sumit Arora";
>    }
> }
>
> *Content of applicationContext.xml*
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>
>        xmlns:context="http://www.springframework.org/schema/context"
>        xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:cxf="
> http://cxf.apache.org/core"
>
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
>        xsi:schemaLocation="
>                         http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd
>
>                         http://www.springframework.org/schema/context
> http://www.springframework.org/schema/context/spring-context.xsd
>
>                         http://cxf.apache.org/jaxrs
> http://cxf.apache.org/schemas/jaxrs.xsd
>
>                         http://cxf.apache.org/core
> http://cxf.apache.org/schemas/core.xsd">
>
>
>     <context:component-scan base-package="com.esumit.all" />
>
>
>     <jaxrs:server address="/simpleqa" id="SimpleQAImpl">
>
>
>
>     </jaxrs:server>
>
>     <bean class="com.esumit.all.SimpleQAImpl" id="simple">
>
>     </bean>
>
>
> </beans>
>
> *Content of Web.xml*
>
>
> <!DOCTYPE web-app PUBLIC
>  "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
>  "http://java.sun.com/dtd/web-app_2_3.dtd" >
>
> <web-app>
>   <display-name>Archetype Created Web Application</display-name>
>
>     <listener>
>
> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
>     </listener>
>     <servlet>
>         <servlet-name>CXFServlet</servlet-name>
>
> <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
>         <load-on-startup>1</load-on-startup>
>     </servlet>
>
>     <servlet-mapping>
>         <servlet-name>CXFServlet</servlet-name>
>         <url-pattern>/simpleqa/*</url-pattern>
>     </servlet-mapping>
> </web-app>
>
> org.springframework.beans.factory.BeanCreationException: Error creating
> bean with name 'SimpleQAImpl': Invocation of init method failed; nested
> exception is org.apache.cxf.service.factory.ServiceConstructionException
>
> *Logs *
>
> Oct 10, 2015 11:44:32 AM org.apache.coyote.AbstractProtocol init
> INFO: Initializing ProtocolHandler ["http-bio-8080"]
> Oct 10, 2015 11:44:32 AM org.apache.catalina.core.StandardService
> startInternal
> INFO: Starting service Tomcat
> Oct 10, 2015 11:44:32 AM org.apache.catalina.core.StandardEngine
> startInternal
> INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
> Oct 10, 2015 11:44:34 AM org.apache.catalina.core.ApplicationContext log
> INFO: No Spring WebApplicationInitializer types detected on classpath
> Oct 10, 2015 11:44:34 AM org.apache.catalina.core.ApplicationContext log
> INFO: Initializing Spring root WebApplicationContext
> Oct 10, 2015 11:44:34 AM org.springframework.web.context.ContextLoader
> initWebApplicationContext
> INFO: Root WebApplicationContext: initialization started
> Oct 10, 2015 11:44:34 AM
> org.springframework.context.support.AbstractApplicationContext
> prepareRefresh
> INFO: Refreshing Root WebApplicationContext: startup date [Sat Oct 10
> 11:44:34 IST 2015]; root of context hierarchy
> Oct 10, 2015 11:44:34 AM
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader
> loadBeanDefinitions
> INFO: Loading XML bean definitions from ServletContext resource
> [/WEB-INF/applicationContext.xml]
> Oct 10, 2015 11:46:41 AM org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean
> checkResources
> SEVERE: No resource classes found
> Oct 10, 2015 12:19:01 PM org.springframework.web.context.ContextLoader
> initWebApplicationContext
> SEVERE: Context initialization failed
> *org.springframework.beans.factory.BeanCreationException: Error creating
> bean with name 'SimpleQAImpl': Invocation of init method failed; nested
> exception is *org.apache.cxf.service.factory.ServiceConstructionException
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
> at
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
> at
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
> at
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
> at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
> at org.springframework.b
>
> ---------------------------------
>
> - I totally understand that this program is doing even basic mistakes, may
> you please suggest me how to understand teh basic concepts and apply here
> to make this even basic 'helloworld' program work ?
>
> Questions -
>
> 1. Do we need to add the Spring ApplicationContext file ?
>
> Thanks for everything,
> 'Sumit
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message