Open gvoigt opened 6 years ago
I think the problem are the space characters in the OLCA_LIB_DIR
. It works for me when I load the libs from a folder with no space characters (there should be a way to encode them correctly for sys.path
but I did not found a quick way). You could just copy the jar files in the libs
folder to another folder without space characters and load them from there.
I tried the same example with the code above from @gvoigt . I also deleted the space characters.
import os
import sys
# change this path so that it matches the `libs` folder of your openLCA installation
libdir = "C:\Users\philipp\AppData\Local\openLCA\plugins\olca-app_1.6.3\libs"
for jar in os.listdir(libdir):
print("Add jar to path " + jar)
full_path = os.path.join(libdir, jar)
sys.path.append(full_path)
# now you can access the openLCA API
from org.openlca.core.database.derby import DerbyDatabase
from java.io import File
# path to our database
folder = "C:\Users\philipp\openLCA-data-1.4\databases\test_ProBas"
db = DerbyDatabase(File(folder))
Unfortunatly I get the following output.
log4j:WARN No appenders could be found for logger (org.openlca.core.database.derby.DerbyDatabase).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Traceback (most recent call last):
File "C:\Users\philipp\eclipse-workspace\test\load_ProBas.py", line 19, in <module>
db = DerbyDatabase(File(folder))
at org.openlca.core.database.derby.DerbyDatabase.createNew(DerbyDatabase.java:96)
at org.openlca.core.database.derby.DerbyDatabase.<init>(DerbyDatabase.java:61)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.python.core.PyReflectedConstructor.constructProxy(PyReflectedConstructor.java:211)
org.openlca.core.database.DatabaseException: org.openlca.core.database.DatabaseException: Failed to create database
What do I do wrong? Thanks for your help!
@Brotrand you have to escape the backslashes in the paths, so write "C:\\Users\\philipp\\openLCA-data-1.4\\databases\\test_ProBas"
or "C:/Users/philipp/openLCA-data-1.4/databases/test_ProBas"
instead of "C:\Users\philipp\openLCA-data-1.4\databases\test_ProBas"
. Does this help?
@msrocka Indeed, thank you very much. It´s working now!
Hi everybody, this is new for me, somebody can help me to play in this level? i do not write macros in openLCA. thanks for all
Julián
2018-01-18 9:16 GMT-05:00 Brotrand notifications@github.com:
@msrocka https://github.com/msrocka Indeed, thank you very much. It´s working now!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/GreenDelta/openlca-python-tutorial/issues/6#issuecomment-358659380, or mute the thread https://github.com/notifications/unsubscribe-auth/AY4vesx6-vqWLGhBrpnSNpjuwCTtW0Qyks5tL1JFgaJpZM4Q9a-K .
I am getting a nullpointer exception when running above code. I deleted all spaces in the lib path and I escaped the database path ('C:\Users\user\openLCA-data-1.4\databases\openlca_lcia_methods_1_5_7').
log4j:WARN No appenders could be found for logger (org.openlca.core.database.derby.DerbyDatabase).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Users\user\.IdeaIC2018.2\config\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_umd.py", line 198, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "C:/Users/user/IdeaProjects/OpenLCATest/main.py", line 5, in <module>
oDB = DerbyDatabase(JavaFile(sDataBasePath))
PersistenceUnitLoadingException: Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.6.4.v20160829-44060b6): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: org.python.core.SyspathJavaLoader@52d96367
Internal Exception: java.lang.NullPointerException
Any ideas?
@Pommespapst Is this error trace complete? If not, could you also post the rest of it?
Otherwise: Is the database maybe opened in openLCA? -> you can only connect to a database that is not opened by another process.
I found one (the?) error. My OpenLCA Version is 1.6.3. My JDK is version 10. The method "toValue" of the org.eclipse.persistence.internal.helper.JavaSEPlatform checks JDK versions up to 9. For versions higher than 9 it returns null, causing the database import to crash. I am now updating OpenLCA to see if that solves the problem.
Update: installing newest OpenLCA Version resolved the problem!
I would like to open a database but without success
I also I tried
But I alway get
How can I fix this?