[seam-issues] [JBoss JIRA] (SEAMSOCIAL-32) twitter.updateStatus() error: Unable to resolve any beans for Types: interface org.jboss.seam.social.oauth.OAuthProvider

Hendy Irawan (JIRA) jira-events at lists.jboss.org
Mon Feb 13 05:02:01 EST 2012


    [ https://issues.jboss.org/browse/SEAMSOCIAL-32?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12665985#comment-12665985 ] 

Hendy Irawan commented on SEAMSOCIAL-32:
----------------------------------------

Thank you Tomas, as of 12 Feb 2012 the Readme in https://github.com/seam/social only mentions it like this:

{code}
Create an OAuthService bean thru Seam configuration (in bean.xml)

Due to limitation of Solder XML configuration you'll have to provide the implementation class of the bean in the configuration file Here is an example of such a configuration :

<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:s="urn:java:ee"
xmlns:o="urn:java:org.jboss.seam.social:org.jboss.seam.social.oauth:org.jboss.seam.social.twitter.jackson">
  <o:TwitterServiceJackson>
      <s:modifies />
      <o:OAuthApplication apiKey="FQzlQC49UhvbMZoxUIvHTQ"
          apiSecret="VQ5CZHG4qUoAkUUmckPn4iN4yyjBKcORTW0wnok4r1k"
          callback="http://localhost:8080/social-web-client/callback.jsf" />
  </o:TwitterServiceJackson>
</beans>

Api Key and Api secret is provided by the service you want to consume (here Twitter). You can use the values above since they're coming from "Seam Social" Twitter application. Callback depends on your application : it's the URL that will collect OAuth verifier

Inject an OAuthService bean with one of the following ways :

Using the Interface of the service

@Named
@SessionScoped
public class mySessionBean implements Serializable {
    ...
    @Inject
    public TwitterService twitter;
    ...
}
{code}

However it doesn't seem to be the problem.

My app can get the TwitterService (TwitterServiceJackson) instance without any problem, however when calling a method there, it will in turn call getProvider() which will fail.

As you can see in the stacktrace snippet:
{code}
	at org.jboss.seam.social.oauth.OAuthServiceBase.getProvider(OAuthServiceBase.java:88) [seam-social-3.1.0.Final.jar:]
	at org.jboss.seam.social.oauth.OAuthServiceBase.sendSignedRequest(OAuthServiceBase.java:139) [seam-social-3.1.0.Final.jar:]
	at org.jboss.seam.social.twitter.jackson.TwitterServiceJackson.updateStatus(TwitterServiceJackson.java:97) [seam-social-twitter-3.1.0.Final.jar:]
	at org.jboss.seam.social.twitter.jackson.TwitterServiceJackson.updateStatus(TwitterServiceJackson.java:45) [seam-social-twitter-3.1.0.Final.jar:]
	at com.satukancinta.ui.admin.UserShowAdmin.publishTwitterStatus(UserShowAdmin.java:262) [classes:]
{code}

the error occurs after entering the TwitterServiceJackson implementation, which means TwitterServiceJackson is injected correctly.
                
> twitter.updateStatus() error: Unable to resolve any beans for Types: interface org.jboss.seam.social.oauth.OAuthProvider
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: SEAMSOCIAL-32
>                 URL: https://issues.jboss.org/browse/SEAMSOCIAL-32
>             Project: Seam Social
>          Issue Type: Bug
>          Components: Twitter
>    Affects Versions: 3.1.0.Final
>            Reporter: Hendy Irawan
>            Assignee: Antoine Sabot-Durand
>
> I configured beans.xml like :
> {code}
> <o:TwitterServiceJackson>
> 	<s:modifies />
> 	<o:OAuthApplication apiKey="****"
> 		apiSecret="****" callback="http://ceefour.annafi:8080/satukancinta-web/callback.jsf" />
> </o:TwitterServiceJackson>
> {code}
> But this code:
> {code}
> @Inject private TwitterService twitter;
> public void publishTwitterStatus() {
> 	String message = getFbStatusMessage();
> 	log.debug("Updating Twitter status: {}", message);
> 	twitter.updateStatus(message);
> }
> {code}
> causes:
> {code}
> Caused by: javax.faces.el.EvaluationException: org.jboss.weld.exceptions.UnsatisfiedResolutionException: WELD-001308 Unable to resolve any beans for Types: [interface org.jboss.seam.social.oauth.OAuthProvider]; Bindings: [@javax.enterprise.inject.Any(), @org.jboss.seam.social.Twitter()]
> 	at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
> 	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
> 	... 30 more
> Caused by: org.jboss.weld.exceptions.UnsatisfiedResolutionException: WELD-001308 Unable to resolve any beans for Types: [interface org.jboss.seam.social.oauth.OAuthProvider]; Bindings: [@javax.enterprise.inject.Any(), @org.jboss.seam.social.Twitter()]
> 	at org.jboss.weld.manager.BeanManagerImpl.getBean(BeanManagerImpl.java:707) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
> 	at org.jboss.weld.bean.builtin.InstanceImpl.get(InstanceImpl.java:96) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
> 	at org.jboss.seam.social.oauth.OAuthServiceBase.getProvider(OAuthServiceBase.java:88) [seam-social-3.1.0.Final.jar:]
> 	at org.jboss.seam.social.oauth.OAuthServiceBase.sendSignedRequest(OAuthServiceBase.java:139) [seam-social-3.1.0.Final.jar:]
> 	at org.jboss.seam.social.twitter.jackson.TwitterServiceJackson.updateStatus(TwitterServiceJackson.java:97) [seam-social-twitter-3.1.0.Final.jar:]
> 	at org.jboss.seam.social.twitter.jackson.TwitterServiceJackson.updateStatus(TwitterServiceJackson.java:45) [seam-social-twitter-3.1.0.Final.jar:]
> 	at com.satukancinta.ui.admin.UserShowAdmin.publishTwitterStatus(UserShowAdmin.java:262) [classes:]
> 	at com.satukancinta.ui.admin.UserShowAdmin$Proxy$_$$_WeldClientProxy.publishTwitterStatus(UserShowAdmin$Proxy$_$$_WeldClientProxy.java) [classes:]
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.7.0_147-icedtea]
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [:1.7.0_147-icedtea]
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [:1.7.0_147-icedtea]
> 	at java.lang.reflect.Method.invoke(Method.java:601) [:1.7.0_147-icedtea]
> 	at org.apache.el.parser.AstValue.invoke(AstValue.java:262) [jbossweb-7.0.7.Final.jar:]
> 	at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) [jbossweb-7.0.7.Final.jar:]
> 	at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:39) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
> 	at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
> 	at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
> 	at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
> 	... 31 more
> {code}
> I tried to provide my own OAuthSession but doesn't work: (because the access token is already stored, there's no need to re-authorize every time)
> {code}
> @Produces @RequestScoped @Twitter public OAuthSession getTwitterSession() {
> 	OAuthSessionImpl session = new OAuthSessionImpl(Twitter.class.cast(Annotation.class));
> 	session.setAccessToken(new OAuthToken() {
> 		
> 		@Override
> 		public String getToken() {
> 			return userView.getUser().getTwitterAccessToken();
> 		}
> 		
> 		@Override
> 		public String getSecret() {
> 			return userView.getUser().getTwitterAccessTokenSecret();
> 		}
> 	});
> 	return session;
> }
> {code}
> I can get the Twitter instance but cannot do anything with it.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the seam-issues mailing list