本地WebServer为Tomcat7,最终部署到Weblogic 11g。以下方法全部为Google结果。


1. 部署后说ClassNotFoundException

 

weblogic类加载顺序问题,在WEB-INF目录下创建weblogic.xml。

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app
xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-web-app http://www.bea.com/ns/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">
    <container-descriptor>
        <index-directory-enabled>true</index-directory-enabled>
        <prefer-web-inf-classes>true</prefer-web-inf-classes>
        <show-archived-real-path-enabled>true</show-archived-real-path-enabled>
    </container-descriptor>
</weblogic-web-app>

表示让weblogic先加载WEB-INF/lib下面的jar包


2. unable to instantiate action


weblogic中的web.xml不支持通配符的写法,如:

部署到tomcat中可以这样写

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

 

但是在weblogic中必须这样写

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


3. SessionFactory配置

Tomcat下:

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="configLocation" value="classpath:hibernate.cfg.xml"/>
</bean>


Weblogic使用datasource:

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean" >
    <property name="jndiName">
        <value>jdbc/TESTDS</value>
    </property>
</bean>
    
<bean id="sessionFactory"
          class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="mappingResources">
        <list>
            <value>com/pojo/Refresh.hbm.xml</value>
        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
            <prop key="hibernate.connection.release_mode">auto</prop>
            <prop key="hibernate.current_session_context_class">jta</prop>
            <prop key="hibernate.transaction.manager_lookup_class">
                org.hibernate.transaction.WeblogicTransactionManagerLookup
            </prop>
        </props>
    </property>
</bean>


4. 修改weblogic部署的应用名称

通过weblogic管理后台console进行发布本地项目的时候,它会默认以WEB-INF的上一级目录作为访问路径。假如你的项目WEB-INF目录的上一层是WebRoot,那么发布后,访问的路径默认是:http://hostname:port/WebRoot,怎么样才能把WebRoot修改成其他内容呢? 解决方法就是修改weblogic.xml文件,增加<context-root>: 

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app
xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-web-app http://www.bea.com/ns/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">
    <context-root>/test</context-root> 
    <container-descriptor>
        <index-directory-enabled>true</index-directory-enabled>
        <prefer-web-inf-classes>true</prefer-web-inf-classes>
        <show-archived-real-path-enabled>true</show-archived-real-path-enabled>
    </container-descriptor>
</weblogic-web-app>

<context-root>标签之间的内容就是替换WebRoot的内容,只要改成你相应的内容即可,此时的访问变为http://hostname:port/test


参考链接:http://simon-fish.iteye.com/blog/1136438  

                  http://www.cnblogs.com/hanxianlong/p/3344546.html