フォーラム

ホーム » Liferay Portal » English » 3. Development

構造的に表示 平面上に表示 ツリー上に表示
スレッド [ 前へ | 次へ ]
toggle
Gopinath Guptha
PermissionChecker not initialized exception while invoking remote services
2012/05/28 23:27
答え

Gopinath Guptha

ランク: Junior Member

投稿: 25

参加年月日: 2010/08/10

最近の投稿

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
2012/05/29 0:24
答え

Nagendra Kumar Busam

ランク: Liferay Master

投稿: 653

参加年月日: 2009/07/07

最近の投稿

How you are trying to access? Brief about what you did exactly
Oliver Bayer
RE: PermissionChecker not initialized exception while invoking remote servi
2012/05/29 1:15
答え

Oliver Bayer

ランク: Liferay Master

投稿: 887

参加年月日: 2009/02/18

最近の投稿

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
2012/05/29 1:21
答え

Gopinath Guptha

ランク: Junior Member

投稿: 25

参加年月日: 2010/08/10

最近の投稿

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
2012/05/29 6:18
答え

Gopinath Guptha

ランク: Junior Member

投稿: 25

参加年月日: 2010/08/10

最近の投稿

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
2012/05/29 6:36
答え

Nagendra Kumar Busam

ランク: Liferay Master

投稿: 653

参加年月日: 2009/07/07

最近の投稿

Thank you very much for sharing emoticon
latha l
RE: PermissionChecker not initialized exception while invoking remote servi
2013/03/18 22:50
答え

latha l

ランク: New Member

投稿: 1

参加年月日: 2013/02/11

最近の投稿

Hi Gopinath,

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

Regards
Latha