Embedding Nuxeo

Hi,

I'm would like to embed the Nuxeo DM core into my application so that I can make Java API calls to it to store and retrieve documents. However, I don't see what is the right starting point for this. I tried to work with the FrameworkerLoader from http://doc.nuxeo.com/display/KB/How+to+use+an+embedded+Nuxeo+from+a+Java+application but I get a NullPointerException when I call Framework.getLocalService(SchemaManager.class). Can somebody provide me with a more complete example on how to embed Nuxeo?

Thanks

Martin

1 votes

1 answers

2068 views

ANSWER

Hi,

What's the full stacktrace with the NullPointerException? I suspect the NPE being raised at line <code>runtime.getService(serviceClass);</code>

If so, did you properly initialize and start the framework? <code>FrameworkLoader.initialize(getClass().getClassLoader(), wd, bundles, env); FrameworkLoader.start();</code><br> Did you look at the logs for checking the Framework starting status?

You may have a look at NuxeoStarter which makes use of the FrameworkLoader:<br> <code>nuxeo-runtime/nuxeo-runtime-deploy/src/main/java/org/nuxeo/runtime/deployment/NuxeoStarter.java</code>

10/31/2011

Hi,

Thanks for the prompt answer!

Yes, sorry for the missing stacktrace: java.lang.NullPointerException

at org.nuxeo.runtime.api.Framework.getLocalService(Framework.java:163)

which is runtime.getService(serviceClass) as you suspected.

Where is this NuxeoStarter class? I don't have it in my sources (which are 5.4.2 release)

Martin

10/31/2011

Since runtime is null, you have an issue with the framework initialization.

NuxeoStarter is a new class, look at nuxeo-runtime 5.5 source code

10/31/2011

The framework reports no errors during initialization. However, my problem seems to be that I did not provide all the bundles required to run my code, because after adding all .jars from the bundles directory of the distribution, my code works. Of course, this is not optimal so I wonder how I can figure out which bundles are required. Currently, I only want to get a reference to the SchemaManager (Framework.getLocalService(SchemaManager.class)) and thus I thought that adding nuxeo-core-schema-5.4.2.jar would be sufficient, but I was wrong. What else do I need to add?

Martin

11/01/2011



There must be logs about missing code (such as ClassNotFoundException). If you do get some logs (confirming you properly configured the logging) but no error, please fill a Jira issue about raising errors at framework initialization: https://jira.nuxeo.com/browse/NXP

About nuxeo-core-schema, if you look at its Maven POM, you will see it has dependencies on other Nuxeo modules: nuxeo-common, nuxeo-runtime and on third-party libraries: xsom and relaxngDatatype
See https://maven.nuxeo.org/nexus/ => nuxeo-core-schema-5.4.2.pom

Note those modules will also have their own dependencies. Manually resolving them will be a pain. You should use Maven for compiling and resolving dependencies. See http://doc.nuxeo.com/x/BIAO

FYI, here's a simplified dependency tree of nuxeo-core-schema:

$ mvn dependency:tree -o
org.nuxeo.ecm.core:nuxeo-core-schema:jar:5.4.2
+- org.nuxeo.common:nuxeo-common:jar:5.4.2:compile
|  +- xerces:xercesImpl:jar:2.9.1:provided
|  +- org.osgi:osgi-core:jar:4.1:provided
|  +- commons-io:commons-io:jar:1.4:provided
|  +- commons-lang:commons-lang:jar:2.3:provided
|  \- commons-logging:commons-logging:jar:1.1:provided
|     +- log4j:log4j:jar:1.2.16:provided (version managed from 1.2.12)
|     +- logkit:logkit:jar:1.0.1:provided
|     +- avalon-framework:avalon-framework:jar:4.1.3:provided
|     \- javax.servlet:servlet-api:jar:2.4:provided (version managed from 2.3)
+- org.nuxeo.runtime:nuxeo-runtime:jar:5.4.2:compile
|  +- org.nuxeo.common:nuxeo-common:jar:5.4.2:compile
|  +- javax.transaction:jta:jar:1.1:provided
|  \- commons-jexl:commons-jexl:jar:1.1:provided
+- com.sun.xml:xsom:jar:20060306:compile
\- com.sun.xml:relaxngDatatype:jar:1.0:compile
0 votes