Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6183191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:19:24+00:00 2026-05-24T01:19:24+00:00

I am getting a wierd problem and i am stuck on it for atleast

  • 0

I am getting a wierd problem and i am stuck on it for atleast 4 hours now. Actually i had written my code in a controller for testing but when i have moved the code to service i am getting a strange behaviour that the methods in service are not returning or may be methods that are calling them in the service only are not receiving .

class FacebookService implements InitializingBean, GroovyInterceptable {
def getUserLikes(def at){
List<String> listOfUrls = []
    String basicFbUrl = "https://graph.facebook.com/"
    String likeUrl = basicFbUrl + "me/likes?access_token=${at}"
    URL url = new URL(likeUrl)
    String jsonResponse = getResponseFromUrl(url)
    println "JSON RESPONSE IS ${jsonResponse}" // this is showing null
}

String getResponseFromUrl() {
  String something

  String resp = null;
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    try {
        int respCode = conn.responseCode
        if (respCode == 400) {
            log.error("COULD NOT MAKE CONNECTION")
            BufferedReader br = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
            def jsonResp = JSON.parse(br.text)
        } else {
            resp = conn.getInputStream().getText()
        }
    } finally {
        conn.disconnect()
    }

    println("RETURNIG RESPONSE ${resp}") // This returns me a map as expected 

    return resp; 
}

Dont know where does resp goes ?? any suggestions please ??
OK i know the culprit , i am posting the code of invokeMethod

def invokeMethod(String name, args){
    System.out.println("IN INVOKE METHOD NAME ${name}")
    if(facebookPalsCache==null)
        facebookPalsCache = new FacebookPalsCache(1000)
    System.out.println("time before ${name} called: ${new Date()}")

    //Get the method that was originally called.
    def calledMethod = metaClass.getMetaMethod(name, args)
    System.out.println("CALLED METHOD IS ${calledMethod}")

    //The "?" operator first checks to see that the "calledMethod" is not
    //null (i.e. it exists).
    if(name.equals("getFriends")){
        println "getFriends..."
        def session = RequestContextHolder.currentRequestAttributes().getSession()
        def friends = facebookPalsCache.get(session.facebook.uid)
        if(!friends){
            def getFriends = facebookGraphService.invokeMethod (name, args)
            println "Saving FBFRIENDS in CACHE"
            facebookPalsCache.put(session.facebook.uid, getFriends)
            return getFriends
        }
        else return friends
    }

    else {
        if(calledMethod){
            System.out.println("IN IF AND INVOKING METHOD ${calledMethod}")
            calledMethod.invoke(this, args)
        }
        else {
            return facebookGraphService.invokeMethod(name, args)
        }
    }
    System.out.println "RETURNING FROM INVOKE METHOD FOR NAME ${name}"
    System.out.println("time after ${name} called: ${new Date()}\n")
}

OK SOMETHING IS WRONG ABOVE I DONT KNOW WHAT CAN ANYONE PLEASE HELP ??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:19:25+00:00Added an answer on May 24, 2026 at 1:19 am

    The code for invokeMethod and the service don’t seem to be the same unless there’s a separate FacebookGraphService. Assuming that’s the case, then the resp is being caught in the part of your invokeMethod that’s inside the if (calledMethod) { block, but since it’s not the last line of the method it’s not being returned from the call to invokeMethod and therefore is being gobbled up.

    Try adding a return to calledMethod.invoke(this, args):

        if(calledMethod){
            System.out.println("IN IF AND INVOKING METHOD ${calledMethod}")
            return calledMethod.invoke(this, args)
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting some really wierd linking errors from a class I wrote. I am
Im getting frustrated because of OpenDNS and other services (ie: roadrunner) that now always
I'm getting an error here that says I haven't defined a method, but it
when I try to test my plug-in I'm getting this weird problem as shown
I am having one weird problem.I am getting time of the day like 800
Today i have encountered a weird problem when dcommitting my master HEAD to google
I have a weird problem. An Object is being passed to my function, and
I'm getting some weird behaviour recompiling some applications in 2009 that used widestrings at
I'm working on a school project and I'm getting some weird errors from Xcode.
Getting the subdomain from a URL sounds easy at first. http://www.domain.example Scan for the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.