-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
URL containing dbf is not supported by java.net.URL #266
Comments
Interesting! I take it you used It might be worth seeing whether you can open that URL (with If that works, it might give you a workaround: open the URL yourself and get the schema with something like Also, please try in a released version of PL/Java: 1.5.5 is the latest. The 1.6 branch is a construction zone; nothing in there is released yet. (Also, part of the construction involves the Java Platform Module System, which could be another reason the I don't recommend using 1.6.0-anything before it is released, unless you have ideas for developing PL/Java. |
Unfortunately the code which is trying to open the DTD schema using dbf url is contained in jasper reports which I'm just including into my project and therefore I'm not able to change the way how the streams are handled. |
The branch is The However, I believe the class loader returns a It is possible that somewhere in the call stack of your example, something is trying to create a new URL by copying only the string representation of the real one. That seems iffy. It will take more time to see what code is doing that and why. |
Do you have access to the XML document being parsed, or is that also buried in the depths of Jasper? It would be good to see exactly how the schema loading attempt is being triggered. |
When I executed the same code directly I found out that the url is on a specific place in jar file (specifically |
I see now, deep within Java's own XML implementation, a class that only holds the URL as a How pressing is your schedule for having this work? I may be able to work up a patch based on 1.5.5 that could temporarily serve your purpose, but I would target a more presentable fix to 1.6.0. The scheme name So until something better is chosen, I am resistant to just making that name generally registered by default. If necessary, a patch you could apply would get your application working, as a deliberate opt-in on your part. |
Here's a simpler workaround you might try: If you did That is a bit more of a fiddly setup, but then |
Thank you very much, I'll try the workaround you've suggested. If this workaround worked then there's no need to hurry - I could live with that until it is resolved generally. I'll let you know the result as soon as I test it. |
I removed jasperreports from the dependencies of my project (I use gradle to build one jar containing my code together with all dependencies). Then I set pljava.classpath using the following command: When I executed by function I received the following output:
|
Oh right, you're still using If you switch to using a released version of PL/Java (may I suggest 1.5.5? It goes very well with the salmon.) you can set If for some reason you want to keep living on the bleeding edge with 1.6.0, you will have to add |
Thank you very much, I've implemented the workaround using BTW: It would be nice to have binary distribution at least for the most widely used combinations of OS and PostgreSQL versions of PL/java, because compiling it on Windows cost me many hours and I have to have a special virtual machine just for the purpose of PL/java compilation. |
Could you describe which OSes are in your environment? There is .deb packaging for Debian and Ubuntu in the PGDG repository. Likewise, the PGDG For Windows, there are two flavors, depending on whether PostgreSQL itself was built with MSVC or with MinGW-64. At one time BigSQL had a WIndows-MinGW-64 build available, but BigSQL seems to have become something else and I am unsure of the story there. There is a Google Summer of Code project in progress that should give us continuous integration, which may better position us to offer more prebuilt binaries. I am sorry about your experience building for Windows; if you have insights about what took the most time, you could share those (maybe in a separate issue); at minimum, we might be able to improve the Windows build documentation to help something go more smoothly. I'll just reiterate about 1.6.0-SNAPSHOT that until it is released it is likely to be something different every time you look and no one can say if those somethings will work. |
Currently we use mainly Windows 2016 Standard (64bit) together with PostgreSQL 10 (64bit) downloaded from https://www.enterprisedb.com/downloads/postgres-postgresql-downloads (probably built on MSVC - I used it to compile PL/java which works with the current version of PostgreSQL which we use). I can't identify (or remember) any major difficulity in compiling, it was just complicated / time consuming to establish the same environment as on the server (PostgreSQL, Windows 64 bit) together with MSVC 64bit on another machine, especially when we are not very familiar with MSVC and its build tools. Anyway - it's good to know that this project is being developed and the community cares about users :). |
PL/Java's class loader has historically handled resource lookups by returning a URL that has a custom URLStreamHandler wired in. Permission to do that wasn't included in the pljava.policy shipped with 1.6.0. Fix that. Addresses #322. Still does not get closer to fixing #266, but at least avoids making it worse.
Class org.postgresql.pljava.sqlj.Loader creates URL containing protocol "dbf" which is not supported by java.net.URL and therefore when the URL is created by org.postgresql.pljava.sqlj.Loader opening it by java.net.URL causes exception:
java.net.MalformedURLException: unknown protocol: dbf
In my case I'm trying to compile Jasper report and the following exception occurs when run within pljava:
net.sf.jasperreports.engine.JRException: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 402; schema_reference.4: Failed to read schema document 'dbf://localhost/1057338', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>. at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:303) at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:286) at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:275) at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:220) at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:195) at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:186) at net.sf.jasperreports.engine.JasperCompileManager.compileToFile(JasperCompileManager.java:254) at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:555) at net.blahovec.framework.report.JasperReportsLib$ReportCompileTaskInternal.compile(JasperReportsLib.java:625) at net.blahovec.pg.lib.PgSysReportLib.reportLayoutJasperCompile(PgSysReportLib.java:44) at net.blahovec.pg.BlahovecNetPg.sysReportLayoutJasperCompile(BlahovecNetPg.java:111) at org.postgresql.pljava.internal@1.6.0-SNAPSHOT/org.postgresql.pljava.internal.EntryPoints.refInvoke(EntryPoints.java:53) Caused by: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 402; schema_reference.4: Failed to read schema document 'dbf://localhost/1057338', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>. at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:204) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:135) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:306) at java.xml/com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaErr(XSDHandler.java:4257) at java.xml/com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaError(XSDHandler.java:4240) at java.xml/com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument1(XSDHandler.java:2531) at java.xml/com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument(XSDHandler.java:2238) at java.xml/com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:588) at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.processJAXPSchemaSource(XMLSchemaLoader.java:844) at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:606) at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.findSchemaGrammar(XMLSchemaValidator.java:2710) at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:2069) at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:829) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:374) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:613) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3063) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:836) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:534) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:888) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:824) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1216) at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:635) at org.apache.commons.digester.Digester.parse(Digester.java:1892) at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:299) ... 11 more Caused by: java.net.MalformedURLException: unknown protocol: dbf at java.base/java.net.URL.<init>(URL.java:652) at java.base/java.net.URL.<init>(URL.java:541) at java.base/java.net.URL.<init>(URL.java:488) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:649) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:150) at java.xml/com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaParsingConfig.parse(SchemaParsingConfig.java:593) at java.xml/com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaParsingConfig.parse(SchemaParsingConfig.java:696) at java.xml/com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaDOMParser.parse(SchemaDOMParser.java:530) at java.xml/com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument(XSDHandler.java:2226) ... 31 more
The same code works without any problem when I run it directly in Java (executed from Eclipse in my case).
I'm using JDK11.0.6 but I've tried OpenJDK 11.0.7 with the same result.
The text was updated successfully, but these errors were encountered: