tomcat遷移到weblogic的幾個問題

第1個問題:css

異常描述:VALIDATION PROBLEMS WERE FOUND problem: cvc-enumeration-valid: string value '3.0' is not a valid enumeration value for web-app-versionType in namespace http://java.sun.com/xml/ns/javaee:<null>java

由於建立項目的時候用的是JAVAEE6,因此生成web.xml文件的時候是這樣的:web

<web-app version="3.0"   
    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_3_0.xsd">

weblogic10.3.6並不支持web-app_3_0.xsd的定義。因此報錯了。spring

<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">

或者部署到weblogic 12。express

第2個問題:tomcat

異常描述:mvc

Caused by: weblogic.management.DeploymentException: [HTTP:101170]The servlet default is referenced in servlet-mapping *.js, but not defined in web.xml.app

緣由:用默認servlet處理靜態資源。url

<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.js</url-pattern>
  </servlet-mapping>
 
 <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.css</url-pattern>
  </servlet-mapping>

每一個web容器都有一個默認servlet,在tomcat默認servlet的名字是:defalut。而在weblogic是:FileServlet。下面列出各容器的默認servlet的名字spa

Tomcat, Jetty, JBoss, and GlassFish 默認 Servlet的名字"default" WebLogic 默認 Servlet的名字 "FileServlet" ,WebSphere默認 Servlet的名字 "Simpledefault" 。

將上面的default改爲FileServlet就能夠了。

第3個問題:

異常描述:

Annotation-specified bean name 'containerTransactionType.Factory' for bean class [com.sun.java.xml.ns.javaee.ContainerTransactionType$Factory] conflicts with existing, non-compatible bean definition of same name and class [com.sun.java.xml.ns.j2Ee.ContainerTransactionType$Factory]

緣由:

mvc-dispatcher-servlet.xml裏有這樣一個配置,

<!-- 須要掃描的標註了@Controller的類 -->
    <context:component-scan base-package="com">
        <context:include-filter type="regex"
            expression=".*.action.*" />
            <!-- 這裏排除service,防止事務失效 -->
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/> 
    </context:component-scan>

個人包名是com.公司名.模塊名。因爲weblogic的包裏也有以com開頭action結尾的包,spring把它的包也掃描了,並注入容器。出現了同名的bean。因此報錯。

解決方法,   將<context:component-scan base-package="com">中包名加一層, 改爲: <context:component-scan base-package="com.公司名">。

第4個問題:

異常描述:

Caused by: java.lang.Throwable: Substituted for missing class org.springframework.beans.factory.BeanCreationException - Error creating bean with name 'ditemAction': Injection of autowired depende
ncies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.jfpal.riskmanage.item.service.IDitemService 

這是在createing 控制器 ‘ditemAction’時出的錯。緣由是沒法注入屬性com.jfpal.riskmanage.item.service.IDitemService 。代碼確定沒問題的,tomcat上運行正常。

通過分析,判定spring沒掃描com.jfpal.riskmanage.item.service.IDitemService 所在的包。

而後查看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>

後面那個數據源的配置。改後部署成功。緣由是weblogic和tomcat解析<param-value>有點不同。

第5個問題:

訪問項目時出錯,報404,說找不到**/**/dwz.frag.xml。查看web.xml,沒有配置xml靜態資源的訪問,加上以下配置

<servlet-mapping>
        <servlet-name>FileServlet</servlet-name>
        <url-pattern>*.xml</url-pattern>
    </servlet-mapping>

至此遷移成功。

還有一些問題,參考個人另外一篇文章《weblogic部署tomcat項目時遇到的一些錯誤及解決方式》https://my.oschina.net/shuming/blog/698155

相關文章
相關標籤/搜索