当前位置:编程学习 > JAVA >>

【急求】SPRING配置DATASOURCE,tomcat启动无错,weblogic启动报错

--------------------编程问答-------------------- 先把内容写死,不读property文件,可能是property文件没有加载到。 --------------------编程问答-------------------- 那就奇怪了,开始我也怀疑过,如果把这个注释掉,另外一个datasource是好用的 --------------------编程问答-------------------- 你的META-INF下的两个xml文件,能贴出来看看否 --------------------编程问答--------------------
引用 3 楼 MrsFeng 的回复:
你的META-INF下的两个xml文件,能贴出来看看否

我本地这个文件夹下没有文件,另外我不是服务器管理员,看不到。 --------------------编程问答-------------------- weblogic最恶心的是自己提供了很多开源jar,它优先加载的是自己的jar,回到导致各种冲突不过这个是可以更改的。我以前在weblogic下部署也是出现了很多问题,不过现在让我搭一套环境只须10分钟。。。。。。。。。。。。 --------------------编程问答--------------------
引用 5 楼 MrsFeng 的回复:
weblogic最恶心的是自己提供了很多开源jar,它优先加载的是自己的jar,回到导致各种冲突不过这个是可以更改的。我以前在weblogic下部署也是出现了很多问题,不过现在让我搭一套环境只须10分钟。。。。。。。。。。。。


是不是因为weblogic没有加载jt400.jar这个包?导致找不到com.ibm.as400.access.AS400JDBCDriver --------------------编程问答--------------------
引用 6 楼 zgld 的回复:
Quote: 引用 5 楼 MrsFeng 的回复:

weblogic最恶心的是自己提供了很多开源jar,它优先加载的是自己的jar,回到导致各种冲突不过这个是可以更改的。我以前在weblogic下部署也是出现了很多问题,不过现在让我搭一套环境只须10分钟。。。。。。。。。。。。


是不是因为weblogic没有加载jt400.jar这个包?导致找不到com.ibm.as400.access.AS400JDBCDriver
但是你这个报错并非noclassfound神马的,很男断定 --------------------编程问答-------------------- 这是报空指针错误的那个类源码
package net.sourceforge.jdbclogger.spring;
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
 
import javax.sql.DataSource;
 
import net.sourceforge.jdbclogger.core.config.JdbcLoggerConstants;
 
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanPostProcessor;
 
/**
 * @author Catalin Kormos (latest modification by $Author: catalean $)
 * @version $Revision: 131 $ $Date: 2007-09-29 21:52:01 +0800 (????, 2007-09-29) $
 */
public class JdbcLoggerBeanPostProcessor implements BeanPostProcessor, InitializingBean {
 
    private static Log log = LogFactory.getLog(JdbcLoggerBeanPostProcessor.class);
     
    private List dataSourceConfigurations; //JdbcLoggerDataSourceConfiguration instances
    private List targetDriverClassNames;
    private boolean enabled = true; 
     
    /**
     * Constructor.
     */
    public JdbcLoggerBeanPostProcessor() {
        dataSourceConfigurations = new ArrayList();
        targetDriverClassNames   = new ArrayList();
    }
     
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        JdbcLoggerDataSourceConfiguration dataSourceConfiguration = getDataSourceConfiguration(beanName);
         
        if (!isEnabled()) {
            log.info("Configuring data source ["+beanName+"] skipped, disabled by configuration.");
            return bean;
        }
             
        if (bean instanceof DataSource) {
            replaceDataSourceDriverClassName((DataSource)bean, beanName, dataSourceConfiguration.getDriverClassNamePropertyName());
        }
        else log.warn("Configured data source bean ["+beanName+"] is not a javax.sql.DataSource instance, ignored.");
         
        return bean;
    }
     
    public void afterPropertiesSet() throws Exception {
        if (!isEnabled()) {
            log.info("Configuring target driver class names skipped, disabled by configuration.");
            return;
        }
         
        //if there were no custom data source settings registered, register the default one
        if (dataSourceConfigurations.size() == 0)
            dataSourceConfigurations.add(new JdbcLoggerDataSourceConfiguration());
         
         
        if (getTargetDriverClassNames().size() == 1) {
            String aTargetDriverClassName = (String)getTargetDriverClassNames().get(0);
            System.setProperty(JdbcLoggerConstants.USER_DRIVER_PROPERTY_NAME, aTargetDriverClassName);
        }
        else if (getTargetDriverClassNames().size() > 1) {
            int index = 0;
             
            Iterator it = getTargetDriverClassNames().listIterator();
            while (it.hasNext()) {
                String aTargetDriverClassName = (String)it.next();
                 
                //set din target driver class into the system's properties
                String propertyName = JdbcLoggerConstants.USER_DRIVER_PROPERTY_NAME + "_"+String.valueOf(index);
                System.setProperty(propertyName, aTargetDriverClassName);
                 
                index += 1;
            }
        }
    }
     
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }
     
    /**
     * This method replace the driver class name of the given data source instance, via reflection. 
     * 
     * @param dataSource
     * @param dataSourceBeanName
     * @param driverClassNamePropertyName
     */
    protected void replaceDataSourceDriverClassName(DataSource dataSource, String dataSourceBeanName, String driverClassNamePropertyName) {
        try {
            BeanUtils.setProperty(dataSource, driverClassNamePropertyName, "net.sourceforge.jdbclogger.JdbcLoggerDriver");
            log.info("Driver class name successfuly replaced for data source ["+dataSourceBeanName+"]");
        } 
        catch (IllegalAccessException exc) {
            log.error("Could not replace target data source driver class name", exc);
        } 
        catch (InvocationTargetException exc) {
            log.error("Could not replace target data source driver class name", exc);
        }
    }
     
    /**
     * @param dataSourceBeanName
     * @return
     */
    private JdbcLoggerDataSourceConfiguration getDataSourceConfiguration(String dataSourceBeanName) {
        Iterator it = getDataSourceConfigurations().listIterator();
        while (it.hasNext()) {
            JdbcLoggerDataSourceConfiguration aConfiguration = (JdbcLoggerDataSourceConfiguration)it.next();
            if (dataSourceBeanName.equals(aConfiguration.getDataSourceBeanName()))
                return aConfiguration;
        }
         
        return null;
    }
     
    /**
     * @return the dataSourceConfigurations
     */
    public List getDataSourceConfigurations() {
        return dataSourceConfigurations;
    }
 
    /**
     * @param dataSourceConfigurations the dataSourceConfigurations to set
     */
    public void setDataSourceConfigurations(List dataSourceConfigurations) {
        this.dataSourceConfigurations = dataSourceConfigurations;
    }
 
    /**
     * @return the targetDriverClassNames
     */
    public List getTargetDriverClassNames() {
        return targetDriverClassNames;
    }
 
    /**
     * @param targetDriverClassNames the targetDriverClassNames to set
     */
    public void setTargetDriverClassNames(List targetDriverClassNames) {
        this.targetDriverClassNames = targetDriverClassNames;
    }
 
    /**
     * @return the enabled
     */
    public boolean isEnabled() {
        return enabled;
    }
 
    /**
     * @param enabled the enabled to set
     */
    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }
}
--------------------编程问答-------------------- 63行那里,不知道是取不到BEAN,还是取到BEAN了,找不到beanName --------------------编程问答-------------------- 顶顶。。。。。。。。。 --------------------编程问答-------------------- 帮顶顶。。。。。。。。。这东西找你组长帮弄下 --------------------编程问答-------------------- 你查看下  你的配置文件是不是有注释   

加载spring的配置文件的时候,在配置文件中有注释的存在,这回影响weblogic读取配置文件,从而导致weblogic不能正常的加载web应用,导致失败 --------------------编程问答--------------------
引用 12 楼 lvpeng251314 的回复:
你查看下  你的配置文件是不是有注释   

加载spring的配置文件的时候,在配置文件中有注释的存在,这回影响weblogic读取配置文件,从而导致weblogic不能正常的加载web应用,导致失败


有可能,如果是你的数据源不是全局的话,建议看看局部配置有没有对上,之前我配置xml的时候也出现注释导致不行,你可以把注释都去掉看看 --------------------编程问答--------------------
引用 13 楼 shadowsick 的回复:
Quote: 引用 12 楼 lvpeng251314 的回复:

你查看下  你的配置文件是不是有注释   

加载spring的配置文件的时候,在配置文件中有注释的存在,这回影响weblogic读取配置文件,从而导致weblogic不能正常的加载web应用,导致失败


有可能,如果是你的数据源不是全局的话,建议看看局部配置有没有对上,之前我配置xml的时候也出现注释导致不行,你可以把注释都去掉看看

如果把出问题的datasource注释掉,发布是没有问题的
补充:Java ,  Web 开发
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,