简体   繁体   English

java.lang.NoClassDefFoundError:org / apache / commons / collections / ReferenceMap

[英]java.lang.NoClassDefFoundError: org/apache/commons/collections/ReferenceMap

Really newbie in java, Spanish-speaker, so, ill do my best for you to understand me :). 真的是新手java,西班牙语,所以,生病尽力让你了解我:)。 I made a program which manages a mysql database for storing clientes, information about clients, etc. And generates (or trying too...) reports. 我制作了一个程序,管理一个mysql数据库,用于存储客户,客户信息等。并生成(或尝试...)报告。 I installed JasperReports from Eclipse Market (BTW, using Eclipse Kepler). 我从Eclipse Market安装了JasperReports(BTW,使用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.");
                }

                }
            }
        )

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. 尽管有变量的西班牙名称,但是捕获由用户键入的变量,连接到数据库,通过其“dni”检查这样的用户是否存在,如果存在,则生成报告,否则,消息错误。 When i executed it first time, apache.commons.logging not found appeared, wich i solved importing apache commons libraries. 当我第一次执行它时,找不到apache.commons.logging,我解决了导入apache commons库的问题。 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! 我说:简单的蛋糕,下载的apache commons集合,进口的罐子......就是这样! 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... 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. ... sooooo ...我仔细检查了库是没问题,它在那里,但由于某种原因,它看起来像eclipse或java,或某种外星人,没有找到它..无论如何,我做了研究遍布互联网,发现这个错误,主要通过导入公共收集来解决...不是我的情况。 Eclipse kepler, java 7, and apache commons 4.0. Eclipse kepler,java 7和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 非常感谢您花时间阅读它,对不起我的英语并等待一些亮点......:D

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). 我只是不得不将集合降级到3.2.1,这很有效..部分,因为我一直有其他类的错误(joda-time,commons-digester和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!! 非常感谢您的帮助!! :) :)

The better trick is to get the classes that are mentioned as missing. 更好的技巧是让提到的类失踪。 In here the missing class is org/apache/commons/collections/ReferenceMap 在这里,缺少的类是org/apache/commons/collections/ReferenceMap

Then google for the jar file and download the newest stable verion and check if the jar file contains the missing class. 然后谷歌获取jar文件并下载最新的稳定版本并检查jar文件是否包含缺少的类。 Once you find the correct jar file, add it to the project. 找到正确的jar文件后,将其添加到项目中。

I downloaded a different .jar file for common collection and it resolved the issue. 我下载了一个不同的.jar文件进行常见收集,它解决了这个问题。 You can download it here : http://www.java2s.com/Code/Jar/o/Downloadorgapachecommonscollectionsjar.htm 你可以在这里下载: http//www.java2s.com/Code/Jar/o/Downloadorgapachecommonscollectionsjar.htm

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.NoClassDefFoundError: org/apache/commons/collections/map/LRUMap - java.lang.NoClassDefFoundError: org/apache/commons/collections/map/LRUMap 休眠java.lang.NoClassDefFoundError:org / apache / commons / collections / MultiMap - Hibernate java.lang.NoClassDefFoundError: org/apache/commons/collections/MultiMap java.lang.NoClassDefFoundError: org/apache/commons/collections/Transformer - java.lang.NoClassDefFoundError: org/apache/commons/collections/Transformer java.lang.NoClassDefFoundError:org / apache / commons / lang / text / StrLookup - java.lang.NoClassDefFoundError: org/apache/commons/lang/text/StrLookup java.lang.NoClassDefFoundError: org/apache/commons/lang/builder/CompareToBuilder - java.lang.NoClassDefFoundError: org/apache/commons/lang/builder/CompareToBuilder java.lang.NoClassDefFoundError:org.apache.commons.lang3.ArrayUtils - java.lang.NoClassDefFoundError: org.apache.commons.lang3.ArrayUtils java.lang.NoClassDefFoundError:org / apache / commons / lang3 / ObjectUtils - java.lang.NoClassDefFoundError: org/apache/commons/lang3/ObjectUtils 错误:java.lang.NoClassDefFoundError:org / apache / commons / collections / map / LRUMap - Error : java.lang.NoClassDefFoundError: org/apache/commons/collections/map/LRUMap java.lang.NoClassDefFoundError:org / apache / commons / lang / Validate - java.lang.NoClassDefFoundError: org/apache/commons/lang/Validate java.lang.NoClassDefFoundError:Lorg / apache / commons / collections / FastHashMap; - java.lang.NoClassDefFoundError: Lorg/apache/commons/collections/FastHashMap;
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM