log4j2.configurationFile does not accept yaml? - log4j2

I migrated my old project from some SimpleLogger to Log4J. I hate Log4j because it is extremely difficult to set up.
Now, how do I feed some config into it?
Configuration:
status:info
name: YAMLConfigTest
thresholdFilter:
level: info
Appenders:
Console:
name: STDOUT
target: SYSTEM_OUT
PatternLayout:
Pattern: "%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"
I tried loading it using the log4j2.configurationFile variable. But log4j always tries to interpret the file as XML. Why is that? Is there anything that I can do about it?
ERROR StatusLogger Error parsing /fullpath/log4j2.yaml
org.xml.sax.SAXParseException; systemId: file:///fullpath/log4j2.yaml; lineNumber: 1; columnNumber: 1; Content ist nicht zulässig in Prolog.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257)
...
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:196)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:599)
at de.tisje.dendro.plot.swing.Kurvenplot.<clinit>(Kurvenplot.java:91)
Alternative solution would be to put the file somewhere where it can be found automatically.
Where do I put the file in a standard eclipse/gradle project?
do I have to tell gradle how to handle it?
thanks

The XML ConfigurationFactory is a "catch-all" factory: it tries to read those files that were rejected by other configuration factories.
While the YAML configuration factory is distributed with log4j-core, it requires additional runtime dependencies to be active (this is mentioned briefly in the documentation). You need to add jackson-dataformat-yaml to your project.

Related

Liquigraph schema files missing?

We have a service in our site that uses neo4j for the database. Today when I tried to load up the service for development the project bombs out. I'm getting errors like this:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquigraph' defined in class path resource [org/liquigraph/spring/starter/LiquigraphAutoConfiguration$LiquigraphConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException:
cvc-elt.1: Cannot find the declaration of element 'changelog'.
and this:
2021-08-02 14:43:41.516 WARN 9650 --- [ restartedMain] o.l.core.io.xml.ChangelogParser : XSD validation warning : schema_reference.4: Failed to read schema document 'http://www.liquigraph.org/schema/1.0/liquigraph.xsd', 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>.
in my terminal.
I went to the site listed in the error and it doesn't work. There is also this one which is pretty similar but gives a 404.
our pom.xml file lists this for liquigraph:
<!-- https://mvnrepository.com/artifact/org.liquigraph/liquigraph-spring-boot-starter -->
<dependency>
<groupId>org.liquigraph</groupId>
<artifactId>liquigraph-spring-boot-starter</artifactId>
<version>3.0.3</version>
</dependency>
In researching the project I saw something about running it "offline" or something. How can I get the project to load with the XSD files missing?
This should be fixed now.
I just deployed a new version of the website and misconfigured a couple of things (wrong CNAME file location, wrong schema files location).
https://www.liquigraph.org/schema/1.0/liquigraph.xsd and http://www.liquigraph.org/schema/1.0/liquigraph.xsd should work fine now.
More recent releases of Liquigraph also support schema location redirects such as the latest 3.x and 4.x. Make sure to upgrade!

Unsupported Java encoding for writing wsdl file

when deploying the following webservice
#WebService(serviceName = "TestService")
#SOAPBinding(use = Use.LITERAL, style = Style.DOCUMENT, parameterStyle= SOAPBinding.ParameterStyle.WRAPPED)
public class KekeDummyWebservice implements kekeService {...
on one of my servers I do get the following error:
javax.wsdl.WSDLException: WSDLException:faultCode=CONFIGURATION_ERROR: Unsupported Java encoding for writing wsdl file: 'ISO8859_15'.
I don't know where the 'ISO8859_15' encoding comes from. The wildfly prints out
-Dfile.encoding=ISO-8859-15
while starting. Another point is that during wildfly start the warning
[jacorb.codeset] (MSC service thread 1-7) Warning - unknown codeset (ISO8859_15) - defaulting to ISO-8859-1
can be seen.
Thanks
I had similar issue on our system, with following error in the log during deployment on Wildlfy10:
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=CONFIGURATION_ERROR: Unsupported Java encoding for writing wsdl file: 'Cp1252'
Finally it was solved by resaving of xsd/wsld in utf-8 and setting targetNamespace in WS implementaion accordingly to what was defined in xsd/wsld. This aproach is not fully applicable on your case, but maybe it helps.
Try to run command "locale". It will give "LANG=en_US.ISO-8859-15".
Update this LANG to use "en_US.UTF-8" using export.
This solved the issue.

TFS Database Backup Failed : There is an error in XML document - but which Doc?

Our Nightly TFS 2012 backup has just started to fail. It also fails when run directly through TFS Express Administration Console.
Which file is the following error actually referring to? If I can find it then I should be able to fix the "Root element is missing" error :)
[13/08/2014 23:00:00] [Info] Full database backup job
[13/08/2014 23:00:00] [Info] Getting backup lock
[13/08/2014 23:00:05] [Error]
Exception Message: There is an error in XML document (0, 0). (type InvalidOperationException)
Exception Stack Trace: at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at Microsoft.TeamFoundation.Admin.BackupSets.Load(String folder)
at Microsoft.TeamFoundation.Admin.Jobs.FullDatabaseBackupJobExtension.Run(TeamFoundationRequestContext requestContext, TeamFoundationJobDefinition jobDefinition, DateTime jobQueueTime, String& resultMessage)
Inner Exception Details:
Exception Message: Root element is missing. (type XmlException)
Exception Stack Trace: at System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo(String res)
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlReader.MoveToContent()
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderBackupSets.Read7_BackupSets()
[13/08/2014 23:00:05] [Info] Full Backups Failed
Thanks.
Dylan answered my original question as to where to find the unspecified xml file that was in error, but in case it helps anyone else...
The Backupsets.xml file was empty. Why this is I do not know...
Attempting to configure backups through TFS Express Administration Console also failed with the same error, so I
Deleted the Backupsets.xml file altogether
Reconfigured Backups using the wizard - Now that it didn't find the xml file at all it created a new one.
Ran a full backup - which was sucessful. Hopefully the scheduled backups will now also work from now on.
NB The newly created Backupsets.xml file (Before the first full backup) :
<?xml version="1.0"?>
<BackupSets xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Version>1</Version>
<BackupSets />
</BackupSets>
Look in the folder where your backups are configured to be placed. there will be an XML file there, can't remember the name, but maybe something like BackupSets.xml
FIX (user workaround):
Rename the file BackupSets.xml in the backup destination folder
Re-run Full Backup*
In TFS Admin Console select Scheduled Backups, then click Take Full Backup Now. Or use command line, PowerShell script, API call as desired.
CAUSE: backupsets.xml in backup destination does not contain valid XML.
Why does this cause failure? Backup wizard opens backupsettings.xml then calls XML deserializer function System.Xml.Serialization.XmlSerializer.Deserialize preparing to add new entry. Invalid XML content including empty/zero byte or text-only content will cause deserialize exception.
PRODUCTS IMPACTED: Repro confirmed in TFS2010 and on 2017-11-25 I had repro with TFS2015 SP3 :-O
Fix is fairly straightforward... once you understand what is going on. -Zephan
MICROSOFT CODE BUGFIX/feature improvement request:
BACKUP Wizard exception handling for backupsets.xml deserialize or parsing exceptions.
If XML deserialization error then close backupsets.xml, rename it to backupsets-YYMMDD-hhmm-corrupt-backup.xml, then jump to backupsets.xml file not found functionality.
SEVERITY: HIGH (data loss)
This is a long-standing problem that can lead to major data loss. I've personally seen over 1 month of data loss due to this issue silently blocking backups and making all earlier restore sets unusable (since parsing BackupSets.xml is VERY finicky I couldn't even hack to restore last successful backup.)

WSDL Endpoint example throwing errors in Mule

Posting here is always my last resort, but I'm going crazy here. I'm a Mule ESB beginner. I've been trying to do some simple examples to get me on the right track.
But I've encountered a problem with one of the examples I've seen on the mule website...
http://www.mulesoft.org/documentation/display/current/WSDL+Connectors
I'm trying to set up a generic WSDL endpoint, which invokes a web service without generating a client.
The WSDL I'm trying to access...
http://www.webservicex.net/CurrencyConvertor.asmx?WSDL&method=ConversionRate
The problem is, I keep getting the following error
[ERROR] IOException during exec() of compiler "javac". Check your path environment variable.
ERROR 2013-04-19 09:27:07,920 [[soap].soapFlow1.stage1.02] org.apache.cxf.endpoint.dynamic.DynamicClientFactory: Could not compile java files for http://www.webservicex.net/CurrencyConvertor.asmx?WSDL&method=ConversionRate?wsdl.
ERROR 2013-04-19 09:27:07,934 [[soap].soapFlow1.stage1.02] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Unable to create JAXBContext for generated packages: Provider com.sun.xml.bind.v2.ContextFactory could not be instantiated: javax.xml.bind.JAXBException: "net.webservicex" doesnt contain ObjectFactory.class or jaxb.index (java.lang.IllegalStateException)
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. "net.webservicex" doesnt contain ObjectFactory.class or jaxb.index (javax.xml.bind.JAXBException)
com.sun.xml.bind.v2.ContextFactory:183 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/xml/bind/JAXBException.html)
2. Provider com.sun.xml.bind.v2.ContextFactory could not be instantiated: javax.xml.bind.JAXBException: "net.webservicex" doesnt contain ObjectFactory.class or jaxb.index (javax.xml.bind.JAXBException)
javax.xml.bind.ContextFinder:-1 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/xml/bind/JAXBException.html)
3. Unable to create JAXBContext for generated packages: Provider com.sun.xml.bind.v2.ContextFactory could not be instantiated: javax.xml.bind.JAXBException: "net.webservicex" doesnt contain ObjectFactory.class or jaxb.index (java.lang.IllegalStateException)
org.apache.cxf.endpoint.dynamic.DynamicClientFactory:363 (null)
4. Unable to create JAXBContext for generated packages: Provider com.sun.xml.bind.v2.ContextFactory could not be instantiated: javax.xml.bind.JAXBException: "net.webservicex" doesnt contain ObjectFactory.class or jaxb.index (java.lang.IllegalStateException) (org.mule.api.DefaultMuleException)
org.mule.module.cxf.builder.AbstractOutboundMessageProcessorBuilder:96 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/DefaultMuleException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
javax.xml.bind.JAXBException: "net.webservicex" doesnt contain ObjectFactory.class or jaxb.index
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:183)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
And yes, I've hunted around the internet for hours looking for a solution.
Things I've done to try fix the problem.
Make sure the javac path is set in the environment variables.
(%JAVA_HOME%\bin)
Make sure that mule studio has the correct path to JRE
I know it's a simple problem, but I need to figure it out to tackle a larger project that I have in mind.
If anyone could shed some light on a solution this problem, then I'd be extremely grateful.
Thanks :)
Other info:
Using Java 1.7
Using MuleStudio 3.4
Ok, after trying and failing at many different solutions, I've figured it out.
I've seen a lot of people asking the same question as me, with very few solutions.
Here is mine...
The JRE was incorrect.
My java directory consisted of..
And Mule studio was using the folder jre7
So I changed it to use the JRE in the directory jdk1.7.0_17/jre
Ran it again and.. OMG it worked!!
Here is how to do it in mule studio/eclipse...Right Click on your Project --> Properties --> Java Build Path --> Libraries Tab --> Click JRE System Library --> Press Edit --> Click Alternate JRE --> Click Installed JREs.. --> Then Add the JRE from the correct directory like I stated above.
Hope this helps anyone with the same problem! :)

saxon: problem reusing XsltTransformer object

Using Saxon-B, I'm trying to follow the javadoc and serially reuse an XsltTransformer object.
I'm thwarted by:
Error
XTDE1490: Cannot write more than one result document to the same URI, or write to a URI
that has been read: file:/Users/benson/x/btweb/web_2_0/sites/us/errors/404/404.xml.prepared
2011-03-22 11:06:23,830 [main] ERROR btweb.compiler.CompileSite - Site compilation terminated with error.
btweb.compiler.CompilerException: Error running transform Cannot write more than one result document to the same URI, or write to a URI that has been read: file:/Users/benson/x/btweb/web_2_0/sites/us/errors/404/404.xml.prepared
It's probably Saxon-B bug. You can find more information here. According to this site "Fixed in 8.9.0.4".

Resources