Using eclipselink in Java code run from MATLAB

≡放荡痞女 提交于 2019-12-10 15:34:47

问题


I am trying to provide an interface that I can call from MATLAB to access the contents of a database. I already have an existing Java interface that uses eclipselink to connect to the database and I would like to re-use it. I wrote a class to provide this and it works properly when I call it straight from Java, but when I try to call it from MATLAB I get the following exception:

javax.persistence.PersistenceException: No Perisistence provider for EntityManager named DatabaseConnection

Usually this exception occurs when I do not have the META-INF folder with the persistence.xml on the classpath properly, but I have tried putting the base folder that contains the META-INF folder on both the dynamic and static MATLAB javaclasspaths with no success. Again, this exact code (including the persistence.xml) work fine when run from java. Does anyone know what I am missing?

The one main difference that I was able to track down from what occurs when I run the java code is that MATLAB is using a OSGI classloader (felix) rather than the default classloader that Java uses, but I haven't figured out what difference that makes to finding the persistence.xml.


回答1:


See my answer to this at Using Java generic classes in Matlab. It is ugly, but the only thing that I have gotten working so far.



来源:https://stackoverflow.com/questions/4390740/using-eclipselink-in-java-code-run-from-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!