nourelhoudabenahmed / facebook-java-api

Automatically exported from code.google.com/p/facebook-java-api
0 stars 0 forks source link

Error on photos_getAlbums if there isn't a Profile Picture (with solution!) #264

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a user without profile picture and one photo album
2. Get the albums list with a JAXB client:
   PhotosGetAlbumsResponse
r=jaxbClient.photos_getAlbums(jaxbClient.users_getLoggedInUser());

What is the expected output? What do you see instead?
I expected to read the 2 album, the default Profile Pictures (without
pictures, i.e. size=0) and the other photo album.
The error is:
Fatal: tried to access class com.sun.xml.bind.v2.runtime.reflect.opt.Const
from class com.google.code.facebookapi.schema.Album$JaxbAccessorF_created
java.lang.IllegalAccessError: tried to access class
com.sun.xml.bind.v2.runtime.reflect.opt.Const from class
com.google.code.facebookapi.schema.Album$JaxbAccessorF_created
    at
com.google.code.facebookapi.schema.Album$JaxbAccessorF_created.set(FieldAccessor
_Long.java:59)
    at com.sun.xml.bind.v2.runtime.reflect.Accessor.receive(Accessor.java:171)
    at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.endElement(Unmarsh
allingContext.java:492)
    at
com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.endElement(SAXConnector.ja
va:145)
    at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Abstract
SAXParser.java:601)
    at
com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElemen
t(AbstractXMLDocumentParser.java:180)
    at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElemen
t(XMLNSDocumentScannerImpl.java:377)
    at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentC
ontentDriver.next(XMLDocumentFragmentScannerImpl.java:2747)
    at
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentS
cannerImpl.java:648)
    at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocum
entScannerImpl.java:140)
    at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocum
ent(XMLDocumentFragmentScannerImpl.java:510)
    at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configu
ration.java:807)
    at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configu
ration.java:737)
    at
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
    at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXPa
rser.java:1205)
    at
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXPar
serImpl.java:522)
    at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Unmarshalle
rImpl.java:211)
    at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Unmarshaller
Impl.java:184)
    at
javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerIm
pl.java:137)
    at
javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerIm
pl.java:194)
    at
com.google.code.facebookapi.FacebookJaxbRestClientBase.getResponsePOJO(FacebookJ
axbRestClientBase.java:144)
    at
com.google.code.facebookapi.FacebookJaxbRestClientBase.parseCallResult(FacebookJ
axbRestClientBase.java:169)
    at
com.google.code.facebookapi.FacebookJaxbRestClient.photos_getAlbums(FacebookJaxb
RestClient.java:50)

What version of the product are you using? On what operating system?
3.0.2-SNAPSHOT

Please provide any additional information below.
I found the solution. 
The returned XML have NULL value for "created" and "modified" for the
Profile Pictures album:
<?xml version="1.0" encoding="UTF-8"?>
<photos_getAlbums_response xmlns="http://api.facebook.com/1.0/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://api.facebook.com/1.0/
http://api.facebook.com/1.0/facebook.xsd" list="true">
  <album>
    <aid>10000077035532_-3</aid>
    <cover_pid>0</cover_pid>
    <owner>1000007703532</owner>
    <name>Profile Pictures</name>
    <created xsi:nil="true"/>
    <modified xsi:nil="true"/>
    <description/>
    <location/>
    <link>http://www.facebook.com/album.php?aid=-3&amp;id=1000007035532</link>
    <edit_link>http://www.facebook.com/editphoto.php?aid=-3</edit_link>
    <size>0</size>
    <visible>everyone</visible>
    <type>profile</type>
    <object_id>0</object_id>
    <modified_major xsi:nil="true"/>
  </album>
  <album>
    <aid>1000007035532_727</aid>
    <cover_pid>1000007035532_9152</cover_pid>
    <owner>100000477035532</owner>
    <name>OnlyOne</name>
    <created>1257869719</created>
    <modified>1257869744</modified>
    <description/>
    <location>Disperazione</location>
    <link>http://www.facebook.com/album.php?aid=727&amp;id=1000007035532</link>
    <edit_link>http://www.facebook.com/editphoto.php?aid=727</edit_link>
    <size>1</size>
    <visible>custom</visible>
    <type>normal</type>
    <object_id>1003856653997</object_id>
    <modified_major>1257869744</modified_major>
  </album>
</photos_getAlbums_response>

Probably the schema.xsd have to be updated for the "album" type to:
<xsd:element name="created" nillable="true" type="time" />
<xsd:element name="modified" nillable="true" type="time" />
(add NILLABLE property set to TRUE)

Original issue reported on code.google.com by giovanni...@gmail.com on 12 Nov 2009 at 11:57

GoogleCodeExporter commented 8 years ago
I have seen this same issue:
java.lang.IllegalAccessError: com/sun/xml/bind/v2/runtime/reflect/opt/Const

Looks like it is this issue: 
https://jaxb.dev.java.net/issues/show_bug.cgi?id=490

Forcing the use of jaxb 2.2 seemed to do the trick:

<dependency>
      <groupId>com.google.code.facebookapi</groupId>
      <artifactId>facebook-java-api</artifactId>
      <version>3.0.3</version>
      <exclusions>
        <exclusion>
          <groupId>com.sun.xml.bind</groupId>
          <artifactId>jaxb-impl</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>com.google.code.facebookapi</groupId>
      <artifactId>facebook-java-api-schema</artifactId>
      <version>3.0.3</version>
      <exclusions>
        <exclusion>
          <groupId>com.sun.xml.bind</groupId>
          <artifactId>jaxb-impl</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.2</version>
    </dependency>

If this is the case, the schema pom should really just be updated to use 2.2...

Original comment by jasper.r...@gmail.com on 16 Mar 2010 at 8:05