有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

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

我会先说“我不知道我在用java做什么”,更不用说ehcache了,但我正在努力学习

也就是说,在添加ehcache之前,我编写的代码运行良好。我只是简单地写文件和读文件,工作很好,但速度很慢,所以我试图通过使用缓存来加快速度

当我运行我的程序时,我得到以下错误,我不明白它告诉我什么是错误的:

Exception in thread "Connect thread - [6, 5]." java.lang.NoClassDefFoundError: org.ehcache.CacheManagerBuilder at com.ibm.tpf.internal.ZSTATEngine.doFilter(ZSTATEngine.java:24) at com.ibm.tpf.etos.filter.FilterFramework.filterMessage(FilterFramework.java:229) at com.ibm.tpf.etos.api.APIFramework.addMessage(APIFramework.java:304) at com.ibm.tpf.etos.comm.ETOSConnection.addMessage(ETOSConnection.java:765) at com.ibm.tpf.etos.comm.ETOSModel._connect(ETOSModel.java:528) at com.ibm.tpf.etos.comm.ETOSModel$ConnectThread.run(ETOSModel.java:706)

Caused by: java.lang.NoClassDefFoundError: org.ehcache.CacheMangerBuilder at java.net.URLClassLoader.findClass(URLClassLoader.java:496) at java.lang.ClassLoader.loadClass(ClassLoader.java:631) at java.lang.ClassLoader.loadClass(ClassLoader.java:597) ... 6 more

我试图模仿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("{path omitted}\\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) 个答案