i have an Liferay portal 6.2 ce ga4 jboss bundle up and running with a thrift servlet i wrote for communication between an app and the server. I wanna use Liferay for its User Management only, so i just want to authenticate a User with his credentials through the Liferay api.
I first tried to use the UserLocalServiceUtil, but when i call the Method the Server throws this error :
08:07:13,962 SEVERE [com.liferay.portal.kernel.bean.PortalBeanLocatorUtil] (http--0.0.0.0-8080-1) BeanLocator is null
08:07:13,963 ERROR [stderr] (http--0.0.0.0-8080-1) java.lang.Exception: Stack trace
08:07:13,963 ERROR [stderr] (http--0.0.0.0-8080-1) at java.lang.Thread.dumpStack(Thread.java:1365)
08:07:13,963 ERROR [stderr] (http--0.0.0.0-8080-1) at com.liferay.portal.kernel.bean.PortalBeanLocatorUtil.locate(PortalBeanLocatorUtil.java:74)
08:07:13,964 ERROR [stderr] (http--0.0.0.0-8080-1) at com.liferay.portal.service.UserLocalServiceUtil.getService(UserLocalServiceUtil.java:3417)
08:07:13,964 ERROR [stderr] (http--0.0.0.0-8080-1) at com.liferay.portal.service.UserLocalServiceUtil.getBeanIdentifier(UserLocalServiceUtil.java:1004)
08:07:13,964 ERROR [stderr] (http--0.0.0.0-8080-1) at com.fsu.unired.alarmapp.thrift.implemented.UserAuthenticationHandler.signIn(UserAuthenticationHandler.java:33)
08:07:13,965 ERROR [stderr] (http--0.0.0.0-8080-1) at com.fsu.unired.alarmapp.thrift.generated.UserAuthenticationService$Processor$signIn.getResult(UserAuthenticationService.java:253)
08:07:13,965 ERROR [stderr] (http--0.0.0.0-8080-1) at com.fsu.unired.alarmapp.thrift.generated.UserAuthenticationService$Processor$signIn.getResult(UserAuthenticationService.java:1)
08:07:13,966 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:39)
08:07:13,966 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:39)
08:07:13,966 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.thrift.server.TServlet.doPost(TServlet.java:83)
08:07:13,967 ERROR [stderr] (http--0.0.0.0-8080-1) at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
08:07:13,967 ERROR [stderr] (http--0.0.0.0-8080-1) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
08:07:13,968 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
08:07:13,968 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
08:07:13,969 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
08:07:13,969 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
08:07:13,970 ERROR [stderr] (http--0.0.0.0-8080-1) at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
08:07:13,970 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
08:07:13,971 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
08:07:13,971 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
08:07:13,972 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
08:07:13,972 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
08:07:13,972 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
08:07:13,973 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
08:07:13,973 ERROR [stderr] (http--0.0.0.0-8080-1) at java.lang.Thread.run(Thread.java:745)
08:07:13,974 ERROR [stderr] (http--0.0.0.0-8080-1) com.liferay.portal.kernel.bean.BeanLocatorException: BeanLocator has not been set
08:07:13,974 ERROR [stderr] (http--0.0.0.0-8080-1) at com.liferay.portal.kernel.bean.PortalBeanLocatorUtil.locate(PortalBeanLocatorUtil.java:82)
08:07:13,974 ERROR [stderr] (http--0.0.0.0-8080-1) at com.liferay.portal.service.UserLocalServiceUtil.getService(UserLocalServiceUtil.java:3417)
08:07:13,975 ERROR [stderr] (http--0.0.0.0-8080-1) at com.liferay.portal.service.UserLocalServiceUtil.getBeanIdentifier(UserLocalServiceUtil.java:1004)
08:07:13,975 ERROR [stderr] (http--0.0.0.0-8080-1) at com.fsu.unired.alarmapp.thrift.implemented.UserAuthenticationHandler.signIn(UserAuthenticationHandler.java:33)
08:07:13,975 ERROR [stderr] (http--0.0.0.0-8080-1) at com.fsu.unired.alarmapp.thrift.generated.UserAuthenticationService$Processor$signIn.getResult(UserAuthenticationService.java:253)
08:07:13,976 ERROR [stderr] (http--0.0.0.0-8080-1) at com.fsu.unired.alarmapp.thrift.generated.UserAuthenticationService$Processor$signIn.getResult(UserAuthenticationService.java:1)
08:07:13,976 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:39)
08:07:13,976 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:39)
08:07:13,977 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.thrift.server.TServlet.doPost(TServlet.java:83)
08:07:13,977 ERROR [stderr] (http--0.0.0.0-8080-1) at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
08:07:13,977 ERROR [stderr] (http--0.0.0.0-8080-1) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
08:07:13,977 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
08:07:13,978 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
08:07:13,978 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
08:07:13,978 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
08:07:13,979 ERROR [stderr] (http--0.0.0.0-8080-1) at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
08:07:13,980 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
08:07:13,980 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
08:07:13,980 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
08:07:13,981 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
08:07:13,981 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
08:07:13,981 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
08:07:13,981 ERROR [stderr] (http--0.0.0.0-8080-1) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
08:07:13,982 ERROR [stderr] (http--0.0.0.0-8080-1) at java.lang.Thread.run(Thread.java:745)
I really don't come any further. I also looked at com.liferay.portal.security.auth but cannot find any classes. I just want a method that i can call that checks if a user is registered.
Here is my Code that is running on the servlet.
import org.apache.thrift.TException;
import com.fsu.unired.alarmapp.thrift.generated.User;
import com.fsu.unired.alarmapp.thrift.generated.UserAuthenticationService;
import com.liferay.portal.service.UserLocalServiceUtil;
public class UserAuthenticationHandler implements UserAuthenticationService.Iface {
@Override
public User signIn(String forceMail, String password){
System.out.println("signIn called...");
User usr = new User();
System.out.println("returning user:" + usr.toString());
try {
int status = com.liferay.portal.service.UserLocalServiceUtil.authenticateByEmailAddress(0, forceMail, password, null,null, null);
System.out.println("Status : " +status);
switch(status) {
case -1: return null;
case 1: System.out.println("case 1");
com.liferay.portal.model.User liferayUser = UserLocalServiceUtil.getUserByEmailAddress(0, forceMail);
System.out.println(liferayUser.toString());
}
return usr;
}
catch(Exception e) {
e.printStackTrace();
}
return usr;
}
I have the portal-service.jar included. And here is my web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>alarm-thrift-servlet</display-name>
<servlet>
<description></description>
<display-name>ThriftServlet</display-name>
<servlet-name>ThriftServlet</servlet-name>
<servlet-class>com.fsu.unired.alarmapp.servlet.ThriftServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ThriftServlet</servlet-name>
<url-pattern>/ThriftServlet</url-pattern>
</servlet-mapping>
</web-app>
I'm assuming that you're deploying a plain web application - you might want to try a Liferay-web plugin. This is very similar but is aware of Liferay being present and might initialize the infrastructure that Liferay's API needs. Otherwise you'll have to do this initialization yourself.