NullPointerException in Jasper Reports? - jasper-reports

When I export a report using jasper report (version 1.2.4), it throws NPE. And I cant find any solution to the problem online. Can anyone help me in this regard please?
If I remove one problematic column in my report and export it, it exports fine. Couldn't find whats the problem with that column as it contains large data.
Many Thanks in Advance !
Posting the exception below :
java.lang.NullPointerException|
at java.awt.font.TextLayout.getBaselineFromGraphic(Unknown Source)|
at java.awt.font.TextMeasurer.initAll(Unknown Source)|
at java.awt.font.TextMeasurer.<init>(Unknown Source)|
at java.awt.font.LineBreakMeasurer.<init>(Unknown Source)|
at java.awt.font.LineBreakMeasurer.<init>(Unknown Source)|
at net.sf.jasperreports.engine.fill.TextMeasurer.renderParagraph(TextMeasurer.java:259)|
at net.sf.jasperreports.engine.fill.TextMeasurer.measure(TextMeasurer.java:220)|
at net.sf.jasperreports.engine.fill.JRFillTextElement.chopTextElement(JRFillTextElement.java:528)|
at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:501)|
at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:345)|
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:311)|
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:275)|
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:1291)|
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:631)|
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportContent(JRVerticalFiller.java:248)|
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:132)|
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:750)|
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:666)|
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89)|
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601)

You can get the exact same error using pure JRE code, like this:
#Test
public void testText()
{
String text = "\uFFFF\u0300";
JTextArea textArea = new JTextArea(text);
JOptionPane.showMessageDialog(null, textArea);
}
Because of this, I have been assuming it's a JRE bug and already submitted it to Oracle. The workaround is presumably to cull whatever character sequence is causing it, but I obviously don't know what you are feeding in.

This is likely either (1) a bug in the version of the JRE you're using, or (2) a threading bug. We've had the same top five lines in stack traces in a project I work on.

Related

error.CannotStartupOSGIPlatform issue when running birt

I'm in the midst of implementing Birt 4.6.0 into my gwt application. Unfortunately whenever I run a specific section of the program, I get the following error:
org.eclipse.birt.core.exception.BirtException:
error.CannotStartupOSGIPlatform at
org.eclipse.birt.core.framework.Platform.startup(Platform.java:81)
I've done some searching and one thread mentioned a permissions error but I am not sure what that entails. What does this mean?
EDIT Just read another article that suggests that it may be an issue with my classpath but I already added all the jar files from ReportEngine/lib to my buildpath. Anyone know what jar files I am supposed to include?
the offending code:
public static synchronized IReportEngine getBirtEngine(ServletContext sc) {
if (birtEngine == null) {
EngineConfig config = new EngineConfig();
java.util.HashMap map = config.getAppContext();;
map.put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY, SegnalazioniDbManager.class.getClassLoader());
config.setAppContext(map);
IPlatformContext context = new PlatformServletContext(sc);
config.setPlatformContext(context);
try {
Platform.startup(config); //problem begins here
.....
}
[1]: http://developer.actuate.com/community/forum/index.php?/topic/20933-errorcannotstartuposgiplatform/
Yes it is indeed a permission error.
The relevant file is:
WEB-INF/platform/configuration/org.eclipse.osgi/.manager/.fileTableLock
You need to give access to the Birt user.

getStructureId returns the real ID minus 1?

this is the code I am using :
JournalArticle article = null;
article = JournalArticleLocalServiceUtil.getLatestArticle(classPk);
String structureId = article.getStructureId();
When I debugged I found that structureId is always the real structureId but minus 1 !!!
Why ?? I need to know if it's Liferay bug ...
thank you,
I am Liferay 6.2 ce ga2.
JournalArticle's field structureId is equivalent not to DDMStructure.structureId, but to DDMStructure.structureKey. I admit, that can be really confusing.
This is due to the DDMStructure's object generation mechanism. When you add new structure using Control Panel, the structureKey is generated automatically using counterLocalService (check this code). As it happens just before the structureId is generated, it is always smaller by one.
See following Jira tickets, where it is explained the structureId vs structureKey issue:
- https://issues.liferay.com/browse/LPS-50671
- https://issues.liferay.com/browse/LPS-31163

GetExportedValues<MyType> returns nothing, I can see the parts

I have a strange MEF problem, I tested this in a test project and it all seems to work pretty well but for some reason not working in the real project
This is the exporting code
public void RegisterComponents()
{
_registrationBuilder = new RegistrationBuilder();
_registrationBuilder
.ForTypesDerivedFrom(typeof(MyType))
.SetCreationPolicy(CreationPolicy.NonShared)
.Export();
var catalog = new AggregateCatalog();
catalog.Catalogs.Add(new AssemblyCatalog(typeof(MyType).Assembly, _registrationBuilder));
var directoryCatalog = new DirectoryCatalog(PathToMyTypeDerived, _registrationBuilder);
catalog.Catalogs.Add(directoryCatalog);
_compositionContainer = new CompositionContainer(catalog);
_compositionContainer.ComposeParts();
var exports = _compositionContainer.GetExportedValues<MyType>();
Console.WriteLine("{0} exports in AppDomain {1}", exports.Count(), AppDomain.CurrentDomain.FriendlyName);
}
exports count is 0 :( Any ideas why?
IN the log file I have many of this
System.ComponentModel.Composition Information: 6 : The ComposablePartDefinition 'SomeOthertype' was ignored because it contains no exports.
Though I would think this is ok because I wasn' interested in exporting 'someOtherType'
UPDATE: I found this link but after debuging over it I am not wiser but maybe I m not following up properly.
Thanks for any pointers
Cheers
I just had the same problem and this article helped me a lot.
It describes different reasons why a resolve can fail. One of the more important ones is that the dependency of a dependency of the type you want to resolve is not registered.
What helped me a lot was the the trace output that gets written to the Output window when you debug your application. It describes exactly the reasons why a type couldn't be resolved.
Even with this output. you might need to dig a little bit, because I only got one level deep.
Example:
I wanted to resolve type A and I got a message like this:
System.ComponentModel.Composition Warning: 1 : The ComposablePartDefinition 'Namespace.A' has been rejected. The composition remains unchanged. The changes were rejected because of the following error(s): The composition produced multiple composition errors, with 1 root causes. The root causes are provided below. Review the CompositionException.Errors property for more detailed information.
1) No exports were found that match the constraint:
ContractName Namespace.IB
RequiredTypeIdentity Namespace.IB
Resulting in: Cannot set import 'Namespace.A..ctor (Parameter="b", ContractName="namespace.IB")' on part 'Namespace A'.
Element: Namespace.A..ctor (Parameter="b", ContractName="Namespace.IB") --> Namespace.A --> AssemblyCatalog (Assembly="assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=...")
But I clearly saw a part for Namespace.IB. So, in the debugger, I tried to resolve that one. And I got another trace output. This time it told me that my implementation of Namespace.IB couldn't be resolved because for one of its imports there was a missing export, so basically the same message as above, just with different types. And this time, I didn't find a part for that missing import. Now I knew, which type was the real problem and figure out, why no registration happened for it.

Enterprise Library Logging tracelistener extension issue with resolving ILogFormatter

I have been sitting with a problem for quite a while now and I just can't seem to find what I'm missing.
I have written a custom trace listener component for Enterprise Library 5.0 for the Logging application block which works but the configured ILogFormatter just won't resolve and so I always end up with the basic string text when it gets handled by my component.
I saw in the enterprise library source code that they use the "Container.ResolvedIfNotNull()" method. It doesn't seem to work for me. I need it to write out a custom formatted string for my component to use. You know, not just the message but the timestamp, machinename, threadId, etc.
Does anyone have any ideas on how to fix this?
Thanks in advance.
Like I've mentioned on this site: http://entlib.codeplex.com/discussions/261749
When you create your CreationExpression in the TraceListener data class make sure you have a flat constructor definition. To put it in other words, don't return:
() => new MyTraceListener(new TraceListenerConfig(..., Container.ResolvedIfNotNull<ILogFormatter>(), ...));
just have it in the constructor of the MyTraceListener:
() => new MyTraceListener(..., Container.ResolvedIfNotNull<ILogFormatter>(), ...);

How do you detect and print the current drilldown in the CrystalReportViewer control?

When using Business Objects' CrystalReportViewer control, how can you detect and manually print the report the user has currently drilled into? You can print this automatically using the Print() method of the CrystalReportViewer, but I want to be able to do a manual printing of this report.
It is possible to print the main ReportSource of the CrystalReportViewer, but I need to know what report the user has drilled into and then do a manual printing of that particular drill down. Any ideas?
I'm not sure which version of Crystal Reports you are using, but if it is XIR2 or earlier then this isn't possible. I haven't used the newer versions so I can't tell you. One thing that I've done to solve this in the past was to have the drill actually link to another report altogether. It depends on how your viewers actually view the reports (either via a thick-client viewer, the developer, or the web portal) on whether this will work however. Good luck!
detect: yes!
webpage:
<CR:CrystalReportViewer ...
ondrill="CrystalReportViewer1_Drill"
ondrilldownsubreport="CrystalReportViewer1_DrillDownSubreport" />
code behind:
protected void CrystalReportViewer1_Drill(object source, CrystalDecisions.Web.DrillEventArgs e)
{
//drill from graph to list of elements
}
protected void CrystalReportViewer1_DrillDownSubreport(object source, CrystalDecisions.Web.DrillSubreportEventArgs e)
{
//drill from main report to subreports
}
print current: no!
protected void CrystalReportViewer1_DrillDownSubreport(object source, CrystalDecisions.Web.DrillSubreportEventArgs e)
{
reportDocument.OpenSubreport(e.NewSubreportName).ExportToHttpResponse(format, Response, true, title);
}
exporting subreports throws an exception "not allowed for subreports".
solution
CrystalReportsViewer's button works also on drilldown...
<CR:CrystalReportViewer HasExportButton="true" ....