I am making an applet that connects to a database that is stored on the same web server, and when I test the code in the applet viewer in Eclipse, it connects. Problem is, when I try to run it outside Eclipse (on web server or locally), I get this error:
Exception in thread "AWT-EventQueue-2" java.lang.ExceptionInInitializerError
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:286)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.j_ctrl.MovePanel.connectDB(MovePanel.java:569)
at com.j_ctrl.MovePanel.showHighScore(MovePanel.java:558)
at com.j_ctrl.MovePanel.enterPress(MovePanel.java:544)
at com.j_ctrl.MovePanel$1.keyPressed(MovePanel.java:163)
at java.awt.Component.processKeyEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied (java.util.PropertyPermission file.encoding read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
at java.lang.System.getProperty(Unknown Source)
at com.mysql.jdbc.StringUtils.<clinit>(StringUtils.java:70)
... 39 more
Is there anything special that needs to be done in order to connect to an SQL database from an applet?
Here is the code that handles the connection:
private void connectDB(){
try{
String driverName = "com.mysql.jdbc.Driver";
Class.forName(driverName);
String url = "jdbc:mysql://localhost/database";
String user = "user";
String pass = "pass";
connection = DriverManager.getConnection(url, user, pass);
System.out.println("Connected");
}catch(Exception ex){
ex.printStackTrace();
}
}
I changed the username, password and database here, but in my code they are correct.
Edit
Since connecting to the SQL server didn't work (I imagine it was hosted on a different host), I have ended up changing the way I access the database. The applet opens a connection to a PHP file on the host, which in turn connects to the database. Either way this is more secure.
This is being caused by the security model for applets. Here's a good article summarizing the two main ways around this issue - either sign the applet or use a policy file. Let us know if you still experience problems after trying one of these:
http://www.coderanch.com/how-to/java/HowCanAnAppletReadFilesOnTheLocalFileSystem
You need to sign your applet. Here is some good documentation on how.
Related
I have this Java application in which I am now developing a module that can read and execute SQL statements from a file and output the results of the queries. If I launch the module via its main method, it works fine. I give the path to the DB connection settings file (with the user, pass, port.. etc), the path to a file containing SQL queries and the name of the output file. As I said, launched as stand alone, it works fine, connects with no problem, executes queries and outputs their results.
If I integrate it in the application workflow, it fails to connect to the database, even if the credentials (i.e., DB connection settings file) are the same. I have tried to wrap it around in a thread, tried to search if I need to launch the connection asynchronously, but nothing helped. The mysql-connector-java-5.1.28 is in the classpath, everything looks fine. I have also tried to set the autoReconnect (the commented line) but it also fails. This is the code to create the connection:
String url = "jdbc:mysql://"+server+":3306/?useCursorFetch=true";
//String url = "jdbc:mysql://"+server+":3306/?autoReconnect=true";
try {
return DriverManager.getConnection(url, user, password);
} catch (SQLException e1) {
Logging.outputStackTrace(e1);
throw new RuntimeException("Cannot connect to DB server: " + e1.getMessage());
with server = localhost. The user and pass are fine, sorry for repeating a third time, the connection is successful while launching it via the module's main method.
This is the stack trace I get while running the module via the application:
ERROR: An error occurred : Could not create connection to database server. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
Check the error log for details
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
java.lang.reflect.Constructor.newInstance(Unknown Source)
com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
com.mysql.jdbc.Util.getInstance(Util.java:386)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:975)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:920)
com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2575)
com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2311)
com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834)
com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
java.lang.reflect.Constructor.newInstance(Unknown Source)
com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:416)
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:347)
java.sql.DriverManager.getConnection(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
org.application.utilities.DBConnection.connectToMySQL(DBConnection.java:144)
org.application.utilities.DBConnection.connect(DBConnection.java:107)
org.application.utilities.RunSQL.run(RunSQL.java:110)
org.application.workflow.Processing.extractData(Processing.java:201)
org.application.workflow.Processing.<init>(Processing.java:73)
org.application.gui.ApiGUI$2.actionPerformed(ApiGUI.java:349)
javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
javax.swing.DefaultButtonModel.setPressed(Unknown Source)
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
java.awt.Component.processMouseEvent(Unknown Source)
javax.swing.JComponent.processMouseEvent(Unknown Source)
java.awt.Component.processEvent(Unknown Source)
java.awt.Container.processEvent(Unknown Source)
java.awt.Component.dispatchEventImpl(Unknown Source)
java.awt.Container.dispatchEventImpl(Unknown Source)
java.awt.Component.dispatchEvent(Unknown Source)
java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
java.awt.Container.dispatchEventImpl(Unknown Source)
java.awt.Window.dispatchEventImpl(Unknown Source)
java.awt.Component.dispatchEvent(Unknown Source)
java.awt.EventQueue.dispatchEventImpl(Unknown Source)
java.awt.EventQueue.access$200(Unknown Source)
java.awt.EventQueue$3.run(Unknown Source)
java.awt.EventQueue$3.run(Unknown Source)
java.security.AccessController.doPrivileged(Native Method)
java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
java.awt.EventQueue$4.run(Unknown Source)
java.awt.EventQueue$4.run(Unknown Source)
java.security.AccessController.doPrivileged(Native Method)
java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
java.awt.EventQueue.dispatchEvent(Unknown Source)
java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
java.awt.EventDispatchThread.pumpEvents(Unknown Source)
java.awt.EventDispatchThread.pumpEvents(Unknown Source)
java.awt.EventDispatchThread.run(Unknown Source)
Any ideas why this is happening? Is this a thread related issue? Can the event manager of the GUI have something to do with it? There are no multiple connections or concurrent connections to the database. Only once and it is properly closed when done. Via MySQL command line I cal also access my database, I made sure the server is on everytime, etc...
Thank you.
i think you forgot to mention database name
String url = "jdbc:mysql://"+server+":3306/?useCursorFetch=true";
must be
String url = "jdbc:mysql://"+server+":3306/DB_NAME?useCursorFetch=true";
OK. Got it. When I was running the SQL module via the application, I was setting the file encoding to ANSI via
System.setProperty("file.encoding", "ANSI");
which was not the case while running it stand alone.
Apparently the DriverManager.getConnection(url, user, pass) does not set the character set on its own to make sure it sends requests in a compatible character encoding. Maybe that should be fixed in the java.sql package.
We have a client server application which runs using spring remoting framework and we are using jetty server and Java 1.7. We deliver both client and server to the customers.
At one of customer's office, for one of the user login, he is getting this Exception which is mentioned in the title of the postjava.net.SocketException:Unexpected end of file from the server. He is actually doing the search for something which makes a server call and finally he ends up getting this error in the error log.
The weird thing is, nobody else in the Customer's office gets this error. It is very weird.
And also i googled about this exception but did not get appropriate answer.
Please provide your suggestions.
org.springframework.remoting.RemoteAccessException: Could not access HTTP invoker remote service at [http://192.168.13.211:6094/SearchFieldServer]; nested exception is ava.net.SocketException: Unexpected end of file from server at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.convertHttpInvokerAccessException(HttpInvokerClientInterceptor.java:211)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:144)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy69.search(Unknown Source)
at se.transware.awt.SearchFieldModel.setObjectIdAndReload(SearchFieldModel.java:329)
at se.transware.awt.SearchFieldModel.setObjectIdAndReload(SearchFieldModel.java:293)
at se.transware.awt.SearchFieldModel.setObjectID(SearchFieldModel.java:282)
at se.transware.awt.SearchField.setOid(SearchField.java:740)
at se.transware.tt.client.register.CustomerClientRegGUI.load(CustomerClientRegGUI.java:3885)
at se.transware.tt.client.register.CustomerClientRegLogic.pseudoConstructor(CustomerClientRegLogic.java:786)
at se.transware.tt.client.main.ModuleController.flipApp(ModuleController.java:222)
at se.transware.tt.client.main.SystemResources.flipApp(SystemResources.java:260)
at se.transware.tt.client.register.RegObjectsTableLogicClientAdapter.editRegObject(RegObjectsTableLogicClientAdapter.java:511)
at se.transware.tt.client.register.RegObjectsTable2$18.mouseClicked(RegObjectsTable2.java:1150)
at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.net.SocketException: Unexpected end of file from server
at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at org.springframework.remoting.httpinvoker.SimpleHttpInvokerRequestExecutor.validateResponse(SimpleHttpInvokerRequestExecutor.java:138)
at org.springframework.remoting.httpinvoker.SimpleHttpInvokerRequestExecutor.doExecuteRequest(SimpleHttpInvokerRequestExecutor.java:62)
at org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.executeRequest(AbstractHttpInvokerRequestExecutor.java:134)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:191)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:173)
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:141)
... 45 more
Here are some links which you probably already found :
https://forums.oracle.com/forums/thread.jspa?messageID=7076649
http://www.coderanch.com/t/207583/sockets/java/java-net-SocketException-Unexpected-file
http://cxf.547215.n5.nabble.com/Caused-by-java-net-SocketException-Unexpected-end-of-file-from-server-td4715340.html
Additionally, if you can share some code snippet or stack trace we can share more realistic comments on this issue. Maybe it is caused by some security options of the client facing this issue.
Are all customers configuration the same?
I am trying to connect to FTP Server using Apache FTPCleint in java web start aplication.
Below is the code i am using.
ftpInstance = new FTPClient();
ftpInstance.setRemoteVerificationEnabled(false);
ftpInstance.connect(<HostName>);
int rpyCode = ftpInstance.getReplyCode();
if(!FTPReply.isPositiveCompletion(rpyCode)){
throw new Exception("Connection Rejected with reply code " + rpyCode + ". - " + <Hostname>);
}
Problem is at line ftpInstance.connect(<HostName>). An exception is been thrown Please look at the stack trace
java.lang.RuntimeException: java.net.SocketException: Malformed reply from SOCKS server
at com.newgen.backend.Operation.call(Operation.java:91)
at filetransfermanager.FileTransferManagerView$1.windowOpened(FileTransferManagerView.java:48)
at java.awt.AWTEventMulticaster.windowOpened(Unknown Source)
at java.awt.Window.processWindowEvent(Unknown Source)
at javax.swing.JFrame.processWindowEvent(Unknown Source)
at java.awt.Window.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.net.SocketException: Malformed reply from SOCKS server
at java.net.SocksSocketImpl.readSocksReply(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:171)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:192)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:285)
at com.newgen.ftp.FTPInstance.getInstance(FTPInstance.java:38)
at com.newgen.backend.Transport.<init>(Transport.java:58)
at com.newgen.backend.Operation.call(Operation.java:81)
... 27 more
Above code is working fine in normal project but not in java web start.
Any help is appreciated.
Thanks.
You have configured SOCKS proxy settings that point to something that isn't a SOCKS proxy.
I am trying to build a desktop app in java using facebook API provided by google. I have a number of questions :
1) Do I have to make use of socket programming? (coz I am a newbie and I haven't :/ )
2) And it is giving a java.net.UnknownHost Exception in facebook api when I try to create a auth_token.
Any extra info would be a great help. :)
java.lang.RuntimeException: java.net.UnknownHostException: api.facebook.com
at com.google.code.facebookapi.BasicClientHelper.runtimeException(BasicClientHelper.java:123)
at com.google.code.facebookapi.ExtensibleClient.callMethod(ExtensibleClient.java:538)
at com.google.code.facebookapi.ExtensibleClient.callMethod(ExtensibleClient.java:446)
at com.google.code.facebookapi.ExtensibleClient.auth_createToken(ExtensibleClient.java:860)
at com.google.code.facebookapi.SpecificReturnTypeAdapter.auth_createToken(SpecificReturnTypeAdapter.java:73)
at facebookConnection.FbStartingPoint.<init>(FbStartingPoint.java:26)
at sourcepoint.FirstWindow$1.actionPerformed(FirstWindow.java:41)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.net.UnknownHostException: api.facebook.com
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at com.google.code.facebookapi.ExtensibleClient.postRequest(ExtensibleClient.java:583)
at com.google.code.facebookapi.ExtensibleClient.callMethod(ExtensibleClient.java:534)
... 41 more
It sound like your machine can't access api.facebook.com host. Are you using a proxy to connect to Internet?
Try using telnet to make sure the whole computer can connect to the internet (not only your proxy-configured driver):
> telnet api.facebook.com 80
Trying 66.220.149.99...
Connected to api.facebook.com.
Escape character is '^]'.
GET /
HTTP/1.1 400 Bad Request
Content-Type: text/html
Date: Sat, 25 Aug 2012 16:29:53 GMT
Connection: close
Content-Length: 134
<HTML><HEAD>
<TITLE>400 Bad Request</TITLE>
</HEAD><BODY>
<H1>Method Not Implemented</H1>
Invalid method in request<P>
</BODY></HTML>
Connection closed by foreign host.
api.facebook.com is the endpoint for the old REST API which is deprecated; you should probably be connecting to graph.facebook.com
Nonetheless, api.facebook.com should be resolvable and still work if you're using the legacy APIs.
This is almost certainly a problem with your network, firewall, computer, DNS, or JDK - its a problem with your code connecting to Facebook, not a problem on Facebook's side
I'm trying to launch my applet locally and this is the exception I get:
I don't know why this is happening the mp3 is already located on the jar file, why can't I access it?
SEVERE: null
java.security.AccessControlException: access denied (java.io.FilePermission file:\C:\applet\CairoNightTrainClient.jar!\Music\train.mp3 read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkRead(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at com.sun.media.codec.audio.mp3.JS_MP3FileReader.getAudioInputStream(JS_MP3FileReader.java:113)
at javax.sound.sampled.AudioSystem.getAudioInputStream(Unknown Source)
at LogicEngine.DJ.createClip(DJ.java:56)
at LogicEngine.DJ.<init>(DJ.java:42)
at GUI.JPanelGameApplet$1.run(JPanelGameApplet.java:65)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Applets (or at least untrusted applets) are not allowed to access the local file system. This is kind of a good thing as most people might get upset if random websites had such access.
If you want to access a file go through javax.jnlp (just google it) and it'll provide an API that presents the user with a file chooser to allow applets to read a specific file of their choosing.
If it's just a file that is part of the applet, use either a resource (Class.getResourceAsStream) or through an http connection (URL)