Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Gopinath Guptha
PermissionChecker not initialized exception while invoking remote services
May 28, 2012 11:27 PM
Answer

Gopinath Guptha

Rank: Junior Member

Posts: 25

Join Date: August 10, 2010

Recent Posts

Hi,

I am facing a problem while invoking webservice methods remotely. I get the below error while using the "Portlet_Journal_JournalArticleService" on Liferay 6.1 community. Can someone provide me pointers on how to solve this problem?


05:58:16,183 ERROR [JournalArticleServiceSoap:171] com.liferay.portal.security.auth.PrincipalException: PermissionChecker not initialized
com.liferay.portal.security.auth.PrincipalException: PermissionChecker not initialized
at com.liferay.portal.service.base.PrincipalBean.getPermissionChecker(PrincipalBean.java:81)
at com.liferay.portlet.journal.service.impl.JournalArticleServiceImpl.getArticle(JournalArticleServiceImpl.java:183)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


Regards,
Nagendra Kumar Busam
RE: PermissionChecker not initialized exception while invoking remote servi
May 29, 2012 12:24 AM
Answer

Nagendra Kumar Busam

Rank: Liferay Master

Posts: 603

Join Date: July 7, 2009

Recent Posts

How you are trying to access? Brief about what you did exactly
Oliver Bayer
RE: PermissionChecker not initialized exception while invoking remote servi
May 29, 2012 1:15 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 870

Join Date: February 18, 2009

Recent Posts

Hi Gopinath,

afaik PrincipalException means that you're trying to access a secured service without being authenticated. I would guess you have to check your login.

HTH Oli
Gopinath Guptha
RE: PermissionChecker not initialized exception while invoking remote servi
May 29, 2012 1:21 AM
Answer

Gopinath Guptha

Rank: Junior Member

Posts: 25

Join Date: August 10, 2010

Recent Posts

Hello Nagendra,

I first added the below two lines in the portal-ext.properties file to allow my ip.

axis.servlet.hosts.allowed=127.0.0.1,192.168.1.88
axis.servlet.https.required=false

In some posts, It is mentioned that the user needs to be provided permissions to invoke the webservices. I searched a bit, but could not find how to do that. So I used the credentials bruno/ bruno as the username (screenname) and password to invoke the webservices (assuming the user has complete privileges and permissions). Below is the code which I found in one of the blogs and I modified it a bit to invoke the webservices.

Regards,
Gopinath


----------------------------------------------------------------------------------

package example;

import mypackage.JournalArticleServiceSoap;
import mypackage.JournalArticleServiceSoapServiceLocator;
import mypackage.JournalArticleSoap;

import java.net.MalformedURLException;
import java.net.URL;

public class HelloJournal
{
public static void main(String[] args)
{
try
{
JournalArticleServiceSoapServiceLocator service = new JournalArticleServiceSoapServiceLocator();

JournalArticleServiceSoap journalService = service.getPortlet_Journal_JournalArticleService(getURL("Portlet_Journal_JournalArticleService"));

JournalArticleSoap journal = journalService.getArticle(19, "10864");
}
catch (Exception e)
{
e.printStackTrace();
}
}

private static URL getURL(String serviceName) throws MalformedURLException
{
String url = "http://192.168.1.5:8080";
String screenName = "bruno";
String password = "bruno";

int pos = url.indexOf("://");
String protocol = url.substring(0, pos + 3);
String host = url.substring(pos + 3, url.length());

StringBuilder sb = new StringBuilder();
sb.append(protocol);
sb.append(screenName);
sb.append(":");
sb.append(password);
sb.append("@");
sb.append(host);
sb.append("/api/axis/");
sb.append(serviceName);

return new URL(sb.toString());
}
}
Gopinath Guptha
RE: PermissionChecker not initialized exception while invoking remote servi
May 29, 2012 6:18 AM
Answer

Gopinath Guptha

Rank: Junior Member

Posts: 25

Join Date: August 10, 2010

Recent Posts

Hi,

I was able to solve this. Below were the changes I did.

1. The path to the service was wrong. The correct one is /api/secure/axis/...

2. The webservice required me to use basic authentication. Below is the code I used -

JournalArticleServiceSoapServiceLocator service = new JournalArticleServiceSoapServiceLocator();
JournalArticleServiceSoap journalService = service.getPortlet_Journal_JournalArticleService(getURL("Portlet_Journal_JournalArticleService"));
((Stub)journalService)._setProperty(Call.USERNAME_PROPERTY, "bruno@7cogs.com");
((Stub)journalService)._setProperty(Call.PASSWORD_PROPERTY, "bruno");
JournalArticleSoap journal = journalService.getArticle(19, "10864");
System.out.println(journal.getContent());

3. The username is in fact the email of the user and not the screen name as suggested in other posts.

Whatever I did, invoking the services using the below url never worked -
http://<usrename>:<password>@<host>:<port>/api/secure/axis/Portlet_Journal_JournalArticleService

Regards,
Gopinath
Nagendra Kumar Busam
RE: PermissionChecker not initialized exception while invoking remote servi
May 29, 2012 6:36 AM
Answer

Nagendra Kumar Busam

Rank: Liferay Master

Posts: 603

Join Date: July 7, 2009

Recent Posts

Thank you very much for sharing emoticon
latha l
RE: PermissionChecker not initialized exception while invoking remote servi
March 18, 2013 10:50 PM
Answer

latha l

Rank: New Member

Posts: 1

Join Date: February 11, 2013

Recent Posts

Hi Gopinath,

Thank you for sharing Gopinath. emoticon
I was struggling with this for 3 days!!!...

Regards
Latha