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

Could not load the property file output_xml.properties for output method xml #978

Closed
ganeshmca opened this issue May 11, 2018 · 4 comments
Closed

Comments

@ganeshmca
Copy link

When Transformer new instance is created I am getting a runtime exception, any solutions or workaround ?

Exception
2018-05-10 09:58:19.278339+0530 LumifyIOS[58056:5630921] *** Terminating app due to uncaught exception 'OrgApacheXmlSerializerUtilsWrappedRuntimeException', reason: 'org.apache.xml.serializer.utils.WrappedRuntimeException: Could not load the propery file 'output_xml.properties' for output method 'xml' (check CLASSPATH)'

JavaCode
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();

J2OBJC Code
JavaxXmlTransformTransformerFactory *transformerFactory = JavaxXmlTransformTransformerFactory_newInstance();
JavaxXmlTransformTransformer *transformer = [((JavaxXmlTransformTransformerFactory *) nil_chk(transformerFactory)) newTransformer];

@tomball
Copy link
Collaborator

tomball commented May 11, 2018

The Xalan serializer has properties files that need to be included with your app as Java resources. There are seven files in the org/apache/xml/serializer directory, so as the Java resources page directs, all of them need to be copied into an org/apache/xml/serializer Resources sub-directory.

I'm leaving this issue open, as we should be able to copy the properties file data into default tables in the OutputPropertiesFactory, so there is a backup when those property files are not present (rather than throwing a WrappedRuntimeException).

@ganeshmca
Copy link
Author

ganeshmca commented May 11, 2018

Thanks, After adding those files that error is solved and I have started getting this exception in the last line, please suggest anything more to be added

Exception
org.apache.xml.serializer.utils.WrappedRuntimeException: The Properties object passed to the SerializerFactory does not have a 'method' property.

TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
DOMSource source = new DOMSource(document);
StreamResult result = new StreamResult(output);
transformer.transform(source, result);

J2OJBC Code
JavaxXmlTransformTransformer *transformer = [((JavaxXmlTransformTransformerFactory *) nil_chk(transformerFactory)) newTransformer];
[((JavaxXmlTransformTransformer *) nil_chk(transformer)) setOutputPropertyWithNSString:JavaxXmlTransformOutputKeys_INDENT withNSString:@"yes"];
[transformer setOutputPropertyWithNSString:@"{http://xml.apache.org/xslt}indent-amount" withNSString:@"2"];
JavaxXmlTransformDomDOMSource *source = new_JavaxXmlTransformDomDOMSource_initWithOrgW3cDomNode_(document);
JavaxXmlTransformStreamStreamResult *result = new_JavaxXmlTransformStreamStreamResult_initWithJavaIoOutputStream_(output);
[transformer transformWithJavaxXmlTransformSource:source withJavaxXmlTransformResult:result];

@ganeshmca
Copy link
Author

Exception
org.apache.xml.serializer.utils.WrappedRuntimeException: The Properties object passed to the SerializerFactory does not have a 'method' property.

This is solved after adding this line.
transformer.setOutputProperty(OutputKeys.METHOD, "xml");

tomball added a commit that referenced this issue May 16, 2018
… include Xalan resources.

	Change on 2018/05/16 by tball <tball@google.com>

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=196823645
@tomball
Copy link
Collaborator

tomball commented May 16, 2018

Added support for apps that fail to correctly link in Xalan resource files. If a resource is not found, a string containing the same data as the resource file is loaded instead. To use this before the next release (not scheduled), build j2objc from source and use that source's dist/lib as the library path to j2objc libraries.

@tomball tomball closed this as completed May 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants