Skip to content
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

Using XML Pretty Printer causes SAXParser exceptions as errors in the server log under Windows #3444

Closed
rbeckman-nextgen opened this issue May 11, 2020 · 4 comments
Milestone

Comments

@rbeckman-nextgen
Copy link
Collaborator

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

Create a channel that sends an XML document to a destination. This could either be using an XML document as the outbound message template and writing out encoded data, or it could just be writing out the transformed data (making sure that you have a transformer or filter so that the transformed data actually exists).

It doesn't really matter what type of destination connector is used, but in that connector's output template, write out the XML, passing it to XMLUtil.prettyPrint(). This causes the following exceptions to be logged:

ERROR 2014-12-12 15:01:05,937 [Thread-47] Server: Warning: org.apache.xerces.parsers.SAXParser: Feature 'http://javax.xml.XMLConstants/feature/secure-processing' is not recognized.
ERROR 2014-12-12 15:01:05,937 [Thread-47] Server: Warning: org.apache.xerces.parsers.SAXParser: Property 'http://javax.xml.XMLConstants/property/accessExternalDTD' is not recognized.
ERROR 2014-12-12 15:01:05,938 [Thread-47] Server: Warning: org.apache.xerces.parsers.SAXParser: Property 'http://www.oracle.com/xml/jaxp/properties/entityExpansionLimit' is not recognized.

Although these exceptions are logged as errors, they are otherwise innocuous. The XML is still correctly output and formatted correctly, and the message has a status of "SENT". However, having these messages fill up your log files can be quite annoying (sure, one could configure log4j to suppress them, but one shouldn't have to do that).

The other thing to point out about this problem is that it seemingly only happens under Windows. I've seen this same behavior on several different computers running Windows 7, but I don't see it when I run the same channel on OS X Mavericks.

Imported Issue. Original Details:
Jira Issue Key: MIRTH-3548
Reporter: ericb
Created: 2014-12-12T15:34:13.000-0800

@rbeckman-nextgen rbeckman-nextgen added this to the 3.2.2 milestone May 11, 2020
@rbeckman-nextgen
Copy link
Collaborator Author

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

[http://www.mirthcorp.com/community/forums/showthread.php?t=9356]

Looks like it's a completely "expected" warning according to Java: [https://docs.oracle.com/javase/tutorial/jaxp/properties/error.html]

Also, this happens for me on OSX as well.

Imported Comment. Original Details:
Author: narupley
Created: 2015-03-30T13:02:45.000-0700

@rbeckman-nextgen
Copy link
Collaborator Author

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

As a workaround, you can do this:

  • Set "Clear global map on redeploy" to No in the server settings.

  • Use this in the global deploy script: `if ($('log4jFilterSet') != true) {
    for (var en = org.apache.log4j.Logger.getRootLogger().getAllAppenders(); en.hasMoreElements();) {
    en.nextElement().addFilter(new JavaAdapter(org.apache.log4j.spi.Filter, {
    decide: function(event) {
    if (event.getLevel().equals(org.apache.log4j.Level.ERROR) && event.getLoggerName().equals("Server")) {
    var msg = event.getRenderedMessage();

      			if (org.apache.commons.lang3.StringUtils.isNotBlank(msg)) {
      				if (org.apache.commons.lang3.StringUtils.equals(msg, "Compiler warnings:") || org.apache.commons.lang3.StringUtils.contains(msg, "Feature 'http://javax.xml.XMLConstants/feature/secure-processing' is not recognized.") || org.apache.commons.lang3.StringUtils.contains(msg, "Property 'http://javax.xml.XMLConstants/property/accessExternalDTD' is not recognized.") || org.apache.commons.lang3.StringUtils.contains(msg, "Property 'http://www.oracle.com/xml/jaxp/properties/entityExpansionLimit' is not recognized.")) {
      					return org.apache.log4j.spi.Filter.DENY;
      				}
      			}
      		}
      		
      		return org.apache.log4j.spi.Filter.NEUTRAL;
      	}
      }));
    

    }

    $g('log4jFilterSet', true);
    }`

Imported Comment. Original Details:
Author: narupley
Created: 2015-03-30T13:02:56.000-0700

@rbeckman-nextgen
Copy link
Collaborator Author

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

Revisions 7659/7660: Suppressed warnings that occur when doing certain XML parser actions like pretty printing. This happens because the parser implementation we're using (Xerces) doesn't support certain properties that were added in JAXP 1.5.

Imported Comment. Original Details:
Author: narupley
Created: 2015-04-06T12:02:40.000-0700

@rbeckman-nextgen
Copy link
Collaborator Author

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

Using a simple channel, wrapping encoded data within the prettyprinter function, I was able to verify that errors were showing up within the server log on windows. The newest build suppressed the error warnings that were originally reported by the system.

Imported Comment. Original Details:
Author: jaysenp
Created: 2015-05-22T10:48:55.000-0700

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.