Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
Gopinath Guptha
PermissionChecker not initialized exception while invoking remote services
28 maggio 2012 23.27
Risposta

Gopinath Guptha

Punteggio: Junior Member

Messaggi: 25

Data di Iscrizione: 10 agosto 2010

Messaggi recenti

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
29 maggio 2012 0.24
Risposta

Nagendra Kumar Busam

Punteggio: Liferay Master

Messaggi: 619

Data di Iscrizione: 7 luglio 2009

Messaggi recenti

How you are trying to access? Brief about what you did exactly
Oliver Bayer
RE: PermissionChecker not initialized exception while invoking remote servi
29 maggio 2012 1.15
Risposta

Oliver Bayer

Punteggio: Liferay Master

Messaggi: 870

Data di Iscrizione: 18 febbraio 2009

Messaggi recenti

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
29 maggio 2012 1.21
Risposta

Gopinath Guptha

Punteggio: Junior Member

Messaggi: 25

Data di Iscrizione: 10 agosto 2010

Messaggi recenti

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
29 maggio 2012 6.18
Risposta

Gopinath Guptha

Punteggio: Junior Member

Messaggi: 25

Data di Iscrizione: 10 agosto 2010

Messaggi recenti

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
29 maggio 2012 6.36
Risposta

Nagendra Kumar Busam

Punteggio: Liferay Master

Messaggi: 619

Data di Iscrizione: 7 luglio 2009

Messaggi recenti

Thank you very much for sharing emoticon
latha l
RE: PermissionChecker not initialized exception while invoking remote servi
18 marzo 2013 22.50
Risposta

latha l

Punteggio: New Member

Messaggi: 1

Data di Iscrizione: 11 febbraio 2013

Messaggi recenti

Hi Gopinath,

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

Regards
Latha