开发者社区> 问答> 正文

weblogic11g无法部署springmvc3.2+cxf3.0.8 web应用?报错

最近在学习cxf,写了一个简单的例子,和springmvc集成,在tomcat6下运行成功。但是部署到weblogic11g上时,一直在报错,google了很久,没有找到解决方法,在这里提出问题,希望大家帮忙看看,提提思路。

jdk版本是1.6(jrockit),weblogic版本是11g(10.3.6),

web.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>mavenweb</display-name>
	
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:spring-core.xml</param-value>
	</context-param>
	
	<listener>
		<description>spring监听器</description>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	<filter>
		<filter-name>CharacterEncodingFilter</filter-name>
		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
		<init-param>
			<param-name>encoding</param-name>
			<param-value>UTF-8</param-value>
		</init-param>
		<init-param>
			<param-name>forceEncoding</param-name>
			<param-value>true</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>CharacterEncodingFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>


	<servlet>
		<servlet-name>dispatcher</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>classpath:spring-servlet.xml</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>dispatcher</servlet-name>
		<url-pattern>*.do</url-pattern>
	</servlet-mapping>
	
    
    <!-- cxf -->
    <servlet>
        <servlet-name>cxf</servlet-name>
        <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>cxf</servlet-name>
        <url-pattern>/webservice/cxf/*</url-pattern>
    </servlet-mapping>
	
</web-app>



weblogic.xml配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app>
	<container-descriptor>
		<index-directory-enabled>true</index-directory-enabled>
		<prefer-web-inf-classes>true</prefer-web-inf-classes>
	</container-descriptor>
	<session-descriptor>	  
		<cookie-name>JSESSIONID1</cookie-name>
		<debug-enabled>true</debug-enabled>
		<persistent-store-type>replicated_if_clustered</persistent-store-type>
		<sharing-enabled>true</sharing-enabled>
	</session-descriptor>
</weblogic-web-app>



spring-core.xml配置如下:



<?xml version="1.0" encoding="UTF-8"?>  
<beans xmlns="http://www.springframework.org/schema/beans"   
       xmlns:aop="http://www.springframework.org/schema/aop"   
       xmlns:context="http://www.springframework.org/schema/context"  
       xmlns:mvc="http://www.springframework.org/schema/mvc"   
       xmlns:tx="http://www.springframework.org/schema/tx"   
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
       xsi:schemaLocation="http://www.springframework.org/schema/aop   
        http://www.springframework.org/schema/aop/spring-aop-3.0.xsd   
        http://www.springframework.org/schema/beans   
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd   
        http://www.springframework.org/schema/context   
        http://www.springframework.org/schema/context/spring-context-3.0.xsd   
        http://www.springframework.org/schema/mvc   
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd   
        http://www.springframework.org/schema/tx   
        http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">  
  
<!-- 此处略去spring、hibernate的各种配置 -->
	
	<!-- CXF支持-->
	<import resource="classpath:spring-cxf.xml"/> 
	
</beans>


spring-cxf.xml配置如下:


<?xml version="1.0" encoding="UTF-8"?>

<!-- START SNIPPET: beans -->
<beans xmlns="http://www.springframework.org/schema/beans" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	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.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="helloWorld" implementor="com.deo.base.webservice.cxf.service.impl.MyServiceImpl" address="/MyService"/>
    
    <bean id="restServiceImpl" class="com.deo.base.webservice.cxf.service.impl.MyRESTServiceImpl"></bean>
    
    <jaxrs:server id="restServiceContainer" address="/myrest">
    	<jaxrs:serviceBeans>
    		<ref bean="restServiceImpl"/>
    	</jaxrs:serviceBeans>
    </jaxrs:server>
</beans>
<!-- END SNIPPET: beans -->


webservice接口如下:



package com.deo.base.webservice.cxf.service;

import javax.jws.WebParam;
import javax.jws.WebService;

@WebService
public interface MyService {

	public String sayHello(@WebParam(name="usernames")String username, @WebParam(name="passwords")String password);
}


webserice接口实现如下:



package com.deo.base.webservice.cxf.service.impl;

import javax.annotation.Resource;
import javax.jws.WebService;

import com.deo.base.entity.DemoEntity;
import com.deo.base.service.BaseService;
import com.deo.base.webservice.cxf.service.MyService;

@WebService
public class MyServiceImpl implements MyService {
	
	@Resource
	private BaseService baseService;

	@Override
	public String sayHello(String username, String password) {
		DemoEntity baseEntity = new DemoEntity();
		baseEntity.setUsername(username);
		baseEntity.setPassword(password);
		baseService.save(baseEntity);
		
		return "id " + baseEntity.getId() + ", username " + username + ", password " + password;
	}

}


weblogic控制台报错信息如下(保留了关键内容):


org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'helloWorld': Invocation of init method failed; nested exception is javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1512)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:633)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
	at com.oracle.weblogic.wsee.wrapper.org.springframework.web.context.ContextLoaderListener.contextInitialized(Unknown Source)
	at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:481)
	at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
	at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
	at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:181)
	at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1868)
	at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3154)
	at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1518)
	at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:484)
	at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
	...
	at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Caused By: javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException
	at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:371)
	at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:252)
	at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:540)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1638)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1579)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
	...
	at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Caused By: org.apache.cxf.service.factory.ServiceConstructionException
	at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:329)
	at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:88)
	at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:469)
	at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:713)
	at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:527)
	at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:263)
	at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:215)
	at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)
	at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:159)
	at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)
	at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:456)
	at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:335)
	at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:252)
	at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:540)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1638)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1579)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
	...
	at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Caused By: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
Class has two properties of the same name "passwords"
	this problem is related to the following location:
		at public java.lang.String com.deo.base.webservice.cxf.service.jaxws_asm.SayHello.getPasswords()
		at com.deo.base.webservice.cxf.service.jaxws_asm.SayHello
	this problem is related to the following location:
		at private java.lang.String com.deo.base.webservice.cxf.service.jaxws_asm.SayHello.passwords
		at com.deo.base.webservice.cxf.service.jaxws_asm.SayHello
Class has two properties of the same name "usernames"
	this problem is related to the following location:
		at public java.lang.String com.deo.base.webservice.cxf.service.jaxws_asm.SayHello.getUsernames()
		at com.deo.base.webservice.cxf.service.jaxws_asm.SayHello
	this problem is related to the following location:
		at private java.lang.String com.deo.base.webservice.cxf.service.jaxws_asm.SayHello.usernames
		at com.deo.base.webservice.cxf.service.jaxws_asm.SayHello

	at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:102)
	at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:448)
	at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:297)
	at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:139)
	at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:117)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:212)
	at javax.xml.bind.ContextFinder.find(ContextFinder.java:372)
	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
	at org.apache.cxf.common.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:347)
	at org.apache.cxf.common.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:345)
	at org.apache.cxf.common.jaxb.JAXBContextCache.createContext(JAXBContextCache.java:345)
	at org.apache.cxf.common.jaxb.JAXBContextCache.getCachedContextAndSchemas(JAXBContextCache.java:246)
	at org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:472)
	...
	at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:540)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1638)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1579)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
	...
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:113)
	at com.oracle.weblogic.wsee.wrapper.org.springframework.web.context.ContextLoaderListener.contextInitialized(Unknown Source)
	at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:481)
	at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
	at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
	...
	at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
	at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:569)
	...
	at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:164)
	at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
	at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13)
	at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:69)
	at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
	at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
	at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)



展开
收起
爱吃鱼的程序员 2020-06-09 16:36:17 681 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    报错显示,配置的用户名密码配置了两次
    但是service的webparam我只写了这一个啊手动顶!

    关于spring和cxf的配置,可参考:http://git.oschina.net/wangkang/llsfw

    希望能够帮到你.

    再次顶

    2020-06-09 16:36:33
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Web应用系统性能优化 立即下载
高性能Web架构之缓存体系 立即下载
PWA:移动Web的现在与未来 立即下载