当前位置: 首页 > 知识库问答 >
问题:

CXF-SOAP-SPRING部署bean创建异常:创建名为“accountDetailsService”的bean时出错:

濮书
2023-03-14

Tomcat日志文件显示:

严重:向类org的侦听器实例发送上下文初始化事件时发生异常。springframework。网状物上下文ContextLoaderListener组织。springframework。豆。工厂BeanCreationException:创建名为“accountDetailsService”的bean时出错:调用init方法失败;嵌套异常为java。lang.NoSuchFieldError:反射

应用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:context="http://www.springframework.org/schema/context"
 xmlns:util="http://www.springframework.org/schema/util"
 xmlns:p="http://www.springframework.org/schema/p"
 xmlns:jaxws="http://cxf.apache.org/jaxws"
 xmlns:jaxrs="http://cxf.apache.org/jaxrs"
 xsi:schemaLocation="
 http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
 http://www.springframework.org/schema/context
 http://www.springframework.org/schema/context/spring-context-2.5.xsd/spring-spring-context-3.1.xsd-3.1.2.RELEASE.xsd
 http://www.springframework.org/schema/util
  http://www.springframework.org/schema/util/spring-util-3.1.xsd
  http://cxf.apache.org/jaxws
  http://cxf.apache.org/schemas/jaxws.xsd
  http://cxf.apache.org/jaxrs
  http://cxf.apache.org/schemas/jaxrs.xsd">
  <import resource="classpath:META-INF/cxf/cxf.xml" />
  <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
  <jaxws:endpoint id="accountDetailsService"
   implementor="com.ctl.prepay.account.webservice.impl.AccountDetailsServiceImpl"
   address="/account"/> 
</beans>`

网状物xml:

 <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
        <display-name>account</display-name>    
        <!-- the session timeout -->
        <session-config>
            <session-timeout>30</session-timeout>
        </session-config>    
        <!-- welcome files -->
        <welcome-file-list>
            <welcome-file>account.jsp</welcome-file>
        </welcome-file-list>    
        <context-param>
        <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/applicationContext.xml</param-value>
        </context-param>
        <servlet>
        <servlet-name>CXFServlet</servlet-name>
        <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
      </servlet> 
      <servlet-mapping>
        <servlet-name>CXFServlet</servlet-name>
        <url-pattern>/ws/*</url-pattern>
      </servlet-mapping>  
        <listener>
                <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener> 
         <listener>
            <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
        </listener>    
        </web-app>`

pom。xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>

      <groupId>account</groupId>
        <artifactId>account</artifactId>
        <packaging>war</packaging>
        <version>1.0-SNAPSHOT</version>


    <!--needs to be checked the requirement  -->
        <name>account</name>
        <url>http://maven.apache.org</url>


        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>    
            <org.springframework.version>3.2.8.RELEASE</org.springframework.version>
        </properties>


        <dependencies>
        <!--to solve the errror  -->

             <dependency>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-rt-frontend-jaxws</artifactId>
                <version>3.0.1</version>
            </dependency>

            <dependency>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-rt-frontend-jaxrs</artifactId>
                <version>3.0.1</version>
            </dependency>
            <dependency>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-rt-transports-http</artifactId>
                <version>3.0.1</version>
            </dependency>

            <dependency>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-bundle-jaxrs</artifactId>
                <version>2.7.15</version>
            </dependency>

            <dependency>
                <groupId>org.apache.felix</groupId>
                <artifactId>org.osgi.core</artifactId>
                <version>1.2.0</version>
            </dependency>

            <dependency>
                <groupId>org.apache.felix</groupId>
                <artifactId>org.osgi.compendium</artifactId>
                <version>1.2.0</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.apache.felix</groupId>
                        <artifactId>org.osgi.foundation</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <version>${org.springframework.version}</version>
            </dependency>

            <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-web</artifactId>
                 <version>3.0.4.RELEASE</version>
            </dependency>


            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-beans</artifactId>
                <version>${org.springframework.version}</version>
            </dependency>

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>${org.springframework.version}</version>
            </dependency>

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-jdbc</artifactId>
                <version>${org.springframework.version}</version>
            </dependency>

            <dependency>
                <groupId>com.oracle</groupId>
                <artifactId>ojdbc14</artifactId>
                <version>10.2.0.4.0</version>
            </dependency>

            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpclient</artifactId>
                <version>4.1.1</version>
            </dependency>

            <dependency>
                  <groupId>exml</groupId>
                  <artifactId>exml</artifactId>
                  <version>7.0</version>
           </dependency>

           <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>1.7.12</version>
            </dependency>

            <!-- JUnit -->
          <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.11</version>
                <scope>test</scope>
            </dependency>

             <dependency>
                <groupId>exml</groupId>
                <artifactId>exml</artifactId>
                <version>7.0</version>
            </dependency>

    <!-- hibernate services -->

            <dependency>
                <groupId>taglibs</groupId>
                <artifactId>standard</artifactId>
                <version>1.1.2</version>
            </dependency>

            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>jstl</artifactId>
                <version>1.1.2</version>
            </dependency>

            <dependency>
                <groupId>commons-dbcp</groupId>
                <artifactId>commons-dbcp</artifactId>
                <version>20030825.184428</version>
            </dependency>

            <dependency>
                <groupId>commons-pool</groupId>
                <artifactId>commons-pool</artifactId>
                <version>20030825.183949</version>
            </dependency>

            <dependency>
                <groupId>org.hibernate.javax.persistence</groupId>
                <artifactId>hibernate-jpa-2.0-api</artifactId>
                <version>1.0.1.Final</version>
            </dependency>

            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
                <version>4.2.4.Final</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-api</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

            <!--  -->


             <!--     <dependency>
                     <groupId>javax.servlet</groupId>
                     <artifactId>javax.servlet-api</artifactId>
                     <version>3.0.1</version>
                     <scope>provided</scope>
                </dependency>
                 -->
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>servlet-api</artifactId>
                <version>2.5</version>
                <scope>provided</scope>
            </dependency>

            <dependency>
                <groupId>javax.servlet.jsp</groupId>
                <artifactId>jsp-api</artifactId>
                <version>2.1</version>
                <scope>provided</scope>
            </dependency>


        </dependencies>

            <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.3.1</version>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                        <encoding>${project.build.sourceEncoding}</encoding>
                    </configuration>
                </plugin>


                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>2.4.3</version>
                    <configuration>
                        <encoding>${project.build.sourceEncoding}</encoding>
                    </configuration>
                </plugin>

            </plugins>

             <finalName>account</finalName>
        </build>




    </project>

共有1个答案

隗翰海
2023-03-14

Docs说jaxws: endpoint中的实现器属性使用完全限定的类名或对配置实现类的Spring bean的ID引用来指定实现类。

在您的例子中,引用带前导“#”符号的bean id不知道为什么?,您是否可以直接使用类名而不是bean id,因为您的AccountDetailsServiceImpl很简单,没有任何依赖项。

 类似资料: