0

I'll post my first question on this forum so be kindly =)

My problem is that my import on my jsp file cannot be resolved :

<%@ page import="java.util.List" %>
<%@ page import="com.javapapers.java.social.facebook.FBConnection" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  pageEncoding="ISO-8859-1"%>
<%
FBConnection fbConnection = new FBConnection();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Java Facebook Login</title>
</head>
<body style="text-align: center; margin: 0 auto;">
<div
    style="margin: 0 auto; background-image: url(./img/fbloginbckgrnd.jpg); height: 360px; width: 610px;">
    <a href="<%=fbConnection.getFBAuthUrl()%>"><img
        style="margin-top: 138px;" src="./img/facebookloginbutton.png" />
    </a>
</div>
</body>
</html>

I crawled this forum since a day and I've done all what is said and I didn't found the solution for my problem...

here is the error :

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: [15] in the generated java file: [C:\Users\Matthieu\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\Facebook_Login\org\apache\jsp\index_jsp.java]
The import com.javapapers.java.social.facebook.FBConnection cannot be resolved

An error occurred at line: 6 in the jsp file: /index.jsp
FBConnection cannot be resolved to a type
3: <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
4:  pageEncoding="ISO-8859-1"%>
5: <%
6:  FBConnection fbConnection = new FBConnection();
7: %>
8: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
9: <html>


An error occurred at line: 6 in the jsp file: /index.jsp
FBConnection cannot be resolved to a type
3: <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
4:  pageEncoding="ISO-8859-1"%>
5: <%
6:  FBConnection fbConnection = new FBConnection();
7: %>
8: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"         "http://www.w3.org/TR/html4/loose.dtd">
9: <html>


Stacktrace:
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
             org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:198)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:450)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:361)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:585)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:363)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

I've put my classes on WEB-INF/classes as recommended (respecting the package name : com/javapapers/java/social/facebook)

I'm working on Eclipse Luna with a TomCat 8.0 server

Deployement assembly : Deployement Assembly

Librairies : Librairies

Sources : Test/src

But the error's still there

Can you help me please

Thanks

4 Answers4

1

As mentioned above, be sure the .jar file is in your classpath.

Second option is that your deployment does not correspond to what you want.

Check your Eclipse configuration for the Deployment Assembly:

  • right click on your project
  • select Deployment Assembly

If you're working on an external deployment (as opposed to workspace resources), check the resources at the deployment.

MarsAtomic
  • 10,436
  • 5
  • 35
  • 56
Gary SEBASTIANI
  • 302
  • 1
  • 15
  • My jar is on my tomcat server classpath. My Deployement Assembly looks like : Source : /src Deploy Path : WEB-INF/classes – Matthieu Le Scornet May 13 '15 at 14:36
  • Your jar ? Isn't it a web project ? – Gary SEBASTIANI May 13 '15 at 14:41
  • It is, but there is a jar for specific functions and variables about Facebook(called restfb) – Matthieu Le Scornet May 13 '15 at 14:46
  • Ok, so you find this jar in the WEB-INF/lib of your project in your tomcat server deploiement classpath ? – Gary SEBASTIANI May 13 '15 at 14:49
  • In my lib there is a jar called Java-json.jar and in my classpath there is two jars called Bootstrap.jar and Tomcat-juli.jar – Matthieu Le Scornet May 13 '15 at 14:54
  • Just to be sure, the lib you're talking is in the WEB-INF/lib of your project deployed on the tomcat server, right ? What is the name of the third-party jar containing the facebook classes ? – Gary SEBASTIANI May 13 '15 at 14:57
  • The lib in the WEB-INF of my project isn't in my tomcat's classpath. Did I need to jar the 3 classes : FBConnection.java, FBGraph.java and MainMenu.java ? There is a jar downloaded from restfb.com who allows me to use the API ( the jar is on my PROJECT BUILD PATH) – Matthieu Le Scornet May 13 '15 at 15:04
  • Could you upload to your question a screenshot of your configuration in: JavaBuildPath>Librairies & source and of Deployment Assembly – Gary SEBASTIANI May 13 '15 at 15:20
  • Done, sorry I can't add Three links neither images (don't have 10 of reputation ) – Matthieu Le Scornet May 13 '15 at 15:28
  • Try to create a folder in your WEB-INF called lib and put the jar in it. Also remove the line with the fb jar on both of your configuration. Then, try to redeploy, – Gary SEBASTIANI May 13 '15 at 15:32
  • In your librairies, you can see Web App Librairies, it actually corresponds to your WEB-INF/lib. You can open it to see what you have in it. Anyway, The problem you have here is clearly a configuration problem, I'd advice you to check some tutorials on Eclipse deploiement and project configuration. There is many misconfiguration in the different screenshots – Gary SEBASTIANI May 13 '15 at 15:34
  • Think it's a good solution, thanks sir for the time you give to my questions – Matthieu Le Scornet May 13 '15 at 15:38
  • You're welcome, think to come here to give the answer when you find it, or to close the topic. Good luck ! – Gary SEBASTIANI May 13 '15 at 15:41
0

You have to create following class in your src with same package name.

FBConnection.java FBGraph.java MainMenu.java

or you can download from the link and place in to your classpath once its compiled. Make sure you have change FB_APP_ID,FB_APP_SECRET,REDIRECT_URI values accordingly in your FBConnection class.

prashant thakre
  • 5,061
  • 3
  • 26
  • 39
0

Assuming that FBConnection comes from a standard JAR file, then you need to ensure that the JAR file is on the JSP compiler's classpath when your JSP is compiled.

If you are deploying via a WAR file, then the library JAR needs to be in the WAR file. If you are deploying using Eclipse's Tomcat integration, then the JAR needs to be a dependency of your Eclipse project.

For more information on how to do this: Adding 3rd party jars to WEB-INF/lib automatically using Eclipse/Tomcat

Community
  • 1
  • 1
Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
-1

You need to use correct App Id and App secret key. Refer the project here http://javapapers.com/java/java-facebook-login-with-oauth-authentication/ , import and change the FB_APP_ID and FB_APP_SECRET in FBConnection() class. Works for me.

Nipun
  • 1