0

好吧,我的应用程序包含 100 多个类文件。整个应用程序工作正常,没有被混淆,但是在使用ProGuard混淆应用程序后,我得到了一个奇怪的异常:

JRException: Error retrieving field value from bean : ID
        at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.toJasperPrin
t(JasperReportBuilder.java:319)
        at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.show(JasperR
eportBuilder.java:332)
        at ims.d.aA.done(Unknown Source)
        at javax.swing.SwingWorker$5.run(Unknown Source)
        at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.run(Unknown Sour
ce)
        at sun.swing.AccumulativeRunnable.run(Unknown Source)
        at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.actionPerformed(
Unknown Source)
        at javax.swing.Timer.fireActionPerformed(Unknown Source)
        at javax.swing.Timer$DoPostEvent.run(Unknown Source)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$000(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 Sour
ce)
        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: net.sf.jasperreports.engine.JRException: Error retrieving field value
 from bean : ID
        at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProp
erty(JRAbstractBeanDataSource.java:123)
        at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getFieldVal
ue(JRAbstractBeanDataSource.java:96)
        at net.sf.jasperreports.engine.data.JRBeanCollectionDataSource.getFieldV
alue(JRBeanCollectionDataSource.java:100)
        at net.sf.jasperreports.engine.fill.JRFillDataset.setOldValues(JRFillDat
aset.java:1330)
        at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.jav
a:1231)
        at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.jav
a:1207)
        at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:
1544)
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVertic
alFiller.java:142)
        at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:
909)
        at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:
841)
        at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:88)
        at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.
java:653)
        at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillMa
nager.java:969)
        at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.toJasperPrin
t(JasperReportBuilder.java:308)
        ... 22 more
Caused by: java.lang.NoSuchMethodException: Unknown property 'ID' on class 'clas
s ims.Reports.Item'
        at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(Prop
ertyUtilsBean.java:1313)
        at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(Prop
ertyUtilsBean.java:762)
        at org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUt
ilsBean.java:837)
        at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.
java:426)
        at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProp
erty(JRAbstractBeanDataSource.java:111)

下面是被指出的 bean 类:

public class Item {

    private String id;
    private double quantity;
    private double unitprice;
    private String uom;
    private String iname = null;

    public String getID() {
        try {
            String query = "select name from master where company_code='" + ims.MainWindow.cc + "' and inid='" + this.id + "'";
            // System.out.println(query);
            Connection con = CPool.getConnection();
            Statement st = con.createStatement();
            ResultSet rs = st.executeQuery(query);
            while (rs.next()) {
                iname = rs.getString(1);
            }
            CPool.closeResultSet(rs);
            CPool.closeConnection(con);
            CPool.closeStatement(st);
        } catch (Exception x) {

        }
        return iname;
    }

    public void setID(String ID) {
        this.id = ID;
    }

    public double getQuantity() {
        return quantity;
    }

    public void setQuantity(double quantity) {
        this.quantity = quantity;
    }

    public double getUnitprice() {
        return unitprice;
    }

    public void setUnitprice(double unitprice) {


        this.unitprice = unitprice;
    }

    public String getUOM() {
        return uom;

    }

    public void setUOM(String u) {
        this.uom = u;
    }
}

我已经尝试保留相关类的名称、方法,并试图防止它们缩小。

我可以使用哪些其他开源混淆器替代品?

4

1 回答 1

3

我已经很长时间没有使用 jasper 报告了,但看起来它正在使用java beans 约定来获取数据。如果您混淆了您的 java bean,将不再可能通过构建名称 getID() 来找到属性 ID 的 getter。

我建议从混淆中排除这些类。

于 2013-03-20T06:33:25.430 回答