Uncategorized

Regex to remove DOCTYPE prolog

While using HTML Tidy I needed to remove the DOCTYPE prolog to prevent ‘org.xml.sax.SAXParseException: Already seen doctype.’ exception. Regex is quite simple, only catch is that we need to make sure we include the \n\r in our selecton and make it not greedy. convertedData = convertedData.replaceAll("<!DOCTYPE((.|\n|\r)*?)\">", ""); convertedData = convertedData.replaceAll("<!DOCTYPE((.|\n|\r)*?)\">", ""); This will consume multiline …

Regex to remove DOCTYPE prolog Read More »

Fixing JasperReports net.sf.jasperreports.engine.JRRuntimeException: Error creating SAX parser

While upgrading machines I have upgraded to run jdk 1.6 which have screwed up compiling of my reports with following error. C:\Program Files (x86)\Java\jdk1.6.0_24\jre\lib\endorsed Source File:c:/Users/greg/report2.jrxml Exception in thread "main" net.sf.jasperreports.engine.JRRuntimeException: Error creating SAX parser at net.sf.jasperreports.engine.xml.JRReportSaxParserFactory.createParser(JRReportSaxParserFactory.java:109) at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createParser(JRXmlDigesterFactory.java:1320) at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createDigester(JRXmlDigesterFactory.java:1295) at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:199) at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:164) at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:148) at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:85) at com.americanbanksystems.complianceproreports.util.CompileReport.compileReport(CompileReport.java:133) at com.americanbanksystems.complianceproreports.util.CompileReport.main(CompileReport.java:189) Caused by: …

Fixing JasperReports net.sf.jasperreports.engine.JRRuntimeException: Error creating SAX parser Read More »

Detaching managed entity from entitymanager.

This code will detach a entity from hibernate Entitymanger making it thus unmanaged entity. // Prepare workbook object to be used for cloning. Session session = (Session) entityManager.getDelegate(); session.evict(workbook); // same as detached workbook.setId(null);// Prepare workbook object to be used for cloning. Session session = (Session) entityManager.getDelegate(); session.evict(workbook); // same as detached workbook.setId(null);