I'm getting the following NullPointerException while trying to use the Play FBConnect module:
Caused by: java.lang.NullPointerException
at tags.fbconnect.FBConnectTags._button(FBConnectTags.java:26)
at tags.fbconnect.FBConnectTags$_button.call(Unknown Source)
at /app/views/main.html.(line:17)
at play.templates.GroovyTemplate.render(GroovyTemplate.java:203)
This seems to be the line where its occurring: https://github.com/rbamba/play-fbconnect/blob/master/app/tags/fbconnect/FBConnectTags.java#L26
Unfortunately I'm not sufficiently familiar with Play modules to debug this myself.
edit: In response to a comment, I believe the fbconnect module is correctly configured, since this is being reported earlier in the log:
13:12:13,225 INFO ~ Module fbconnect is available (/home/****/play-1.1.1/modules/fbconnect-0.3)
edit2: I've actually got it to progress past this point on my local machine, but still getting this NPE on my production server.
I can't see anything specifically wrong with the plugin code. To explain a little of what is going on,
// the line of code with the error
String url = Play.plugin(FBConnectPlugin.class).session().getLoginUrl(scope);
Lets break this down a little
Play.plugin(FBConnectPlugin.class)
This line asks Play to return the initialised plugin, from the list of plugins configured within Play. If the Plugin is not set up, then it returns null. This is the most likely reason for the error.
.session()
This simply gets the session object from the FBConnectPlugin, which is a statically created object, so will not be null.
.getLoginUrl(scope);
This builds the URL up. This method is not called, otherwise you would see it in the stack trace.
Therefore, the problem is that you have not configured the plugin correctly. Check over the documentation again to make sure why it has a problem. Alternatively, you may want to check out the FbGraph module. I installed this a few days ago, and have a Facebook app up and running already. It is very simple, and the documentation is excellent.
The answer is a little long-winded, but as you said you did not understand how modules worked, I thought it was worth explaining.
I spoke to Regis Bamba, one of the programmers who works on fb-connect.
I eventually decided to use the fbgraph module instead, and I'd probably recommend this to anyone thinking of using fb-connect because its more powerful, and seems to be better maintained. Even Regis recommended using it :-)
Regardless, here is what Regis suggested to get rid of the "java.net.URISyntaxException":
The solution is to manually replacing it with its encoded value, before encoding the whole string.
The getAuthUrl() function in FBConnectSession.java should be:
public String getAuthUrl(String authCode){
return "https://graph.facebook.com/oauth/access_token?client_id=" +
WS.encode(id)+"&redirect_uri=" +
WS.encode(Router.getFullUrl("FBConnect.callback")) +
"&client_secret="+WS.encode(secret)+"&code="+WS.encode(authCode.replace("|","%7C"));
}
Related
I'm very new to java. starting from yesterday! i installed eclipse and imported spring libraries inside it. but a weird problem happened. in import statement there was an error telling The type org.springframework.context.ApplicationContext is not accessible. after running the project another error happened (related to same subject ApplicationContext cannot be resolved to a type).
Anyway! i was confused. it took one day for me. searching forums such as stackoverflow and googling didn't resolve my problem. suddenly i saw a popup message in eclipse suggesting some solutions. ignoring some worthless one of them was adding module to module-info.java file. unbelievably that solved the problem! strangest thing was that i never saw this solution in related forums! and most annoying thing is that what if i never saw that popup? where did i do a mistake? and why this solution doesn't exist on the internet?
Lots of thanks!
Java modules are a new feature of Java 9; they allow you to specify exactly which dependencies you need for your program, hence allowing greater control of the size of your application - no need to bring along library code you don't use. That seems to imply that you need to explicitly say what you want, I guess so that you realise that you are pulling in more modules.
So the reason that you don't see much information about modules in general is that they are comparatively new and doubt that I'm alone in being a long-standing Java developer who has never seen a module-info file!
I wonder whether Eclipse gave you some options when you were creating your project and you inadvertently took an option meaning "yes I want the extra control of doing mocules and I don't mind doing a bit more work."
In our application we encounter very sporadic run time exceptions which crash our message processors (which are stand-alone java processes running on Java 8). The processors, at the time of this exception, generally try to execute a web service call.
The exception are
java.lang.Error: Failed to create new instance of com.sun.xml.internal.ws.api.streaming.XMLStreamWriterFactory$1
at com.sun.xml.internal.ws.api.streaming.ContextClassloaderLocal.createNewInstance(ContextClassloaderLocal.java:63)
..
Caused by: java.lang.IllegalArgumentException: Unable to access unsupported property javax.xml.stream.isRepairingNamespaces
at weblogic.xml.stax.ConfigurationContextBase.check(ConfigurationContextBase.java:90)
The strange thing is, the whole application is running without errors 99.9% of the time: the above exceptions happen quite infrequently (ca. every couple of days). After a crash, the processors are restarted automatically, and again operate perfectly fine, until the same exception occurs again after a seemingly random interval.
So far we could not correlate this with any misbehavior on the part of the JVM or the host the application is running on.
Does anyone have any pointers as to why such an unsupported property javax.xml.stream.isRepairingNamespaces exception could appear sporadically?
We're running jdk1.8.0_66 on Red Hat 4.8.5-4. Web service interfaces are generated using JAX-WS.
Edit:
I can't share the classpath (lots of internal info, sorry). We do have the Weblogic full client in there though: wlfullclient-12.1.3.jar. It defines an XML factory via ServiceLoader
META-INF/services/javax.xml.stream.XMLOutputFactory --> weblogic.xml.jaxp.RegistryXMLOutputFactory
Where as xml-apis-1.4.01.jar (also on classpath) contains javax/xml/stream/XMLOutputFactory.class (related to the exception thrown in ConfigurationContextBase).
Could this be part of the problem?
You have to change the class path order. At first point all the axis2 jars and then point the weblogic.jar in class path. Hope it will solve your issue.
I encountered this problem yesterday after making some significant changes to my code. This particular post is the ONLY information I can find by googling this particular error -- always a bad sign. After hours and hours of fruitless deep debugging, comparing the original working version of the code with the new non-working version, I decided to start backing out my code changes to see where/when the problem originated. Well, after backing out pretty much every single code change, the problem was still happening. I finally realized that this problem was perhaps external to the code. It turns out that at some point, I had added an extraneous library: wstx.jar to my lib directory. Once I removed that lib, everything worked great. So apparently it was utilizing the wrong classes to try to perform this operation.
Not sure if that is of any assistance to you, but even if not, I thought someone someday might stumble onto this and find it to be useful.
I have a legacy java app written up by a previous developer. A bug has recently been found in it, and I've been given the task of fixing it.
Part of the problem is that there were never any error messages reporting from it.
By putting in a lot of logging messages, I finally narrowed it down to a specific line in the code - it's trying to run a method on a null object.
This is something that SHOULD have thrown an error into the log. Yet it hasn't. And even fixing this one, there's a lot of this problem in the code - assuming something will have a value when it doesn't. Every time I put in a data-verification for one, it fails somewhere shortly down the line for a very similar reason, and then I have to go through the hassle of putting in logging commands every other line again to finally narrow it down.
Why would a java program be silently failing instead of throwing errors? I can't seem to find any sort of setting suggesting that this is on purpose, but I'm really not even sure where to look for such a thing.
I recently upgraded to helios and now every time I step into a constructor for a class (e.g. Cat myCat = new Cat();), eclipse debugger shows the stack as
:
To get to the actual constructor code, I have to step out several times which is annoying. This is happening with every class and despite the stack I never see any error messages in the console. How do I fix this so it directly steps into the constructor for my class?
This only happens the first time the class is used, and even for classes that are in the same src file as the current one.
Eclipse has a step filter preference in the Java debugger preferences. Its default preference filters out java.lang.ClassLoader, however this wasn't working. This might have something to do with recently having installed and switched to using jre7. To solve my problem I added a filter to step through any code in the java.lang package.
I think the ClassNotFoundException is just happening as a part of class loading -- the problem is that you have a breakpoint set to trigger when those exceptions are thrown. My guess is that your version of Eclipse has this breakpoint on by default, whereas the old one didn't.
Check out this link, which reports a similar problem and provides the solution, which is just to disable that breakpoint.
(In the interest of teaching to fish and all that, the google search term was "eclipse debugger launcher$appclassloader".)
From the stack track reported in Eclipse, it seems a ClassNotFoundException was initialized and is being thrown, Did the application you wrote ran into any problems?
Have you set breakpoints in constructor of the class? you was not able to step into the constructor at all?
Were you using Class.forname() or import to introduce the class to JRE?
It seems that the for my students using lab machines running openjdk, the solution was to add a step filter in the same preferences mentioned in https://stackoverflow.com/a/10525351/1449799 but add jdk.*
I have a jar package that I wrote using netbeans. This package is called from other java file. The jar calls a webservice and is supposed to do something with it. Now everything works fine locally. I compiled the files and locally and uploaded them to the server and when I run it, I get the "Service could not be initialized".I am not sure how to debug this. I am pretty new to java. What is the best approach here to solve the issue?
I would start by implementing logging (I like log4J) in your project so you can get some better details of what is actually going wrong. This will be very useful not only now but in the future as things go wrong (they inevitably will) you will be able to solve them based on how good of a job you did logging what is happening in your application. Right now it sounds like an error is bubbling up and you're not getting much detail about it. Logging should help you determine not only what went wrong but where it happened and what the application was doing at the time.
Try this short introduction to log4j to get started.