例外:java.lang.NoClassDefFoundError:org.ehcache.CacheMangerBuilder

时间:2015-09-22 19:37:34

标签: java exception ehcache

我先说“#34;我不知道我在做什么"使用java,更不用说ehcache,但我正在努力学习。

那就是说,我已经写好了这段代码,直到我添加了ehcache的东西。我只是简单地写文件并从文件中读取,这些文件工作得很好但很慢,所以我试图通过使用缓存来加快速度。

当我运行我的程序时,我收到以下错误,而且我不明白它告诉我的错误:

  

线程中的异常"连接线程 - [6,5]。"   java.lang.NoClassDefFoundError:org.ehcache.CacheManagerBuilder     在com.ibm.tpf.internal.ZSTATEngine.doFilter(ZSTATEngine.java:24)     在com.ibm.tpf.etos.filter.FilterFramework.filterMessage(FilterFramework.java:229)     在com.ibm.tpf.etos.api.APIFramework.addMessage(APIFramework.java:304)     在com.ibm.tpf.etos.comm.ETOSConnection.addMessage(ETOSConnection.java:765)     在com.ibm.tpf.etos.comm.ETOSModel._connect(ETOSModel.java:528)     在com.ibm.tpf.etos.comm.ETOSModel $ ConnectThread.run(ETOSModel.java:706)

     

引起:java.lang.NoClassDefFoundError:   org.ehcache.CacheMangerBuilder     at java.net.URLClassLoader.findClass(URLClassLoader.java:496)     在java.lang.ClassLoader.loadClass(ClassLoader.java:631)     at java.lang.ClassLoader.loadClass(ClassLoader.java:597)     ......还有6个

我试图模仿ehcache 3.0文档页面上的缓存代码......但我必须做一些可怕的错误。有人介意看看吗?

package com.ibm.tpf.internal;

import java.awt.Color;
import java.io.File;
import org.ehcache.*;
import org.ehcache.config.CacheConfigurationBuilder;

import com.ibm.tpf.etos.TPFFilter.*;
import com.ibm.tpf.etos.api.*;
import com.ibm.tpf.etos.filter.*;

public class ZSTATEngine implements ETOSFilterEngine {
    FilterFramework fw = null;
    String[] names = null;

    public ZSTATEngine(FilterFramework filFW, String[] parms) {
        super();
        this.fw = filFW;
    }

    public MessageBlock doFilter(MessageBlock msgBlock) throws FilterRuntimeException  {
        File file = new File("D:\\EASRVCS\\DATA\\FILTER_ENGINE\\FILTER.DAT");
        CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder().withCache("csmpCache",CacheConfigurationBuilder.newCacheConfigurationBuilder().buildConfig(Long.class, String.class)).build(false);
        cacheManager.init(); 
        Cache<Long, String> csmpCache = cacheManager.getCache("csmpCache", Long.class, String.class);
        if(msgBlock.getMsgID().equals("CSMP0097I")) {
            csmpCache.put(1L, msgBlock.getMsg()); /* 1L is a key */
            msgBlock.setSuppressed(TernarySwitch.ON);
        }
        else {
            if(msgBlock.getFlag() == Constants.ETOS_ONE_MSG || msgBlock.getFlag() == Constants.ETOS_START_MSG) {
                if(file.exists() && file.isFile()) {
                    String csmpValue = csmpCache.get(1L);
                    MessageBlock mbCSMP = new MessageBlock(csmpValue, Constants.ETOS_ONE_MSG);
                    mbCSMP.setForeground(Color.BLUE);
                    msgBlock.setForeground(Color.BLUE);
                    fw.addFilteredMessage(mbCSMP);
                }   
            }           
        }
        cacheManager.close();
        return msgBlock;                                             /* whatever gets returned is what the system prints */
    }

    private Color ColorStringInterpreter(String colorMsg) throws FilterRuntimeException {
        if (colorMsg.toUpperCase().startsWith("TOS")) {              /* if it starts with TOS, then we're using color names */
            String[] colorParts = colorMsg.split("_",2);
            String colorTxt     = colorParts[1].toString().trim();
            if (colorTxt.toUpperCase() != "NONE") {
                Color finalColor = Colors.fromString(colorTxt);
                return finalColor;
            }
        }
        else {
            String[] colorParts = colorMsg.split("_",3);            /* otherwise we're using RGB values */
            String sRed = colorParts[0].toString().trim();
            String sGreen = colorParts[1].toString().trim();
            String sBlue = colorParts[2].toString().trim();
            int iRed = Integer.parseInt(sRed);
            int iGreen = Integer.parseInt(sGreen);
            int iBlue = Integer.parseInt(sBlue);
            Color finalColor = new Color (iRed, iGreen, iBlue);
            return finalColor;
        }
        return null;
    }

    public String getName() {
        return null;
    }

    public void modifyState(Object[] newParams) throws FilterConfigurationException, FilterRuntimeException {
    }

    public boolean isActive() {
        return false;
    }

    public void shutdown() {
    }
}

感谢您的时间

0 个答案:

没有答案