SilverHoodCorp / gdata-java-client

Automatically exported from code.google.com/p/gdata-java-client
Apache License 2.0
0 stars 0 forks source link

GData java client still uses long-deprecated google-collect jar #344

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It is very dangerous to use google-collect.jar, as if a user ends up with that 
and guava on her classpath at the same time, very unpredictable and strange 
errors can result.

google-collect has been officially deprecated for a year now, but Guava is a 
full-compatible superset of its functionality.

Original issue reported on code.google.com by kevin...@gmail.com on 30 May 2011 at 6:27

GoogleCodeExporter commented 9 years ago
Duplicated in Issue 347 
http://code.google.com/p/gdata-java-client/issues/detail?id=347
Agree, this cost me a couple hours of time.

Original comment by mark.sie...@gmail.com on 6 Jun 2011 at 9:40

GoogleCodeExporter commented 9 years ago
And now with the release of guava 11 we hit on NoSuchMethodErrors:

guava 11 has removed:

- public static <E> ImmutableSet<E> of(E[] elements)

See 
http://docs.guava-libraries.googlecode.com/git-history/v11.0/jdiff/changes/com.g
oogle.common.collect.ImmutableSet.html

A method that is used in:

- com/google/gdata/wireformats/AltFormat.java

See 
http://code.google.com/p/gdata-java-client/source/browse/trunk/java/src/com/goog
le/gdata/wireformats/AltFormat.java#399

Which leads to an exception like this:
                              Caused by: java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.of([Ljava/lang/Object;)Lcom/google/common/collect/ImmutableSet;
                                at com.google.gdata.wireformats.AltFormat$Builder.setAcceptableTypes(AltFormat.java:399)
                                at com.google.gdata.wireformats.AltFormat$Builder.setAcceptableXmlTypes(AltFormat.java:387)
                                at com.google.gdata.wireformats.AltFormat.<clinit>(AltFormat.java:49)
                                at com.google.gdata.client.Service.<clinit>(Service.java:558)

Actually it makes me wonder, since the current gdata download package shows 
"google-collect-1.0-rc1.jar" as dependency in the deps folder, but the google 
collection "rc1" had no method ImmutableSet.of(E[] elements). 

See 
http://grepcode.com/file/repo1.maven.org/maven2/com.google.collections/google-co
llections/1.0-rc1/com/google/common/collect/ImmutableSet.java?av=f

So i guess, the developers use internally an (now older) version of guava? And 
will probably hit the same problem as well, if they change to guava 11?

Solution is by the way to change to ImmutableSet.copyOf(E[] elements)

Original comment by okris...@gmail.com on 5 Jan 2012 at 7:45

GoogleCodeExporter commented 9 years ago
Same for me, I've wasted an hour or two already, please update to use guava 
instead of old google-collections

Original comment by burn...@gmail.com on 19 Feb 2012 at 1:14

GoogleCodeExporter commented 9 years ago
Same for me.

Original comment by gabrielmoreira on 24 Feb 2012 at 6:15

GoogleCodeExporter commented 9 years ago
guava 11 and later are still compatible to google-collections api 1.0

It would just help, if gdata would definitly rely on the google-collections api 
1.0 and not on "1.0-rc1". 

Then everyone is happy again.

No need to make gdata compatible with guava everytime.

Original comment by okris...@gmail.com on 24 Feb 2012 at 6:46

GoogleCodeExporter commented 9 years ago
Then again, if you're upgrading anyway, why not bring it up to the latest? That 
is current 11.0.2, if I'm not mistaken.

Original comment by raymond....@gmail.com on 24 Feb 2012 at 6:55

GoogleCodeExporter commented 9 years ago
orkis: what?  No.  1.0-rc1 to 1.0 is not going to fix this.  We have started 
removing APIs that have been deprecated for >6 consecutive major Guava releases.

Original comment by kevin...@gmail.com on 24 Feb 2012 at 7:10

GoogleCodeExporter commented 9 years ago
Well, gdata right now claims to use google-collection api 1.0, which is just 
not true. So it should be fixed first.

The thing with gdata depending on guava-XX is, that it can break with other 
libraries in my app, which also depend on guava, but on a different version.

One depends on guava-11, the other on guava-10, but guava-11 does not claim, 
its compatible with guava-10. Therefore my whole upgrade process stops. I must 
wait, till all libraries have grown to the same guava-version.

Therefore i like libraries, which depend on a stable API. While in my app, in a 
controlled environment, i am free to go with whatever guava-version i like, as 
long its compatible with that stable API as well.

Etc pp :D

Original comment by okris...@gmail.com on 24 Feb 2012 at 7:22

GoogleCodeExporter commented 9 years ago
@kevin, as far as i have seen, gdata uses a method, that is in 1.0-rc1, but was 
not in 1.0. But that method has been added again in guava, and has been removed 
finally in guava-11. So gdata needs to compile against 1.0, then it would also 
work within guava-11.

"Guava contains a strictly compatible superset of the old, deprecated Google 
Collections Library"

Why that would not work?

Original comment by okris...@gmail.com on 24 Feb 2012 at 7:30

GoogleCodeExporter commented 9 years ago
Libraries evolve, such is life. It's ugly, but straightforward enough to use 
reflection to determine whether google-collections api is in use, or the 
guava-11+ version, and call appropriate methods based on the result. Does gdata 
project accept patches?

Original comment by dvrya...@gmail.com on 12 Mar 2012 at 5:06

GoogleCodeExporter commented 9 years ago
When can we expect this to be fixed, if ever? It's irritating that our project 
can't use the latest Guava simply because it also uses GData.

Original comment by bello...@gmail.com on 23 Mar 2012 at 6:19

GoogleCodeExporter commented 9 years ago
I switched to guava-r07.jar located at 
http://code.google.com/p/guava-libraries/downloads/detail?name=guava-r07.zip&can
=4&q=

This got me past
ContactsService service = new ContactsService(""); 

Jar's in use:
Default Eclipse plugin jar's

gdata-base-1.0.jar
gdata-client-1.0.jar
gdata-contacts-3.0.jar
gdata-core-1.0.jar
gdata-media-1.0.jar
guava-r07.jar

Apache (servlet-api.jar)
JavaMail (mail.jar)
JavaBeans Activation Framework (activation.jar)

Original comment by obrien....@gmail.com on 26 Mar 2012 at 2:14

GoogleCodeExporter commented 9 years ago
This issue has been fixed in release 1.47.0

Original comment by ala...@google.com on 17 Apr 2012 at 3:12

GoogleCodeExporter commented 9 years ago
I am using Google Adwords apI where the version of guava jar is 13.0.....When I 
replace guava-11.0.2 (which I used for Contacts) with guava-13.0, I get the 
above mentioned error again... 
Caused by: java.lang.NoSuchMethodError: 
com.google.common.collect.ImmutableSet.of([Ljava/lang/Object;)Lcom/google/common
/collect/ImmutableSet;

Original comment by vjchauha...@gmail.com on 10 Sep 2012 at 9:36

GoogleCodeExporter commented 9 years ago
I faced same issue when added guava 13.0 for Google Drive API

Original comment by c.moradi...@gmail.com on 21 Dec 2012 at 7:31

GoogleCodeExporter commented 9 years ago
currently wasted 4hrs and counting just trying to have project that uses Google 
Spreadsheets, gdata-client libs and Google Calendars API.

all due to guava lib not being a true replacement for collections.jar as far as 
I can see.

Please sort this.

Original comment by doug.stoddart on 6 Mar 2013 at 11:38

GoogleCodeExporter commented 9 years ago
Waster 3 hours because of that :
NoSuchMethodError : google common ImmutableSet.copyOf

See more at :
http://stackoverflow.com/questions/16475015/nosuchmethoderror-google-common-immu
tableset-copyof

I had to switch to guava version : guava-r07.jar I do not understand why is 
newest guava not compatible with google contacts api library...

Original comment by VichMar...@gmail.com on 12 May 2013 at 10:49

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
The above mentioned issues were also faced during environment set up and it was 
too difficult for me to trace them out. Step by step I eradicated all the 
errors.
I hope the following list of jar files will definitely help you..
------------------------------------------------
The Required library jars are as follows. 
---------------------------------------------
gdata-client-1.0.jar
gdata-core-1.0.jar
gdata-media-1.0.jar
gdata-youtube-2.0.jar
guava-11.0.2.jar
java-mail-1.4.4.jar
-------------------------

I am using the above mentioned library . Please make use of it ; because the 
ultimate aim is to get the YouTubeService Object. Check below for the code 
snippet.

package com.baba.test;
/*
 * Author : Somanath Nanda
 */
import java.net.MalformedURLException;
import java.net.URL;

import com.google.gdata.client.youtube.YouTubeQuery;
import com.google.gdata.client.youtube.YouTubeService;

public class Test {
    private static final String CLIENT_ID = "************************";
    private static final String DEVELOPER_KEY = "************************";
    public static void main(String[] args) throws MalformedURLException {
        // TODO Auto-generated method stub
        YouTubeService service = new YouTubeService(CLIENT_ID,DEVELOPER_KEY);
        service.setConnectTimeout(2000);
        YouTubeQuery query = new YouTubeQuery(new URL("http://gdata.youtube.com/feeds/api/videos"));
        query.setOrderBy(YouTubeQuery.OrderBy.VIEW_COUNT);
        query.setFullTextQuery("java code");
        query.setMaxResults(10);
        System.out.println("Service : "+service);
    }

}

Original comment by somanat...@gmail.com on 12 Oct 2013 at 6:47