cancel
Showing results for 
Search instead for 
Did you mean: 

tagging by local java api caused NullpointerException

maumig_
Confirmed Champ
Confirmed Champ

Hi all, when I try to tag a document by following code, I obtain a nullpointerexception. Some suggest about how to use local java api? Thanks.

I have a jsp with this code: **<%

	LocalSessionFactory lsf = new LocalSessionFactory();
	CoreSession session = lsf.getSession();
	
	TagService tsi = Framework.getService(TagService.class);
	tsi.tag(session, "2b1eefa4-81ee-4d0f-8bcb-24f5e9745f96", "trytag","Administrator");

%>**

Exception stacktrace logs:

143: CoreSession csession = lsf.getSession(); 144: 145: TagService tsi = Framework.getService(TagService.class); 146: tsi.tag(csession, "2b1eefa4-81ee-4d0f-8bcb-24f5e9745f96", "cacca","Administrator"); 147: 148: 149: Stacktrace: at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:521) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:430) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.nuxeo.wss.servlet.BaseWSSFilter.doFilter(BaseWSSFilter.java:137) at org.nuxeo.wss.servlet.FailSafeWSSFilter.doFilter(FailSafeWSSFilter.java:55) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.nuxeo.ecm.platform.ui.web.rest.FancyURLFilter.doFilter(FancyURLFilter.java:129) ... 24 more Caused by: java.lang.NullPointerException at org.nuxeo.ecm.core.api.local.LocalSession.getPrincipal(LocalSession.java:164) at org.nuxeo.ecm.core.api.UnrestrictedSessionRunner.isUnrestricted(UnrestrictedSessionRunner.java:103) at org.nuxeo.ecm.core.api.UnrestrictedSessionRunner.(UnrestrictedSessionRunner.java:56) at org.nuxeo.ecm.platform.tag.TagServiceImpl$UnrestrictedAddTagging.(TagServiceImpl.java:131) at org.nuxeo.ecm.platform.tag.TagServiceImpl.tag(TagServiceImpl.java:115) at org.apache.jsp.prova_jsp._jspService(prova_jsp.java:220) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388) ... 34 more

3 REPLIES 3

Florent_Guillau
World-Class Innovator
World-Class Innovator

This is not how you extend Nuxeo. LocalSessionFactory is an internal class not designed to be used by user code.

Please start with http://doc.nuxeo.com/display/NXDOC/Dev+Cookbook and http://doc.nuxeo.com/display/NXDOC/Customization+and+Development

maumig_
Confirmed Champ
Confirmed Champ

Ok. But, probably I was not clear.

As stated in the documentation,

mode of invocation of services

The services can be local (inside the same JVM) and most of them can be Also called remotely via RMI if your target Application Server supports EJB3 remoting.

I would like to call upon the services of Nuxeo from "local", ie with a java client within the same JVM of Nuxeo. This need arises from having to perform operations that are not supported by remote clients documented. For example, do the tagging of a document.

The question becomes: How do I invoke a service (for example that of tagging) in "local" mode?

I tried to write the previous code but probably I'm missing some basic concept.

Thank you again.

Florent_Guillau
World-Class Innovator
World-Class Innovator

You wrote this in the answers section but this is not an answer. Please update your original question instead, or add a comment to it.

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.