cancel
Showing results for 
Search instead for 
Did you mean: 

USING ALFRESCO IN EMBEDDED WAY

alestudent
Champ in-the-making
Champ in-the-making
Hi, i'm new to alfresco,

in this period i created a java library that make some operation on alfresco repository. Using this library in eclipse, it make correctly the operations on the repository (with web services but also in embedded way).
Now i'm trying to develope a web application using jsp that uses the library i have created. Now i'm tryng only to log in in the repository; Using web services there are not errors, but using alfresco in the embedded way i have the following exceptions thrown by tomcat:

exception

org.apache.jasper.JasperException
   org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:476)
   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:389)
   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

root cause

java.lang.NullPointerException
   it.saga.progetti.rs.esi.cms.alfresco.embedded.EsiCmsAlfrescoEmFactory.login(Unknown Source)
   it.saga.progetti.rs.esi.cms.EsiCmsManager.login(Unknown Source)
   org.apache.jsp.login.login_jsp._jspService(login_jsp.java:75)
   org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
——————————————————————————————————————————————-
it.saga.progetti.rs.esi.cms.alfresco.embedded.EsiCmsAlfrescoEmFactory.login IS THE LOGIN METHOD OF MY CLASS.

I'M USING ALFRESCO COMMUNITY 2.1.0 TOMCAT BOUNDLED. AND MY WEB APP IS IN THE "WEBAPPS" TOMCAT FOLDER
THERE ARE SOME CONFIGURATION TO USE ALFRESCO IN THE EMBEDDED WAY? I HAVE TO PUT SOME IMPORTANT FILE IN MY LIBRARY JAR(I.E. alfresco-jmxrmi.access )?
CAN SOMEONE HELP ME?
THANKS IN ADVANCE
4 REPLIES 4

pmonks
Star Contributor
Star Contributor
The stack trace says it all: the class "it.saga.progetti.rs.esi.cms.alfresco.embedded.EsiCmsAlfrescoEmFactory" is throwing a NullPointerException in its "login" method somewhere.  I'd suggest recompiling the class with debugging information enabled (so that line numbers are available) and then use the line number to help you identify where the problem lies in that method & class.

Cheers,
Peter

alestudent
Champ in-the-making
Champ in-the-making
Hi Peter,
thank you for answer;
Using log4j, i created a log file in which i see that my library can't obtain alfresco application context!!
I see also this page: http://wiki.alfresco.com/wiki/Alfresco_and_Tapestry_on_the_Same_Tomcat_Installation, but i can't resolve the problem….

I'M USING MY LIBRARY IN A WEB APPLICATION CREATED BY ME AND USING WEB SERVECES IT WORKS, BUT IF I WANT TO USE ALFRESCO IN EMBEDDED WAY IT FAILS TO OBTAIN APPLICATION CONTEXT…

CAN YOU HELP ME PLEASE?
THANK YOU IN ADVANCE

alestudent
Champ in-the-making
Champ in-the-making
HI,

FOLLOWING INFORMATION GIVEN FROM http://wiki.alfresco.com/wiki/Alfresco_and_Tapestry_on_the_Same_Tomcat_Installation, I DEPLOYED ALFRESCO COMMUNITY 2.1.0 TOMCAT BOUNDLED, AND IN TOMCAT FOLDER I HAVE PUT IN MY WEB APP THAT USES MY LIBRARY AND MY LIBRARY ITSELF IN TOMCAT SHARED/LIB FOLDER.
I TRIED TO OBTAIN ALFRESCO SERVLET CONTEXT THROUGH MY LIBRARY BUT I CAN'T. I FOLLOW THE FOLLOWING CODE:


ServletContext alfrescoWebContext = getServletContext().getContext("/alfresco");

WebApplicationContext alfrescoSpringContext = WebApplicationContextUtils.getRequiredWebApplicationContext(alfrescoWebContext);

Repository repository = (Repository)alfrescoSpringContext.getBean("JCR.Repository");

ServiceRegistry registry = (ServiceRegistry)alfrescoSpringContext.getBean(ServiceRegistry.SERVICE_REGISTRY);

etc…

POSTED AT http://forums.alfresco.com/viewtopic.php?t=3618#12296 BUT I FAILED WHEN I TRY TO CALL getServletContext().getContext("/alfresco");

I THINK THAT THE PROBLEM IS HERE BECAUSE THE NULL POINTER EXCEPTION IS GIVEN WHEN MY LIBRARY TRY TO OBTAIN ALFRESCO APPLICATION CONTEXT. BUT I CAN'T SOLVE IT BECAUSE OF MY LOW EXPERIENCE.

SORRY FOR MY ENGLISH
CAN SOMEONE HELP ME PLEASE?

alestudent
Champ in-the-making
Champ in-the-making
Hi everybody!

I solved my problem! It was because my library didn't find the correct alfresco spring application context! So i follow a forum post and i put my web app in the same alfresco tomcat (i use alfresco community 2.1.0 tomcat boundled) so with servlet.jar i can obtain the alfresco context and pass it to my web application.

regards