Spring Social Facebook dependency issue - facebook

I am trying to connect my application with facebook. I copied the code from
http://spring.io/guides/gs/accessing-facebook/
Added all the stated dependencies but the error doesn't seem to go. Code given below screenshot attached. Can anyone suggest what might be the issue.
The error is #EnableInMemoryConnectionRepository cannot be resolved.
UserIdSource cannot be resolved.
package controllers;
import org.springframework.context.annotation.Bean;
import org.springframework.social.connect.ConnectionFactoryLocator;
import org.springframework.social.connect.ConnectionRepository;
import org.springframework.social.connect.web.ConnectController;
import org.springframework.social.facebook.config.annotation.EnableFacebook;
#EnableFacebook(appId="someAppId", appSecret="shhhhhh!!!")
#EnableInMemoryConnectionRepository
public class FacebookConfig {
#Bean
public ConnectController connectController(ConnectionFactoryLocator connectionFactoryLocator, ConnectionRepository connectionRepository) {
return new ConnectController(connectionFactoryLocator, connectionRepository);
}
#Bean
public UserIdSource userIdSource() {
return new UserIdSource() {
#Override
public String getUserId() {
return "testuser";
}
};
}
}

Try adding spring-social-config .jar file to your lib. This link will help you to download. Use spring-social-core-1.1.0.M4.jar instead of spring-social-core-1.0.0.Release.jar. Here, you can download from here

I found another way to fix this problem.
Clone the repo that site tell you to clone.
Import the project as existing maven project.
Then go to the .m2 folder and get all the jar file needed for this project

Related

How to update JUnit5 jupiter.api_5.3.1 to jupiter.api_5.4.2?

i want to know that if "MethodOrderer" class is available in JUnit5 Library FOR ECLIPSE or not, because i am unable to find it.
If not, how can i shift jupiter.api_5.3.1 to jupiter.api_5.4.2 in eclipse JUnit5 library?
Will be thankful to see your reply.
I downloaded JUnit5 jar file from "https://search.maven.org/artifact/name.remal.tools.test/junit5/1.26.97/jar" and this jar does have "MethodOrderer" class but when i add this to project dependency and run the testclass, eclipse shows up this error "No tests found with test runner 'JUnit5'."
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
#TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class JunitCalculatorV4 {
#BeforeAll
static void setUpBeforeClass() throws Exception {
System.out.println("Before All");
}
#AfterAll
static void tearDownAfterClass() throws Exception {
System.out.println("After All");
}
#Test
#Order(1)
void addTest() {
System.out.println("Add test");
}
#Test
#Order(2)
void divideTest() {
System.out.println("Divide Test");
}
}
Actually this annotation #TestMethodOrder(MethodOrderer.OrderAnnotation.class) is from jupiter.api_5.4.2 which i added as an external jar, and that might be causing conflict with the existing JUnit5 library.
My problem would be solved if the JUnit5 library is updated as a whole, or atleast the jarfile inside the library is updated.
Project > Properties: Java Build Path, tab Libraries:
You are using Eclipse 2018-12 (4.10) with JUnit 5.3.1 instead of Eclipse 2019-03 (4.11) with JUnit 5.4.0 (the screenshot shows JAR file names containing _5.3.1.v20181005- instead of _5.4.0.v20190212-).
Please upgrade.

Red5 plugin in Eclipse, import cannot be resolved

After installing the last versions of Red5, Eclipse and Infrared5 plugin, I create a new Dynamic Web Project with Red5 server runtime. The generated code is :
package org.red5.core;
import org.red5.logging.Red5LoggerFactory;
import org.red5.server.adapter.MultiThreadedApplicationAdapter;
import org.red5.server.api.IConnection;
import org.red5.server.api.scope.IScope;
public class Application extends MultiThreadedApplicationAdapter {
//private static Logger log = Red5LoggerFactory.getLogger(Application.class);
/** {#inheritDoc} */
#Override
public boolean connect(IConnection conn, IScope scope, Object[] params) {
//log.info("appConnect");
return true;
}
/** {#inheritDoc} */
#Override
public void disconnect(IConnection conn, IScope scope) {
//log.info("disconnect");
super.disconnect(conn, scope);
}
}
The imports fail, I get the error :
Cannot find the class file for org.red5.server.api.IConnection.
The type org.red5.server.api.IConnection cannot be resolved.
It is indirectly referenced from required .class files
Same for org.red5.logging.Red5LoggerFactory and org.red5.server.api.scope.IScope
I think maybe the plugin is out of date and it could be solved by changing the import locations... But I don't know the correct ones. Where can I get them for the last version of Red5 ?
IConnection has never been moved to my knowledge and the other imports are in their correct locations.
MultiThreadedApplicationAdapter
IConnection
IScope
Not being a Red5 Eclipse plugin expert, I would expect that your plugin is not pointing at the correct location for the red5 jars. If you just want to use Eclipse for your Red5 development, you can use these guides Eclipse Setup or First Red5 App to get going (they do not require Pro)

Remote EJB Client Eclipse

I've been trying for some time to learn Java EE but I could never run an EJB example. Oracle's guide uses netbeans but I must learn how to do it in Eclipse. Neither did books did any help or youtube videos.
I can run servlets, jsp, jsf without problems but I always had problems with EJBs. What am I missing?
The problem is configuration within Eclipse I think.
My Project Structure in Eclipse is the following:
The code of HelloWorld.java file:
package helloworld.ejb;
import javax.ejb.Remote;
#Remote
public interface HelloWorld {
public String outputHelloWorld();
}
Code of the HelloWorldBean.java file
package helloworld.ejb;
import javax.ejb.Stateless;
#Stateless
public class HelloWorldBean implements HelloWorld {
public String outputHelloWorld() {
return "Hello World!";
}
}
Code of the HelloWorldClient.java
package helloworldprojectclient;
import javax.ejb.EJB;
import helloworld.ejb.HelloWorld;
public class HelloWorldClient {
#EJB
private static HelloWorld helloWorld;
public static void main (String[] args) {
System.out.println(helloWorld.outputHelloWorld());
}
}
I am using Glassfish 4.0 as a server. The HelloWorldProject is an "EJB Project" while "helloworldprojectclient" is a regular Java Project and i've added javaee.jar (from the glassfish directory) to the buildpath.
When I try to run the HelloWorldClient.java I get the following exception:
Exception in thread "main" java.lang.NullPointerException
at helloworldprojectclient.HelloWorldClient.main(HelloWorldClient.java:10)
which is the following line: System.out.println(helloWorld.outputHelloWorld());
What is the problem? I mention i'm a total beginner at EJBs. Thank you!
Just in case you are still intrested in this:
The first version doesn´t work because you are trying to inject an ejb reference in a class that is not managed by a Container. When you execute the main method, the #EJB annotation is ignored, thus 'HelloWorld' class member is never initialized.
In order to execute this code without modification, you need execute the class in a Application Client Container that will inject the ejb reference.
Your second version runs because instead of to delegate to Container, you are getting the ejb reference through the JNDI service. This is the suggested way when Container injection is no available.
I've managed to make it work. I don't know if this is the correct way but in the "helloworldprojectclient" if you set the buildpath's Project tab and add HelloWorldProject then on the Libraries tab add appserv-rt.jar and javaee.jar (both from glassfish lib folder)
then the client should look like this:
package helloworldprojectclient;
import javax.naming.InitialContext;
import helloworld.ejb.HelloWorld;
public class HelloWorldClient {
public static void main(String[] args) {
try {
InitialContext ic = new InitialContext();
HelloWorld thing = (HelloWorld) ic.lookup("helloworld.ejb.HelloWorld");
System.out.println("It seems it runs: " + thing.outputHelloWorld());
} catch (Exception e) {
e.printStackTrace();
}
}
}

OSGI Bundle Installed and Started but no visible output

I am trying to learn OSGI. (Mainly, the dynamic loading and unloading of bundles).
Following Neil Bartlett's tutorial for How To Embed OSGi, I added The Equinox OSGi framework implementation to the class path and started the game.
Here's the code:
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.ServiceLoader;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
import org.osgi.framework.launch.Framework;
import org.osgi.framework.launch.FrameworkFactory;
public class BundleManager {
/**
* #param args
* #throws Exception
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
FrameworkFactory frameworkFactory = ServiceLoader.load(
FrameworkFactory.class).iterator().next();
Map<String, String> config = new HashMap<String, String>();
//TODO: add some config properties
Framework framework = frameworkFactory.newFramework(config);
framework.start();
BundleContext context = framework.getBundleContext();
List<Bundle> installedBundles = new LinkedList<Bundle>();
installedBundles.add(context.installBundle(
"file:C:/Users/student/Documents/eclipse/myPlugins/HellowService.jar"));
for (Bundle bundle : installedBundles) {
if (bundle.getHeaders().get(Constants.FRAGMENT_HOST) == null)
bundle.start();
}
System.out.println("done!!");
}
}
Yes, it works. No errors at all. However, the bundle that I installed which is a jar file in the path:C:/Users/student/Documents/eclipse/myPlugins/HellowService.jar contains a "HelloWorld" in its start method. I don't see that "HelloWold" in my eclipse console. Why I don't see that message although the bundle was started? I appreciate any simple help.
Note: HellowService.jar is a plugin project that i created earlier, implemented BundleActivator in one of its classes to add "HelloWorld" message in the start method, and finally exported it as a jar file to the directory C:/Users/student/Documents/eclipse/myPlugins/
Edit: Here's my Activator class in the bundle I am installing and starting:
package com.javaworld.sample.service.impl;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import com.javaworld.sample.service.HelloService;
public class HelloServiceActivator implements BundleActivator {
ServiceRegistration helloServiceRegistration;
public void start(BundleContext context) throws Exception {
HelloServiceFactory helloServiceFactory = new HelloServiceFactory();
helloServiceRegistration =context.registerService(HelloService.class.getName(), helloServiceFactory, null);
System.out.println("Hello World!");
}
public void stop(BundleContext context) throws Exception {
helloServiceRegistration.unregister();
}
}
And here's the MANIFEST.MF file of the bundle:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: HelloService
Bundle-SymbolicName: com.javaworld.sample.HelloService
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.javaworld.sample.service.impl.HelloServiceActivator
Bundle-Vendor: JAVAWORLD
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Import-Package: org.osgi.framework;version="1.3.0"
Export-Package: com.javaworld.sample.service
The way i export the bundle is by Right Click on the bundle project->Export->Runnable Jar File->then I select the Launch Configuration to be BundleManager (Which is the class installing the bundle).
I still do not see "Hello World!" message when I start the bundle from my application.
Your launcher does not wait for the OSGi Framework to stop. I would expect this program to start everything but then immediately shut down, because we reach the end of the main method. Refer back to my tutorial where I show how to use the Framework.waitForStop method.
Having said that, I would expect the output from your HelloWorld bundle to actually appear before the shutdown. So it seems likely there is an error in that bundle also. Perhaps you haven't declared the activator? I can only guess, because you haven't given any details.
It turned out that I was exporting the bundle incorrectly. That's because I tried to do it by myself. Here's how the bundle should be exported as a jar file:
Open the plugin export wizard File > Export... > Plug-in Development >
Deployable plug-ins and fragments .
Then select the bundle you want to export and the destination directory. Done!
You can now use the path of the jar file to install the bundle. In my case, it is:
installedBundles.add(context.installBundle(
"file:C:/Users/student/Documents/eclipse/myPlugins/plugins/com.javaworld.sample.HelloService_1.0.0.201307220322.jar"));
Source: http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.pde.doc.user%2Fguide%2Ftools%2Fexport_wizards%2Fexport_plugins.htm
And for sure thanks to #Neil Bartlett

Eclipse Unresolved compilation

I have this really weird problem working on a bigger project in Eclipse Indigo 3.7.2.
I checked out the project from an SVN repository using the Subclipse plug-in and when I start the application I get the following error message:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at anares.preprocess.StanfordParser.getInstance(StanfordParser.java:73)
at anares.start.Startconsole.<init>(Startconsole.java:22)
at anares.start.Startconsole.main(Startconsole.java:52)
This is what Startconsole.class looks like, containing the main method:
package anares.start;
import java.io.FileNotFoundException;
import java.io.IOException;
import anares.core.AnaResAlgorithm;
import anares.preprocess.MorphaDornerSentenceSplitter;
import anares.preprocess.CollectionEquipper;
import anares.preprocess.ParserHandlerInterface;
import anares.preprocess.Preprocessor;
import anares.preprocess.SplitterInterface;
import anares.preprocess.StanfordParser;
import anares.text.AnaResTextObject;
public class Startconsole {
public final ParserHandlerInterface parserint = StanfordParser.getInstance();
public final SplitterInterface splitterint = MorphaDornerSentenceSplitter.getInstance();
public final CollectionEquipper equipperint = null;
public final static int buffersize = 5;
private Startconsole(String file) throws IOException {
AnaResTextObject object = startPreprocess(file);
startAlgorithm(object);
}
private AnaResTextObject startPreprocess(String file) throws IOException {
Preprocessor prepro = new Preprocessor(parserint, splitterint,
equipperint);
AnaResTextObject textObject = prepro.preprocessText(file);
return textObject;
}
private void startAlgorithm(AnaResTextObject object) {
AnaResAlgorithm algo = new AnaResAlgorithm(buffersize);
algo.resolveAnaphora(object);
}
public static void main(String args[]) throws FileNotFoundException,
IOException {
if(args.length > 0){
Startconsole console = new Startconsole(args[0]);
}else{
Startconsole console = new Startconsole("Text.txt");
}
}
}
As I was saying this is a bigger project and therefore contains a few .jar-files and references to other packages.
This problem only occurs on my laptop. On my other PC everything works fine, and a fellow student of mine, who works on the same project, does not have any problems either.
I already tried checking the project out again, cleaning it up and even reinstalling eclipse.
Now here's the weird part: If I comment out the whole main method, just leaving something like
public static void main(String args[]) throws FileNotFoundException,
IOException {
// if(args.length > 0){
// Startconsole console = new Startconsole(args[0]);
// }else{
// Startconsole console = new Startconsole("Text.txt");
// }
System.out.println("Hello World!");
}
I still get the exact same error message with the exact same line numbers. And no "Hello World!" in the output.
Does anyone have any ideas where the problem comes from?
Your issue seems like either there is an error in the code that I cannot see, or your Eclipse instance/compiler got into a strange state it cannot recover from.
Just some basic ideas to check
Have you tried restarting Eclipse?
Are you using the same version of Java on all computers? E.g. there might be some incompatibilities between Java 6 and Java 7.
Is automatic build turned on? Look in the Project/Build automatically menu item. It is possible that the automatic Java builder got turned off, and thus it does not recompile your code.
Have you tried to clean your project to force a rebuild? (Project/Clean menu item).
Is JDT installed in your Eclipse instance? It should be, but it might worth check for such trivial issue.
Maybe you should try to create a new workspace, and checkout the projects again.
You could also try to download Eclipse again with this new workspace idea.
If neither of these things work, I have no idea what to look for.
Look in Eclipse's Problems view (tab); any compilation problems in the project will be reported there. You can double-click on an error or warning in the Problems view and the editor will open on the specific line that is a problem.
Do one thing just remove the build path of englischPCFG.ser.gz from your project because i am sure this is not the jar file you have added in your project