LINQ Java not work

Hi,


Our system is using Aspose for mail merge before and now I want try LINQ. I try to build report using the ReportingEngine as the hello world shows but it throws an “NoClassDefError” for “asposewobfuscated.zzWJ” class

Then I create a individual hello world and it fails too. The exception is as below, could you pls help me with that?

Exception in thread "main" java.lang.ExceptionInInitializerError

at asposewobfuscated.zzWK.zzX(Unknown Source)

at asposewobfuscated.zzWH.zzQ(Unknown Source)

at asposewobfuscated.zzWH.zzZ(Unknown Source)

at asposewobfuscated.zzWH.zzY(Unknown Source)

at asposewobfuscated.zzWH.zzZ(Unknown Source)

at asposewobfuscated.zzO6.zzY(Unknown Source)

at asposewobfuscated.zzY5.zzZ(Unknown Source)

at asposewobfuscated.zzY5.zzXv(Unknown Source)

at asposewobfuscated.zzY5.zzXw(Unknown Source)

at asposewobfuscated.zzY5.zzXx(Unknown Source)

at asposewobfuscated.zzY5.zzXy(Unknown Source)

at asposewobfuscated.zzY5.zzXz(Unknown Source)

at asposewobfuscated.zzY5.zzXA(Unknown Source)

at asposewobfuscated.zzY5.zzXB(Unknown Source)

at asposewobfuscated.zzY5.zzXC(Unknown Source)

at asposewobfuscated.zzY5.zzXD(Unknown Source)

at asposewobfuscated.zzY5.zzXE(Unknown Source)

at asposewobfuscated.zzY5.zzXF(Unknown Source)

at asposewobfuscated.zzY5.zzXG(Unknown Source)

at asposewobfuscated.zzY5.zzXH(Unknown Source)

at asposewobfuscated.zzY5.zzXI(Unknown Source)

at asposewobfuscated.zzY5.zzXL(Unknown Source)

at asposewobfuscated.zzTN.zzZ(Unknown Source)

at asposewobfuscated.zzN6.zzKw(Unknown Source)

at asposewobfuscated.zzX5.zzW6(Unknown Source)

at asposewobfuscated.zzX5.parseTag(Unknown Source)

at asposewobfuscated.zzX5.zzW7(Unknown Source)

at asposewobfuscated.zzN6.zzZ(Unknown Source)

at asposewobfuscated.zzH1.zzZ(Unknown Source)

at asposewobfuscated.zzH1.zzZ(Unknown Source)

at com.aspose.words.ReportingEngine.buildReport(Unknown Source)

at main.main(main.java:9)

Caused by: java.lang.IllegalStateException

at asposewobfuscated.zzWJ.zzY(Unknown Source)

at asposewobfuscated.zzWJ.(Unknown Source)

... 32 more

any feebacks?

Hi Kin,


Thanks for your inquiry. Please try using the following sample code:
DocumentBuilder builder = new DocumentBuilder();
builder.write(“The items are: <<foreach [item in items]>><<[item]>>, <>and others.”);
Document doc = builder.getDocument();

ArrayList arrList = new ArrayList();
arrList.add(“Item1”);
arrList.add(“Item2”);
arrList.add(“Item3”);

ReportingEngine engine = new ReportingEngine();
engine.buildReport(doc, arrList, “items”);

doc.save(getMyDir() + “out.docx”);

I hope, this helps.

Best regards,

After replace the jar with the latest one, the problem is solved. But I meet another issue.


I read Working with Types in Java|Aspose.Words for Java and Accessing Type Members in Java|Aspose.Words for Java

But I found I can’t access method in my public java class in the foreach loop. It always throws an exception that no such method for “java.lang.Object”. Until I specify type in the “foreach” and cast the type in orderBy directly. It works. But It’s still not working for the group by.

<<foreach [usage in usages]>><<[ usage.getSubscriptionNumber()]>> not work
<<foreach [UsageClass usage in usages]>><<[ usage.getSubscriptionNumber()]>> works

<<foreach [UsageClass usage in usages.orderBy(p=>p.getQuantity())]>><<[ usage.getSubscriptionNumber()]>> not works
<<foreach [UsageClass usage in usages.orderBy(p=>((UsageClass)p).getQuantity())]>><<[ usage.getSubscriptionNumber()]>> works

<<foreach [UsageClass usage in usages.groupBy(p=>p.getQuantity())]>><<[ usage.getSubscriptionNumber()]>> not works
<<foreach [UsageClass usage in usages.groupBy(p=>((UsageClass)p).getQuantity())]>><<[ usage.getSubscriptionNumber()]>> not works

Thank you awais.


It works now. Could you pls help look at another issue I posted above?

Any feedback?

Hi Kin,

Thanks for your inquiry. Please attach your input template document (containing working and not working samples) and source code you're getting this problem with here for testing. We will investigate the issue on our end and provide you more information.

Best regards,

Hi,


Please use the attachment for your further handling. My java class definition is also in the document.

Hi Kin,


Thanks for your inquiry. We are in coordination with product team to get answer pertaining to your queries. Soon you will be updated with the required information.

Best regards,

Hi Kin,


Thanks for being patient. Please note that following two points:

1. The result of a grouping operation is not an enumeration of entities of the same type, but an enumeration of grouping instances instead. Please, see notes for groupBy here: http://www.aspose.com/docs/display/wordsjava/Appendix+A.+Enumeration+Extension+Methods

2. Because of the Java Type Erasure feature, it is not always possible for the engine to obtain the type of an item from the type of an enumeration. Please, see here: http://www.aspose.com/docs/display/wordsjava/Appendix+B.+Technical+FAQ

Definitely, the engine is unable to get the type of an item implicitly, when ArrayList is used as a data source.

We have added comments to your template explaining why your expressions do not work and how to work around this. Please, check the attachment.

Hope, this helps.

Best regards,

Hi Awais,


Thank your for your support and I’ve made most of my previous template work. But I have another issue when using the sum operation, group.sum(p=>p.getQuantity().toDouble()), there throws a exception. I’ve uploaded the template, could you plz help take a look?

Thank you!
Hi Kin,

Thanks for your inquiry. We are in coordination with product team to get answer pertaining to your queries. Soon you will be updated with the required information.

Best regards,

Hi Kin,


Unfortunately, it is difficult to say what the problem is. The information provided is not enough. As far as I know, there is no built-in Decimal class in Java. There is only BigDecimal. So what is your Decimal class actually? Is it visible (see here)? To ensure a timely and accurate response, please prepare a separate usecase for this problem and attach the following resources here for testing:

  • Your input Word document containing a single template you’re getting this problem with
  • Aspose.Words generated output document which shows the undesired behavior (if any)
  • Are you getting any exceptions? Information on the exception thrown would help to get to the bottom of this problem
  • Please create a standalone simplified Java application (source code without compilation errors) that helps us reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip them and Click ‘Reply’ button that will bring you to the ‘reply page’ and there at the bottom you can include any attachments with that post by clicking the ‘Add/Update’ button.

Best regards,