Installing facebook4GWT using Maven2 and Ant

1) Download the newest (facebook4gwt-1.0.4.jar) from:


2) In Terminal change directory to your download location

3) Install the jar in your local Maven2 REPO:

mvn install:install-file -DgroupId=com.reveregroup.gwt -DartifactId=facebook4gwt -Dversion=1.0.4 -Dpackaging=jar -Dfile=facebook4gwt-1.0.4.jar

4) Verify that the jar is installed correctly:

uki@Uki:~/.m2/repository/com/reveregroup/gwt/facebook4gwt/1.0.4 $ ls
facebook4gwt-1.0.4.jar

5) Update your pom.xml (Maven2) with the dependency:

<dependency>
<groupId>com.reveregroup.gwt</groupId>
<artifactId>facebook4gwt</artifactId>
<version>1.0.4</version>
</dependency>

6) Run Ant (build.xml) to bring the jars to your project:

       <target name="copy_maven_jars_filtered_resources">
<echo>Maven Executable: ${MAVEN_EXEC}</echo>
<!-- resources:resources filters the files in the resources directory and copies them to target/classes -->
<!-- dependency:copy-dependencies copies the dependencies to the target/dependency folder -->
<exec taskname="mvn war" dir="${basedir}"
executable="${MAVEN_EXEC}">
<arg line="clean resources:resources dependency:copy-dependencies -Dtarget=${TARGET}" />
</exec>
<delete dir="${GOOGLE_WAR}\\WEB-INF\\lib" />
<!-- copy the maven depenecies to the war/WEB-INF/lib folder -->
<copy todir="${GOOGLE_WAR}\\WEB-INF\\lib">
<fileset dir="${MAVEN_TARGET}\\dependency" />
</copy>
<!-- copy the filtered resources to the src folder -->
<copy todir="${GOOGLE_SRC}">
<fileset dir="${MAVEN_TARGET}\\classes" />
</copy>
</target>

7) Use the facebook4gwt API and send us the feedback












As an Amazon Associate I earn from qualifying purchases.

2 comments:

  1. Hi,
    I'm using this library to integrate facebook in my application. I run into problems when I try to authenticate a user on the server side. In the code, I call Facebook.init(FB_API_KEY); and use the sample code here to get things started and I get an error Caused by: java.lang.NoClassDefFoundError: com/reveregroup/gwt/facebook4gwt/Facebook.
    I do have the jar file in the classpath and I know it works because If I implement the user logging in and out on the client, in the onModuleLoad() method it works fine.
    Is there an issue with running facebook4gwt on the server side or something I may have missed?

    Thanks.

    ReplyDelete
  2. @Manners, there is not really an issue with servier side per se, but since the library uses native javascript, it can only work on the GWT client side, assuming you are trying to deploy to app engine. So yes, it should only work from an onModuleLoad() entry point. There are other libraries designed for server side deployment, but you will still need to use something like Facebook Connect from the client to establish a session. I am working on an integrated library for this purpose. I could use help if anyone is interested. http://code.google.com/p/facebook-gwt/

    ReplyDelete

Please be polite.

Post Scriptum

The views in this article are mine and do not reflect those of my employer.
I am preparing to cancel the subscription to the e-mail newsletter that sends my articles.
Follow me on:
X.com (Twitter)
LinkedIn
Google Scholar

My favorite quotations..


“A man should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.”  by Robert A. Heinlein

"We are but habits and memories we chose to carry along." ~ Uki D. Lucas


Popular Recent Posts

Most Popular Articles