Java.Null.Pointer.Exception

51 views
Skip to first unread message

Leonardo Rafael Morastoni

unread,
Nov 10, 2010, 6:21:53 AM11/10/10
to OpenSocial Client Libraries
Hello!

I really don't understand why I'm getting a
Java.Null.Pointer.Exception in the code below. I'm using
OAuth2LeggedScheme, and I use some code of ThirdLeg example. I'm
getting Java.Null.Pointer.Exception on this line: Welcome, <b><%=
viewer.getDisplayName() %> (ID: <%= viewer.getId() %>)</b>!
I think that all is correct, so I need to do anything else?

<%@ page import="org.opensocial.Client"%>
<%@ page import="org.opensocial.providers.Provider"%>
<%@ page import="org.opensocial.providers.OrkutProvider"%>
<%@ page import="org.opensocial.auth.AuthScheme"%>
<%@ page import="org.opensocial.auth.OAuth2LeggedScheme"%>
<%@ page import="org.opensocial.Request"%>
<%@ page import="org.opensocial.Response"%>
<%@ page import="org.opensocial.services.PeopleService"%>
<%@ page import="org.opensocial.models.Person" %>

<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>

<%
Person viewer = null;
List<Person> friends = null;
Provider provider = new OrkutProvider();
AuthScheme scheme = new OAuth2LeggedScheme("orkut.com:CONSUMER",
"SECRET");
Client client = new Client(provider, scheme);
try {
Map<String, Request> requests = new HashMap<String, Request>();
requests.put("friends", PeopleService.getFriends());
requests.put("viewer", PeopleService.getViewer());

Map<String, Response> responses = client.send(requests);
friends = responses.get("friends").getEntries();
viewer = responses.get("viewer").getEntry();
} catch (Exception e) {
}

%>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=UTF-8">
<title>Hello </title>
</head>

<body>
<h1>profile.jsp</h1>
<div>
Welcome, <b><%= viewer.getDisplayName() %> (ID: <%=
viewer.getId() %>)</b>!
</div>
<div>
<h4>Friends:</h4>
<ul>
<%
for (Person friend : friends) {
out.println("<li>" + friend.getDisplayName() + " (ID: " +
friend.getId() + ")</li>");
}
%>
</ul>
</div>
</body>
</html>


Thanks,

Leonardo.

Leonardo Rafael Morastoni

unread,
Nov 12, 2010, 10:25:19 AM11/12/10
to OpenSocial Client Libraries
Someone can Help me please?

On Nov 10, 8:21 am, Leonardo Rafael Morastoni <leomo...@gmail.com>
wrote:

Robson Dantas

unread,
Nov 12, 2010, 10:27:57 AM11/12/10
to opensocial-cl...@googlegroups.com
Did you hide the keys or just forgot to setup here ?
AuthScheme scheme = new OAuth2LeggedScheme("orkut.com:CONSUMER", "SECRET");

Robson Dantas

2010/11/12 Leonardo Rafael Morastoni <leom...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "OpenSocial Client Libraries" group.
To post to this group, send email to opensocial-cl...@googlegroups.com.
To unsubscribe from this group, send email to opensocial-client-l...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/opensocial-client-libraries?hl=en.


Leonardo Rafael Morastoni

unread,
Nov 12, 2010, 12:20:06 PM11/12/10
to opensocial-cl...@googlegroups.com
I hide the keys.
I think that is connecting becaus whet i put provider.getName() it returns, but I don't if it really connects or just get the info provider.

2010/11/12 Robson Dantas <biu.d...@gmail.com>



--
Leonardo Rafael Morastoni
Microsoft Certified Professional
Fone: (47) 8417-3306/(47) 8834-8415
"Não venho desafiar ninguém... Só a mim. Ser hoje melhor que ontem, isso sim é um desafio de verdade. Por isso vale à pena suar, ir para o sacrifício. O problema é que, todo dia, no final do treino, mesmo tendo vencido, sei que amanhã vou querer ser melhor do que fui hoje."


Leonardo Rafael Morastoni

unread,
Nov 12, 2010, 12:24:05 PM11/12/10
to opensocial-cl...@googlegroups.com
Other question is....OAuth2LeggedScheme works out of google enviroment like OAuth3LeggedScheme, or I just can test it on orkut by example.
I have this test and a gadget on orkut that show the same error
Link to gadget: http://www.orkut.com.br/Main#Application?uid=13006305923742952829&appId=373590006723

Thanks for return Robson.

Leonardo Rafael Morastoni

unread,
Nov 12, 2010, 1:08:46 PM11/12/10
to opensocial-cl...@googlegroups.com
More information:

Enviroment: Eclipse Helios 64 bits (Eclipse Java EE IDE for Web Developers.)
Web Server : Tomcat 7.0 or Tomcat 6.0
Libs: commons-codec-1.3.jar
        json_simple-1.1.jar
        junit-4.5.jar
        oauth-20090825.jar
        opensocial-1.0.jar
I try with google app engine for eclipse and without it too.

Leonardo Rafael Morastoni

unread,
Nov 12, 2010, 4:29:22 PM11/12/10
to opensocial-cl...@googlegroups.com
Except for the hidden keys, somone find anything wrong with this code?
I try all I can and know to solve this problem :(

Thanks.

Leonardo Rafael Morastoni

unread,
Nov 13, 2010, 7:25:22 AM11/13/10
to opensocial-cl...@googlegroups.com
Good Morning!

Someone knows if this tutorial works?

http://code.google.com/p/opensocial-java-client/source/browse/wiki/TwoLeggedOAuthJava.wiki

I do it, not creting manually the project, but using eclipse and I getting connection refused. To me it is other way to solve my problem.

Leonardo Rafael Morastoni

unread,
Nov 13, 2010, 3:28:57 PM11/13/10
to opensocial-cl...@googlegroups.com
Solved problem, i put my real opensocial id on it, and it works. I was getting uid fom profile link
Use this gadget to get ur opensocial id

http://www.orkut.com.br/Main#Application?uid=13006305923742952829&appId=919907497851&rl=ls

2010/11/13 Leonardo Rafael Morastoni <leom...@gmail.com>
Reply all
Reply to author
Forward
0 new messages