You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by smq <sm...@hotmail.com> on 2015/02/23 20:17:16 UTC

Error: No bean named 'cxf' is defined with cxf.xml imported

Hi,

I am setting up a simple RESTful web service using Apache CXF 3.0.0.  I keep
getting the following error:

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
named 'cxf' is defined

even though I already have

<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/> 

in WEB-INF/conf/application-context.xml file.  I may be missing something
basic here, please help!!

Here is my pom.xml:

 <properties>
		<maven.compiler.source>1.7</maven.compiler.source>
		<maven.compiler.target>1.7</maven.compiler.target>
		<cxf.version>3.0.0</cxf.version>
		<spring.version>4.1.4.RELEASE</spring.version>
		<spring-ldap.version>2.0.2.RELEASE</spring-ldap.version>
		<hibernate.version>4.2.11.Final</hibernate.version>
		<servletapi.version>2.5</servletapi.version>
  </properties>
  
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
  	  <groupId>org.apache.cxf</groupId>
   	  <artifactId>cxf-rt-frontend-jaxrs</artifactId>
	  <version>${cxf.version}</version>
	  <exclusions>
       <exclusion>
         <groupId>org.eclipse.jetty</groupId>
         <artifactId>jetty-server</artifactId>
       </exclusion>
   </exclusions> 
	</dependency>
	    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>${cxf.version}</version>
    </dependency>
	<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
    </dependency>
    		<dependency>
			<groupId>org.springframework.ldap</groupId>
			<artifactId>spring-ldap-core</artifactId>
			<version>${spring-ldap.version}</version>
			<type>jar</type>
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.ldap</groupId>
			<artifactId>spring-ldap-test</artifactId>
			<version>${spring-ldap.version}</version>
			<type>jar</type>
			<scope>test</scope>
		</dependency>
				<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-web</artifactId>
			<version>${spring.version}</version>
		</dependency>
    <dependency>
			<groupId>org.json</groupId>
			<artifactId>json</artifactId>
			<version>20140107</version>
		</dependency>
	<dependency>
		<groupId>commons-lang</groupId>
		<artifactId>commons-lang</artifactId>
		<version>2.3</version>
	</dependency>
	
	<dependency>
		<groupId>org.hibernate</groupId>
		<artifactId>hibernate-core</artifactId>
		<version>${hibernate.version}</version>
	</dependency>
	<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>servlet-api</artifactId>
			<version>${servletapi.version}</version>
			<scope>provided</scope>
		</dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>1.7.0</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.0</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.0</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.14</version>
    </dependency>
  </dependencies>

web.xml:::
<web-app>
  <display-name>secws</display-name>
  	<description>Web Service</description>

	<context-param>
		<param-name>contextConfigLocation</param-name>
		
		<param-value>classpath*:/conf/*-context.xml</param-value>
	</context-param>

<context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>/WEB-INF/conf/log4j.properties</param-value>
</context-param>	
<listener>
   
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>	

	<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>/services/*</url-pattern>
	</servlet-mapping>
</web-app>

WEB-INF/conf/application-context.xml:::::

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

	 <import resource="classpath:META-INF/cxf/cxf.xml"/>
	<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/> 

    <cxf:bus>
        <cxf:features>
            <cxf:logging/>
        </cxf:features>
    </cxf:bus>


	<bean id="userLdapDao" 
		class="com.xxx.dao.ldap.UserDaoLdapImpl" /> 
		
	<bean id="userSqlDao" 
		class="com.xxx.dao.Sql.UserDaoSqlImpl" /> 
		

	<bean id="securityMgrService" 
		class="com.xxx.ws.impl.SecurityMgrServiceImpl">
		<property name="userLdapDao" ref="userLdapDao"/>
		<property name="userSqlDao" ref="userSqlDao"/>
	</bean>

	<bean id="jsonProvider" 
		class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>
	
  	<jaxrs:server id="securityMgrServiceREST" address="/">
  		<jaxrs:serviceBeans>
  			<ref bean="securityMgrService"/>
  		</jaxrs:serviceBeans>
  		<jaxrs:providers>
			<ref bean='jsonProvider' />
		</jaxrs:providers>
  	</jaxrs:server> 	

</beans>




--
View this message in context: http://cxf.547215.n5.nabble.com/Error-No-bean-named-cxf-is-defined-with-cxf-xml-imported-tp5754557.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Error: No bean named 'cxf' is defined with cxf.xml imported

Posted by Sergey Beryozkin <sb...@gmail.com>.
I've actually no idea why you are seeing that error given that you do 
not have any explicit references to a 'cxf' bean...
On 24/02/15 14:00, smq wrote:
> Could you please clarify on where I need an explicit reference to the 'cxf'
> bean? and how?
>
> I thought what I have in application-context.xml is sufficient based on some
> of the CXF tutorials out there:
>
>    <jaxrs:server id="securityMgrServiceREST" address="/">
>    <jaxrs:serviceBeans>
>    <ref bean="securityMgrService"/>
>    </jaxrs:serviceBeans>
>    <jaxrs:providers>
>                          <ref bean='jsonProvider' />
>                  </jaxrs:providers>
>    </jaxrs:server> 	
>
> Any input would be appreciated!!
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Error-No-bean-named-cxf-is-defined-with-cxf-xml-imported-tp5754557p5754583.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>


Re: Error: No bean named 'cxf' is defined with cxf.xml imported

Posted by smq <sm...@hotmail.com>.
Could you please clarify on where I need an explicit reference to the 'cxf'
bean? and how?

I thought what I have in application-context.xml is sufficient based on some
of the CXF tutorials out there:

  <jaxrs:server id="securityMgrServiceREST" address="/">
  <jaxrs:serviceBeans>
  <ref bean="securityMgrService"/>
  </jaxrs:serviceBeans>
  <jaxrs:providers>
                        <ref bean='jsonProvider' />
                </jaxrs:providers>
  </jaxrs:server> 	

Any input would be appreciated!!



--
View this message in context: http://cxf.547215.n5.nabble.com/Error-No-bean-named-cxf-is-defined-with-cxf-xml-imported-tp5754557p5754583.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Error: No bean named 'cxf' is defined with cxf.xml imported

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

I'm not sure what is going on there, all appears to be fine, I do not 
see any explicit references to a 'cxf' bean in your context example 
though...

Sergey
On 23/02/15 19:17, smq wrote:
> Hi,
>
> I am setting up a simple RESTful web service using Apache CXF 3.0.0.  I keep
> getting the following error:
>
> org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
> named 'cxf' is defined
>
> even though I already have
>
> <import resource="classpath:META-INF/cxf/cxf.xml"/>
> <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
>
> in WEB-INF/conf/application-context.xml file.  I may be missing something
> basic here, please help!!
>
> Here is my pom.xml:
>
>   <properties>
> 		<maven.compiler.source>1.7</maven.compiler.source>
> 		<maven.compiler.target>1.7</maven.compiler.target>
> 		<cxf.version>3.0.0</cxf.version>
> 		<spring.version>4.1.4.RELEASE</spring.version>
> 		<spring-ldap.version>2.0.2.RELEASE</spring-ldap.version>
> 		<hibernate.version>4.2.11.Final</hibernate.version>
> 		<servletapi.version>2.5</servletapi.version>
>    </properties>
>
>    <dependencies>
>      <dependency>
>        <groupId>junit</groupId>
>        <artifactId>junit</artifactId>
>        <version>3.8.1</version>
>        <scope>test</scope>
>      </dependency>
>      <dependency>
>    	  <groupId>org.apache.cxf</groupId>
>     	  <artifactId>cxf-rt-frontend-jaxrs</artifactId>
> 	  <version>${cxf.version}</version>
> 	  <exclusions>
>         <exclusion>
>           <groupId>org.eclipse.jetty</groupId>
>           <artifactId>jetty-server</artifactId>
>         </exclusion>
>     </exclusions>
> 	</dependency>
> 	    <dependency>
>          <groupId>org.apache.cxf</groupId>
>          <artifactId>cxf-rt-transports-http</artifactId>
>          <version>${cxf.version}</version>
>      </dependency>
> 	<dependency>
>          <groupId>org.springframework</groupId>
>          <artifactId>spring-context</artifactId>
>          <version>${spring.version}</version>
>      </dependency>
>      		<dependency>
> 			<groupId>org.springframework.ldap</groupId>
> 			<artifactId>spring-ldap-core</artifactId>
> 			<version>${spring-ldap.version}</version>
> 			<type>jar</type>
> 			<scope>compile</scope>
> 		</dependency>
> 		<dependency>
> 			<groupId>org.springframework.ldap</groupId>
> 			<artifactId>spring-ldap-test</artifactId>
> 			<version>${spring-ldap.version}</version>
> 			<type>jar</type>
> 			<scope>test</scope>
> 		</dependency>
> 				<dependency>
> 			<groupId>org.springframework</groupId>
> 			<artifactId>spring-web</artifactId>
> 			<version>${spring.version}</version>
> 		</dependency>
>      <dependency>
> 			<groupId>org.json</groupId>
> 			<artifactId>json</artifactId>
> 			<version>20140107</version>
> 		</dependency>
> 	<dependency>
> 		<groupId>commons-lang</groupId>
> 		<artifactId>commons-lang</artifactId>
> 		<version>2.3</version>
> 	</dependency>
> 	
> 	<dependency>
> 		<groupId>org.hibernate</groupId>
> 		<artifactId>hibernate-core</artifactId>
> 		<version>${hibernate.version}</version>
> 	</dependency>
> 	<dependency>
> 			<groupId>javax.servlet</groupId>
> 			<artifactId>servlet-api</artifactId>
> 			<version>${servletapi.version}</version>
> 			<scope>provided</scope>
> 		</dependency>
>      <dependency>
>          <groupId>org.slf4j</groupId>
>          <artifactId>jcl-over-slf4j</artifactId>
>          <version>1.7.0</version>
>          <scope>runtime</scope>
>      </dependency>
>      <dependency>
>          <groupId>org.slf4j</groupId>
>          <artifactId>slf4j-api</artifactId>
>          <version>1.7.0</version>
>          <scope>runtime</scope>
>      </dependency>
>      <dependency>
>          <groupId>org.slf4j</groupId>
>          <artifactId>slf4j-log4j12</artifactId>
>          <version>1.7.0</version>
>          <scope>runtime</scope>
>      </dependency>
>      <dependency>
>          <groupId>log4j</groupId>
>          <artifactId>log4j</artifactId>
>          <version>1.2.14</version>
>      </dependency>
>    </dependencies>
>
> web.xml:::
> <web-app>
>    <display-name>secws</display-name>
>    	<description>Web Service</description>
>
> 	<context-param>
> 		<param-name>contextConfigLocation</param-name>
> 		
> 		<param-value>classpath*:/conf/*-context.xml</param-value>
> 	</context-param>
>
> <context-param>
>      <param-name>log4jConfigLocation</param-name>
>      <param-value>/WEB-INF/conf/log4j.properties</param-value>
> </context-param>	
> <listener>
>
> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
> </listener>	
>
> 	<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>/services/*</url-pattern>
> 	</servlet-mapping>
> </web-app>
>
> WEB-INF/conf/application-context.xml:::::
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
> 		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>       	xmlns:cxf="http://cxf.apache.org/core"
> 		xmlns:jaxws="http://cxf.apache.org/jaxws"
> 		xmlns:jaxrs="http://cxf.apache.org/jaxrs"
> 		xsi:schemaLocation="
> 			http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
> 			http://www.springframework.org/schema/beans
> 			http://www.springframework.org/schema/beans/spring-beans.xsd
> 			http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
> 			http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
>
> 	 <import resource="classpath:META-INF/cxf/cxf.xml"/>
> 	<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
>
>      <cxf:bus>
>          <cxf:features>
>              <cxf:logging/>
>          </cxf:features>
>      </cxf:bus>
>
>
> 	<bean id="userLdapDao"
> 		class="com.xxx.dao.ldap.UserDaoLdapImpl" />
> 		
> 	<bean id="userSqlDao"
> 		class="com.xxx.dao.Sql.UserDaoSqlImpl" />
> 		
>
> 	<bean id="securityMgrService"
> 		class="com.xxx.ws.impl.SecurityMgrServiceImpl">
> 		<property name="userLdapDao" ref="userLdapDao"/>
> 		<property name="userSqlDao" ref="userSqlDao"/>
> 	</bean>
>
> 	<bean id="jsonProvider"
> 		class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>
> 	
>    	<jaxrs:server id="securityMgrServiceREST" address="/">
>    		<jaxrs:serviceBeans>
>    			<ref bean="securityMgrService"/>
>    		</jaxrs:serviceBeans>
>    		<jaxrs:providers>
> 			<ref bean='jsonProvider' />
> 		</jaxrs:providers>
>    	</jaxrs:server> 	
>
> </beans>
>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Error-No-bean-named-cxf-is-defined-with-cxf-xml-imported-tp5754557.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com