web tomcat 7可以运行,部署weblogic10.3不行

工程 :mave ,mybits,spring spring mvc restful

项目在tomcat 下正常运行,而在weblogic各种错误:

1)首先出现的 ,打成war 上传到weblogic 服务器,启动weblogic 也正常,视乎一切都很顺利,在浏览器很愉快的敲响首页的访问地址(敲回车特用力),尼玛,一点反应都有,没有404 没有500 更没有503....吐血之旅就这样开始了,查看了AdminServer下log, 貌似只说找不到这个URL 处理类,很平常,一点异常都木有,往往看似平常,最后最难下手,google下,组尝试了下 下面的做法,竟然部署上去了

然后查看web.xml,发现如下配置

 

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

 

将其改为

 

<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value>classpath:applicationContext.xml,classpath:applicationContext-myBatis.xml</param-value> 
  </context-param>


2) 紧接着,马上给你抛个异常,这回比什么信息都木有好多,起码见红了,兴奋无比,在去见google,说包冲突,幸亏这次工程用maven,去掉某些包,容易

java.lang.ClassCastException: weblogic.xml.jaxp.RegistryDocumentBuilderFactory cannot be cast to javax.xml.parser.DocumentBuilderFactroy

      原因:war包中的xml-apis-xx.jar和weblogic中的xml解析包出现冲突;

      解决办法:从项目中删掉这个jar包,如果是在maven情况下,可以采用maven的方式去掉,比如这个包是引入dom4j时传递引入的包,则可致在依赖中添加exclusion标签去掉

                          对该jar包的依赖;

maven 打包去掉某些jar

<packagingExcludes>
<!-- WEB-INF/classes/com/thinkgem/jeesite/** -->
WEB-INF/classes/org/apache/ibatis/**,
WEB-INF/classes/org/mybatis/spring/**,
WEB-INF/lib/xml-apis-*.jar

</packagingExcludes>

或者包scope改下

   * compile,缺省值,适用于所有阶段,会随着项目一起发布。
    * provided,类似compile,期望JDK、容器或使用者会提供这个依赖。如servlet.jar。
    * runtime,只在运行时使用,如JDBC驱动,适用运行和测试阶段。
    * test,只在测试时使用,用于编译和运行测试代码。不会随项目发布。
    * system,类似provided,需要显式提供包含依赖的jar,Maven不会在Repository中查找它。 


3) 搞定上面那个后,新的异常 接踵而至,org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean#0': Invocation of init method failed; nested exception is java.lang.ClassCastException: weblogic.xml.stax.XMLStreamInputFactory cannot be cast to javax.xml.stream.XMLInputFactory
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1554)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
      解决方法 https://community.oracle.com/thread/847969?start=0&tstart=0

weblogic-application.xml


<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application xmlns="http://www.bea.com/ns/weblogic/90">
<!-- prefer-application-packages -->
<package-name>javax.xml.ws.*</package-name>
<package-name>javax.xml.bind.*</package-name>
<package-name>javax.jws.*</package-name>
<package-name>javax.namespace.xml.*</package-name>
<package-name>javax.xml.soap.*</package-name>
<package-name>org.apache.xerces.*</package-name>
<package-name>org.apache.commons.*</package-name>
<package-name>com.sun.xml.*</package-name>
<package-name>org.hibernate.*</package-name>    


<container-descriptor>
     <prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor> 
    <charset-params>
        <input-charset>
            <resource-path>/*</resource-path>
            <java-charset-name>UTF-8</java-charset-name>
        </input-charset>
    </charset-params>
    <jsp-descriptor>
        <encoding>UTF-8</encoding>
    </jsp-descriptor>
    <context-root>/netManage</context-root>
    <session-descriptor>
        <timeout-secs>1800</timeout-secs>
    </session-descriptor>
    <weblogic-version>10.3</weblogic-version>
</weblogic-application>






4)程序终于可以跑起来,查询没问题,界面很美丽,很爽,可是当保持下,又来异常了

 Handler processing failed; nested exception is java.lang.AbstractMethodError
at org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1280)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:958)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Caused by: java.lang.AbstractMethodError
at javax.persistence.Persistence$1.isLoaded(Persistence.java:78)
at org.hibernate.validator.internal.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:56)
at org.hibernate.validator.internal.engine.resolver.DefaultTraversableResolver.isReachable(DefaultTraversableResolver.java:130)
at org.hibernate.validator.internal.engine.resolver.CachingTraversableResolverForSingleValidation.isReachable(CachingTraversableResolverForSingleValidation.java:46)
at org.hibernate.validator.internal.engine.ValidatorImpl.isReachable(ValidatorImpl.java:1358)
at org.hibernate.validator.internal.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:1343)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:520)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:465)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:429)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:381)
at org.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:184)
at org.springframework.validation.beanvalidation.SpringValidatorAdapter.validate(SpringValidatorAdapter.java:207)
at com.thinkgem.jeesite.common.beanvalidator.BeanValidators.validateWithException(BeanValidators.java:38)
at com.thinkgem.jeesite.common.web.BaseController.beanValidator(BaseController.java:77)
at com.thinkgem.jeesite.modules.sys.web.UserController.save(UserController.java:115)
at com.thinkgem.jeesite.modules.sys.web.UserController$$FastClassBySpringCGLIB$$25977f0a.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:708)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.apache.shiro.spring.security.interceptor.AopAllianceAnnotationsAuthorizingMethodInterceptor$1.proceed(AopAllianceAnnotationsAuthorizingMethodInterceptor.java:82)
at org.apache.shiro.authz.aop.AuthorizingMethodInterceptor.invoke(AuthorizingMethodInterceptor.java:39)
at org.apache.shiro.spring.security.interceptor.AopAllianceAnnotationsAuthorizingMethodInterceptor.invoke(AopAllianceAnnotationsAuthorizingMethodInterceptor.java:115)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:644)
at com.thinkgem.jeesite.modules.sys.web.UserController$$EnhancerBySpringCGLIB$$88b85748.save(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
... 43 more
(String)


weblogic 中使用hibernate validator

      使用hibernate validator,在tomcat下部署没有问题,发布到weblogic(10)下面就报错了。在使用验证时有以下错误:
java.lang.AbstractMethodError: getProviderUtil
at javax.persistence.Persistence$PersistenceUtilImpl.isLoaded(Unknown Source)
      出错原因是weblogic自身带有openjpa的包(hibernate、openjpa掐架?),解决方法是在spring中增加配置
dispatcher-servlet.xml
<mvc:annotation-driven validator="validator"/>

applicationContext.xml
<bean name="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<property name="traversableResolver">
<bean class="com.....ExtTraversableResolver"></bean>
</property>
</bean>

其中 ExtTraversableResolver代码如下:
import java.lang.annotation.ElementType;
import javax.validation.Path;
import javax.validation.TraversableResolver;

public class ExtTraversableResolver implements TraversableResolver {

public final boolean isReachable(Object traversableObject, Path.Node traversableProperty, Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
return true;
}

public final boolean isCascadable(Object traversableObject, Path.Node traversableProperty, Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
return true;
}
}

大功告成

你可能感兴趣的:(spring,tomcat,weblogic,异常)