本文介绍了java.lang.NoClassDefFoundError:org / apache / commons / collections / ReferenceMap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

真的是新手在java,西班牙语的,所以,不好,尽我最大的了解我:)。我创建了一个程序,它管理一个用于存储客户端的mysql数据库,有关客户端的信息等。并生成(或尝试...)报告。我从Eclipse Market安装了JasperReports(BTW,使用Eclipse Kepler)。按照一些教程,我通过参数创建了一个报告。它只是一个参数来识别一个客户端。这不是问题。问题出现在我点击我的按钮生成报告,其中包含以下代码:

Really newbie in java, Spanish-speaker, so, ill do my best for you to understand me :). I made a program which manages a mysql database for storing clientes, information about clients, etc. And generates (or trying too...) reports. I installed JasperReports from Eclipse Market (BTW, using Eclipse Kepler). Following some tutorials, i made my way into creating a report by parameters. Its just one parameter to identify one client. Thats not the problem. The problem comes when i click my button to generate the report, which contains the code below:

JButton btnOk = new JButton("OK");
    btnOk.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            String doc = jftxtDni.getText();
            String sql;
            boolean respuesta = false;
            ConexionBaseDatos cc = new ConexionBaseDatos();

            sql = "SELECT * FROM clientes WHERE DNI = '"+doc+"'";

            rs = cc.Consultar(sql);

                try
                {
                    while (rs.next())
                    {
                    respuesta = true;
                    }
                }
                catch (SQLException e)
                {
                    JOptionPane.showMessageDialog(null, "error sql: "+e.getMessage());
                }

                if (respuesta)
                {
                    ConexionBaseDatos cd = new ConexionBaseDatos();
                    Connection cn = cd.Conectar();
                    JasperReport jr = null;
                    String archivo = "src/reportes/Tree.jasper";
                    try
                    {
                        HashMap<String, Object> parametro = new HashMap<String, Object>();
                        parametro.put("dni", doc);
                        jr = (JasperReport) JRLoader.loadObjectFromFile(archivo);
                        JasperPrint jp = JasperFillManager.fillReport(jr,parametro,cn);
                        JasperViewer jv = new JasperViewer(jp);
                        jv.setVisible(true);
                        jv.setTitle("Informe de cliente");

                    }
                    catch (JRException e)
                    {
                        JOptionPane.showMessageDialog(null, "error Jasper: "+e.getMessage());;
                    }

                }
                else
                {
                    JOptionPane.showMessageDialog(null, "No existe el cliente en la base de datos, verifique.");
                }

                }
            }
        )

尽管使用了西班牙变量名称,捕获用户输入的变量,连接到数据库,通过其dni检查是否存在这样的用户,如果存在,则生成报告,否则生成消息错误。
当我第一次执行它,apache.commons.logging没有找到出现,我解决了导入apache commons库。但之后呢,这个错误是我这个话题的。我说:容易蛋糕,下载apache commons收藏品,进口罐子...就是这样!我想...但没有办法..我得到:

which despite spanish names of variables, catchs a variable typed by user, connects to database, check the existence of such a user through its "dni", if exists, generates the report, otherway, a message error. When i executed it first time, apache.commons.logging not found appeared, wich i solved importing apache commons libraries. But after that, the error was the one i titled this topic. I said: easy cake, downloaded apache commons collections, imported jars... and that is it! I thought... but no way.. i get:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/collections/ReferenceMap
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.<init>(DefaultExtensionsRegistry.java:97)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at net.sf.jasperreports.engine.util.ClassUtils.instantiateClass(ClassUtils.java:59)
at net.sf.jasperreports.extensions.ExtensionsEnvironment.createDefaultRegistry(ExtensionsEnvironment.java:82)
at net.sf.jasperreports.extensions.ExtensionsEnvironment.<clinit>(ExtensionsEnvironment.java:69)
at net.sf.jasperreports.engine.util.JRStyledTextParser.<clinit>(JRStyledTextParser.java:83)
at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:123)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:88)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:103)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:61)
at net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:179)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:81)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:446)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:849)
at formularios.ImprimirCliente$2.actionPerformed(ImprimirCliente.java:143)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.ReferenceMap
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 55 more

... sooooo ...我仔细检查了图书馆是确定,它在那里,但由于某种原因,它看起来像eclipse或java,或某种外星人,没有找到它..无论如何,我在互联网上进行了研究,发现这个错误,大多是解决通过进口公共集合...不是我的情况。 Eclipse kepler,java 7和apache commons 4.0。任何模糊的想法?非常感谢你花时间阅读,对不起我的英语,等待一些光..:D

...sooooo... i double checked the library is ok, and its there, but for some reason, it looks like eclipse or java, or some kind of alien, doesnt find it.. anyway, i did research all over the internet, and found this error, wich was mostly solved by importing commons collections... not my case. Eclipse kepler, java 7, and apache commons 4.0. Any vague idea..? Thank you very much for taking time to read it, sorry for my english and waiting for some light.. :D

推荐答案

, 问题解决了!我只需要将集合降级到3.2.1,这样做很好。部分原因是因为我对其他类(joda-time,commons-digester和javax-servlet)有错误。在某些情况下,下载最新版本没有工作,只是下载一个。所以,我的报告完美无瑕。非常感谢您的帮助!! :)

Well, problem solved! I just had to downgrade collections to 3.2.1, and that worked, well.. partially, because i kept having errors about other classes (joda-time, commons-digester and javax-servlet). And in some cases, downloading latest version didnt work, just downloading a previous one. So, my report came flawless after that. Thank you very much for your help!! :)

这篇关于java.lang.NoClassDefFoundError:org / apache / commons / collections / ReferenceMap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 00:25