hbci4java
hbci4java copied to clipboard
Android Version
I am trying to convert the library for Android, I can load Umsätze but I can't make SEPATransfers… This is the Problem:
javax.xml.bind,ContextFinder.class does not find the right JAXBContext....
`static JAXBContext find(Class[] classes, Map properties) throws JAXBException { String jaxbContextFQCN = JAXBContext.class.getName(); Class[] arr$ = classes; int len$ = classes.length;
String factoryClassName;
for(int i$ = 0; i$ < len$; ++i$) {
Class c = arr$[i$];
ClassLoader classLoader = getClassClassLoader(c);
Package pkg = c.getPackage();
if (pkg != null) {
String packageName = pkg.getName().replace('.', '/');
String resourceName = packageName + "/jaxb.properties";
logger.log(Level.FINE, "Trying to locate {0}", resourceName);
Properties props = loadJAXBProperties(classLoader, resourceName);
if (props != null) {
logger.fine(" found");
if (props.containsKey("javax.xml.bind.context.factory")) {
factoryClassName = props.getProperty("javax.xml.bind.context.factory").trim();
return newInstance(classes, properties, factoryClassName);
}
throw new JAXBException(Messages.format("ContextFinder.MissingProperty", packageName, "javax.xml.bind.context.factory"));
}
logger.fine(" not found");
}
}
logger.log(Level.FINE, "Checking system property {0}", "javax.xml.bind.context.factory");
factoryClassName = (String)AccessController.doPrivileged(new GetPropertyAction("javax.xml.bind.context.factory"));
if (factoryClassName != null) {
logger.log(Level.FINE, " found {0}", factoryClassName);
return newInstance(classes, properties, factoryClassName);
} else {
logger.fine(" not found");
logger.log(Level.FINE, "Checking system property {0}", jaxbContextFQCN);
factoryClassName = (String)AccessController.doPrivileged(new GetPropertyAction(jaxbContextFQCN));
if (factoryClassName != null) {
logger.log(Level.FINE, " found {0}", factoryClassName);
return newInstance(classes, properties, factoryClassName);
} else {
logger.fine(" not found");
Class factory = lookupUsingOSGiServiceLoader("javax.xml.bind.JAXBContext");
if (factory != null) {
logger.fine("OSGi environment detected");
return newInstance(classes, properties, factory);
} else {
logger.fine("Checking META-INF/services");
try {
String resource = "META-INF/services/" + jaxbContextFQCN;
ClassLoader classLoader = getContextClassLoader();
URL resourceURL;
if (classLoader == null) {
resourceURL = ClassLoader.getSystemResource(resource);
} else {
resourceURL = classLoader.getResource(resource);
}
if (resourceURL != null) {
logger.log(Level.FINE, "Reading {0}", resourceURL);
BufferedReader r = new BufferedReader(new InputStreamReader(resourceURL.openStream(), "UTF-8"));
factoryClassName = r.readLine().trim();
return newInstance(classes, properties, factoryClassName);
}
logger.log(Level.FINE, "Unable to find: {0}", resource);
} catch (UnsupportedEncodingException var13) {
throw new JAXBException(var13);
} catch (IOException var14) {
throw new JAXBException(var14);
}
logger.fine("Trying to create the platform default provider");
return newInstance(classes, properties, "com.sun.xml.internal.bind.v2.ContextFactory");
}
}
}
}`
I've absolutly no idea what this code means, where it comes from and what it's used for. I've never designed and tested HBCI4Java to be used in Android.
hello, i can understand that you dont support android, the code is from javax.xml.bind. the exception is
org.kapott.hbci.exceptions.HBCI_Exception: Fehler beim Hinzuf�gen des Auftrages UebSEPA1 zum aktuellen Dialog at org.kapott.hbci.manager.HBCIDialog.addTask(HBCIDialog.java:546) at org.kapott.hbci.manager.HBCIHandler.addJobToDialog(HBCIHandler.java:412) at org.kapott.hbci.GV.HBCIJobImpl.addToQueue(HBCIJobImpl.java:1181) at org.kapott.hbci.GV.HBCIJobImpl.addToQueue(HBCIJobImpl.java:1186) at org.de.jmg.hbci4android2.Banking.SepaTrans(Banking.java:541) at org.de.jmg.hbci4android2.activity_Transfer.transfer(activity_Transfer.java:94) at org.de.jmg.hbci4android2.activity_Transfer.access$600(activity_Transfer.java:19) at org.de.jmg.hbci4android2.activity_Transfer$1.onClick(activity_Transfer.java:60) at android.view.View.performClick(View.java:4463) at android.view.View$PerformClick.run(View.java:18789) at android.os.Handler.handleCallback(Handler.java:808) at android.os.Handler.dispatchMessage(Handler.java:103) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:5299) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641) at dalvik.system.NativeStart.main(Native Method) Caused by: org.kapott.hbci.exceptions.HBCI_Exception: *** the _sepapain segment for this job can not be created at org.kapott.hbci.GV.AbstractSEPAGV.createSEPAFromParams(AbstractSEPAGV.java:304) at org.kapott.hbci.GV.AbstractSEPAGV.verifyConstraints(AbstractSEPAGV.java:348) at org.kapott.hbci.manager.HBCIDialog.addTask(HBCIDialog.java:496) ... 18 more Caused by: javax.xml.bind.JAXBException
- with linked exception: [java.lang.ClassNotFoundException: Didn't find class "com.sun.xml.internal.bind.v2.ContextFactory" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:241) at javax.xml.bind.ContextFinder.find(ContextFinder.java:455) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:652) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:599) at org.kapott.hbci.GV.generators.AbstractSEPAGenerator.marshal(AbstractSEPAGenerator.java:43) at org.kapott.hbci.GV.generators.GenUebSEPA00100303.generate(GenUebSEPA00100303.java:151) at org.kapott.hbci.GV.generators.GenUebSEPA00100303.generate(GenUebSEPA00100303.java:1) at org.kapott.hbci.GV.AbstractSEPAGV.createSEPAFromParams(AbstractSEPAGV.java:296) ... 20 more Caused by: java.lang.ClassNotFoundException: Didn't find class "com.sun.xml.internal.bind.v2.ContextFactory" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/vendor/lib, /system/lib]]at alvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:497) at java.lang.ClassLoader.loadClass(ClassLoader.java:457) at android.app.LoadedApk$WarningContextClassLoader.loadClass(LoadedApk.java:438) at javax.xml.bind.ContextFinder.safeLoadClass(ContextFinder.java:573) at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:239) ... 27 more
Olaf Willuhn [email protected] schrieb am So., 29. Sep. 2019 22:38:
I've absolutly no idea what this code means, where it comes from and what it's used for. I've never designed and tested HBCI4Java to be used in Android.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/hbci4j/hbci4java/issues/31?email_source=notifications&email_token=ACHFGDJCDMMOQCIKJ6LGPM3QMEG57A5CNFSM4I3T3GTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD736E7Q#issuecomment-536339070, or mute the thread https://github.com/notifications/unsubscribe-auth/ACHFGDLDIXXNLWGIDMAMOYTQMEG57ANCNFSM4I3T3GTA .
Android hat kein Jaxb mit an Bord, soweit ich weiß. Und man kann es auf Android wohl auch nicht verwenden, da man keine Libs mit javax package hinzufügen darf. Ich denke es liegt daran. Google mal "jaxb android" Man sollte also eventuell hier erstmal JAXB rausschmeißen, um die Lib dann auf Android verwenden zu können.
Ich kann sehr wohl 'javax.xml.bind:jaxb-api:2.3.1' hinzufügen. Nur fehlen dann anscheinend weitere libraries. Wenn man JAXB rausschmeisst, muss man hbci4java zu 50% neu programmieren......
@jgbl I am also trying to use hbci4java on Android, and in my use case reading transactions might be enough. Thus I'd be interested to learn how you managed to get that far. Even if add jaxb, I still run into "javax.xml.parsers.ParserConfigurationException: No validating DocumentBuilder implementation available". Could you document how you defined your dependencies? Mine are at the moment:
implementation 'com.github.hbci4j:hbci4j-core:3.1.37'
implementation 'javax.xml.bind:jaxb-api:2.3.1'
On branch 4.0, I was able to build a version that runs on Android, by patching file MsgGen.java to use Xerces instead of the default DocumentBuilderFactory:
diff --git a/src/main/java/org/kapott/hbci/manager/MsgGen.java b/src/main/java/org/kapott/hbci/manager/MsgGen.java
index 18ec0f3..c0d3a4c 100644
--- a/src/main/java/org/kapott/hbci/manager/MsgGen.java
+++ b/src/main/java/org/kapott/hbci/manager/MsgGen.java
@@ -75,7 +75,7 @@ public final class MsgGen
public MsgGen(InputStream syntaxFileStream)
{
try {
- DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
+ DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl", null);
dbf.setIgnoringComments(true);
dbf.setValidating(true);
@willuhn Would you be willing to allow clients of the library to configure the DocumentBuilderFactory to use?
Die von "DocumentBuilderFactory.newInstance()" verwendete Factory ist doch bereits durch die Java-Bordmittel konfigurierbar.
System.setProperty("javax.xml.parsers.DocumentBuilderFactory","org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
https://docs.oracle.com/javase/8/docs/api/javax/xml/parsers/DocumentBuilderFactory.html#DocumentBuilderFactory--
Die von "DocumentBuilderFactory.newInstance()" verwendete Factory ist doch bereits durch die Java-Bordmittel konfigurierbar.
Unfortunately not on Android: https://developer.android.com/reference/javax/xml/parsers/DocumentBuilderFactory#newInstance()
Hab's übernommen. https://github.com/hbci4j/hbci4java/commit/0f7626d0ceb85773eb37effd2a3d1f59628d4502
Readme lesen
Olaf Willuhn @.***> schrieb am Fr., 4. Aug. 2023, 15:08:
Die von "DocumentBuilderFactory.newInstance()" verwendete Factory ist doch bereits durch die Java-Bordmittel konfigurierbar.
System.setProperty("javax.xml.parsers.DocumentBuilderFactory","org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
https://docs.oracle.com/javase/8/docs/api/javax/xml/parsers/DocumentBuilderFactory.html#DocumentBuilderFactory--
— Reply to this email directly, view it on GitHub https://github.com/hbci4j/hbci4java/issues/31#issuecomment-1665583691, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACHFGDPEMMZDHRB6ZUVBWQLXTTX6LANCNFSM4I3T3GTA . You are receiving this because you were mentioned.Message ID: @.***>
Fürs Protokoll: Funktionalität, die JAXB (oder Jakarta auf branch 4.0) benötigt, funktioniert nicht.
Soweit ich getestet habe, funktioniert HKKAZ (Umsätze in mt940/mt942).
HKCAZ (Umsätze im camt Format) funktioniert nicht.