【问题标题】:Error while LinkedIn integration in java在 Java 中集成 LinkedIn 时出错
【发布时间】:2013-12-18 10:32:46
【问题描述】:

我正在尝试将 LinkedIn 集成到我的 Java Web 应用程序中,但是当我尝试从 linkedin 获取 Person 对象时出现以下异常。 授权/登录/获取访问令牌的过程运行良好且成功。 但是在访问linkedin对象时我遇到了一些问题。

下面是sn-p的代码:

LinkedInRequestToken requestToken = (LinkedInRequestToken) req.getSession().getAttribute("requestToken");
LinkedInOAuthService oauthService = LinkedInOAuthServiceFactory.getInstance().createLinkedInOAuthService(appkey, secretKey);
LinkedInAccessToken accessToken = oauthService.getOAuthAccessToken(requestToken, oauth_verifier);

LinkedInApiClientFactory factory = LinkedInApiClientFactory.newInstance(appId, secretKey);
LinkedInApiClient client = factory.createLinkedInApiClient(accessToken.getToken(), accessToken.getTokenSecret());

直到代码工作正常,但是当我说,

Person person = client.getProfileForCurrentUser();

我遇到了这个异常:

com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
Package "com.google.code.linkedinapi.schema" is missing jaxb.properties file.
Have you copied this from the generated source directory or include it in the classpath?
this problem is related to the following location:
at com.google.code.linkedinapi.schema.ObjectFactory

我正在为 LinkedIn API 使用以下依赖项

<dependency>
    <groupId>com.googlecode.linkedin-j</groupId>
    <artifactId>linkedin-j-core</artifactId>
    <version>1.0.416</version>
</dependency>

【问题讨论】:

    标签: java annotations linkedin linkedin-j


    【解决方案1】:

    版本 1.0.416 缺少 jax.properties 文件。

    见:https://code.google.com/p/linkedin-j/issues/detail?id=53

    我遵循的步骤: 1.签出src并检索core/src/main/java/com/google/code/linkedinapi/schema/jaxb.properties 2. mkdir -p mkdir -p src/main/resources/com/google/code/linkedinapi/schema/
    cp jaxb.properties src/main/resources/com/google/code/linkedinapi/schema 3. 如果你只是将它放在当前路径中,它可能会起作用,但这个修复对我有用。

    【讨论】:

      【解决方案2】:

      除了maven,你还需要添加linkedin-j jar 来构建路径。这是下载jar的链接http://www.java2s.com/Code/Jar/l/Downloadlinkedinjjar.htm@milind_db

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-11-23
        • 2011-09-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多