Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am developing a GWT web app and am trying to connect to a mysql-database from my RemoteServiceServlet implementation (for rpc).

The server runs and I am able to connect to the database from the machine I work on. For testing purposes, I wrote a small program which only connects to the database. This works:

Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection("jdbc:mysql://192.168.0.106:3306/dbname", "dbuser", "dbpasswd");

But the same lines fail in my gwt app with about 100 lines of stack trace, here is the "cause":

Caused by: java.net.SocketException: java.security.AccessControlException: access denied (java.net.SocketPermission 192.168.0.106:3306 connect,resolve)
at com.mysql.jdbc.StandardSocketFactory.unwrapExceptionToProperClassAndThrowIt(StandardSocketFactory.java:408)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:269)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:294)
... 55 more

and now my question: why?

edit: for testing I use the development mode with chrome and gwt plugin

edit2: the part of code where it crashes:

public DataLinkImpl() {
Connection tmpConnection = null;
try {
  Class.forName("com.mysql.jdbc.Driver");
  tmpConnection = DriverManager.getConnection("jdbc:mysql://192.168.0.106:3306/dbname", "dbuser", "dbpasswd");
} catch (ClassNotFoundException e) {
  System.err.println("jdbc driver class not found");
} catch (SQLException e) {
  System.err.println("could not establish database connection");
  e.printStackTrace();
  e.getNextException().printStackTrace();
} finally {
  connection = tmpConnection;
}
}

with the following stacktrace:

could not establish database connection
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance_(Runtime.java:112)
at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance(Runtime.java:120)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:344)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2333)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2370)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2154)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance_(Runtime.java:112)
at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance(Runtime.java:120)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at de.eikecochu.gwt.awidb.server.DataLinkImpl.<init>(DataLinkImpl.java:23)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:428)
at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:60)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:78)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:362)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.net.SocketException: java.security.AccessControlException: access denied (java.net.SocketPermission 192.168.0.106:3306 connect,resolve)
at com.mysql.jdbc.StandardSocketFactory.unwrapExceptionToProperClassAndThrowIt(StandardSocketFactory.java:408)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:269)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:294)
... 55 more
01.12.2011 02:33:09 com.google.appengine.tools.development.ApiProxyLocalImpl log
SCHWERWIEGEND: javax.servlet.ServletContext log: unavailable

java.lang.NullPointerException
at de.eikecochu.gwt.awidb.server.DataLinkImpl.<init>(DataLinkImpl.java:29)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:428)
at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:60)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:78)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:362)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

01.12.2011 02:33:09 com.google.apphosting.utils.jetty.JettyLogger warn
WARNUNG: /awidb/datalink
java.lang.NullPointerException
at de.eikecochu.gwt.awidb.server.DataLinkImpl.<init>(DataLinkImpl.java:29)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:428)
at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:60)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:78)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:362)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

edit3: I added a permission to my /Library/Java/.../security/java.policy file:

grant {
    permission java.net.SocketPermission "192.168.0.106:3306", "connect,resolve";
}

but still the same, I can not connect to the database. I also tried to execute it directly on the machine where the db is, so I deployed it in tomcat (added the same permission there), but still no go. Wtf??

edit4: to confirm this, i wrote a very simple web app:

EntryPoint class:

package de.eikecochu.gwt.gwttest.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;

public class GWTTest implements EntryPoint {
  private TestServiceAsync testservice = GWT.create(TestService.class);
  @Override
  public void onModuleLoad() {
    Button b = new Button("test");
    RootPanel.get("container").add(b);
    b.addClickHandler(new ClickHandler() {
      @Override
      public void onClick(ClickEvent event) {
        testservice.echo("test", new AsyncCallback<String>() {
          @Override
          public void onFailure(Throwable caught) {
            RootPanel.get("container").add(new Label("error"));
          }
          @Override
          public void onSuccess(String result) {
            RootPanel.get("container").add(new Label(result));
          }
        });
      }
    });
  }
}

Remote Service Interface:

package de.eikecochu.gwt.gwttest.client;

import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

@RemoteServiceRelativePath("testservice")
public interface TestService extends RemoteService {

  String echo(String s);

}

Remote Service Async Interface:

package de.eikecochu.gwt.gwttest.client;

import com.google.gwt.user.client.rpc.AsyncCallback;

public interface TestServiceAsync {

  void echo(String s, AsyncCallback<String> callback);

}

RemoteServiceServlet Implementation:

package de.eikecochu.gwt.gwttest.server;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

import de.eikecochu.gwt.gwttest.client.TestService;

public class TestServiceImpl extends RemoteServiceServlet implements
    TestService {
  private static final long serialVersionUID = 1L;

  private final Connection connect() {
    String driver = "com.mysql.jdbc.Driver";
    String dblink = "jdbc:mysql://192.168.0.106:3306/";
    String dbname = "dbname";
    String dbuser = "dbuser";
    String dbpass = "dbpass";
    try {
      Class.forName(driver).newInstance();
    } catch (InstantiationException e) {
      e.printStackTrace();
    } catch (IllegalAccessException e) {
      e.printStackTrace();
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    }
    Connection conn = null;
    try {
      conn = DriverManager.getConnection(dblink + dbname, dbuser, dbpass);
    } catch (SQLException e) {
      System.err.println("mysql connection error: ");
      e.printStackTrace();
    }
    return conn;
  }

  @Override
  public String echo(String s) {
    Connection c = connect();
    return s;
  }

}

this does not work either. Not on my machine, and not on localhost (where the db is). The same error appears again (AccessControlException bla bla).

edit5: I tried to execute my app directly on my server, which means: i installed eclipse and gwt tools on the server and executed it there locally in chrome/development mode. Still the same error. I get the feeling that either my mysql/ubuntu have wrong configs or I am doing something wrong, fundamentally. Normally, it should be quite easy to connect to a database, yes? I mean, what is a website without a database...

edit6: as baba suggested, I tried to set System.setSecurityManager(null);

in my RemoteServlet right before connecting to the database. It throws following error (abbreviated):

java.security.AccessControlException: access denied (java.lang.RuntimePermission setSecurityManager)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:252)
at java.lang.System.setSecurityManager0(System.java:273)
at java.lang.System.setSecurityManager(System.java:264)

so it seems I have a SecurityManager installed.

Also, I have tried to access my database with telnet. At first, my connection was refused but I changed my mysql-bind address to the ip of my server (192.168.0.106) and followed the steps here: http://ubuntu-commands.blogspot.com/2008/11/how-do-i-enable-remote-access-to-mysql.html

And when I telnet 192.168.0.106 3306 now, weird symbols appear:

eikes-macbook-air:~ eike$ telnet 192.168.0.106 3306
Trying 192.168.0.106...
Connected to eike-server.speedport.ip.
Escape character is '^]'.
=
5.1.58-1ubuntu1(b5|529h~!dYpI\rHP:qKc

ot packets out of orderConnection closed by foreign host.

It seems this is an error?

Plus, I searched for the AccessDenied error and found this link: http://code.google.com/p/gwt-examples/wiki/project_MySQLConn#Tomcat_Setup_Notes which describes exactly the error I am experiencing, although I use the Devmode for developing. Although following these steps didn't help (I edited my default /Library/.../security/java.policy file)

edit7: I installed postgresql and set up a very simple database just to test the connection. Without GWT it works fine, GWT produces the same error again. Therefore, it is not the fault of my mysql config. I played a bit with the java policy file, no reaction. GWT hates me :<

edit8: I tried both postgresql and mysql on another machine (this time win7) and executed my gwt app there locally (before & after editing the policy file), still the same error. This is unmistakably GWTs fault! It seems like the gwt devmode is not allowed to do anyting, anywhere...

Another question: the error clearly states "java.security.AccessControlException: access denied (java.net.SocketPermission localhost resolve)", so why does this still appear when I modify my java policy file to connect,resolve on the needed ports? It seems like that had absolutely no effect! I even tried grant AllPermission, no effect either.

Next, I found the "gwt-log.txt", which lists an error in the loading process:

Public resources found in...
[WARN] Error processing classpath URL 'file:/C:/Program Files (x86)/eclipse/plugin/com.google.gdt.eclipse.designer.hosted.2_2_2.4.2.r37x201110201837/gwt-dev-designtime.jar'
java.net.URISyntaxException: Illegal character in path at index 16: file:/C:/Program Files (x86)/eclipse/plugins/com.google.gdt.eclipse.designer.hosted.2_2_2.4.2.r37x201110201837/gwt-dev-designtime.jar
at java.net.URI$Parser.fail(Unknown Source)

I don't know what that is or if it's important, but it's not my fault!

share|improve this question
    
what application server are you using? –  Dmitry Beransky Dec 1 '11 at 1:09
    
you mean the development mode? I don't use a dedicated server –  Eike Cochu Dec 1 '11 at 1:14
    
could you post the complete stack trace? –  Dmitry Beransky Dec 1 '11 at 1:21
2  
You might be running in a security sandbox accidentally, sockets require permissions and technically they can be denied for the JVM instance. Check your main call and make sure that the runtime is through a local JVM. java.sun.com/developer/onlineTraining/Programming/JDCBook/… –  Daniel B. Chapman Dec 1 '11 at 3:20
1  
Have you tried accessing db on localhost? does that work? –  gotomanners Dec 1 '11 at 22:46
show 3 more comments

3 Answers

up vote 6 down vote accepted
+50

You have installed Google Eclipse Plugin with Google App Engine. Create a new GWT Project and make sure you unselect Google App Engine, and then retry. Or, delete all GAE related jar files from your eclipse classpath.

GAE is a hosting environment provided by Google. It has a very restricted environment. It does not allow you to open socket connections or read/write files. Database drivers open up a socket connection, and so GAE blocks it with a security exception.

GWT and GAE are two separate offerings by Google, but the Eclipse Plugin is the same. Unfortunately, it assumes you want to use both offerings as part of your project.

share|improve this answer
    
now it works, thank you very much! –  Eike Cochu Dec 5 '11 at 18:38
    
Your answer made my day! Good vibes to you –  Kovags Aug 16 '12 at 11:26
add comment

Sounds to me like your SecurityManager policy doesn't allow you to do the certain stuff you are doing. Are you certain that your java.policy file is applied? Can you try to call `System.setSecurityManager(null);' and attempt to connect to your db?

If during the call to setSecurityManager you get a SecurityException it would seem to me that you have a SecurityManager in place. Also, as the guy above me said:

Keep in mind that by default mysql does not listen to non-localhost interfaces, you will need to open them up yourself.

Can you try to telnet to the above address and the above port and see if everything is fine?

EDIT:

The more I look at things, the more I believe it is a MySQL configuration issue. Do you execute your pure Java code from the same machine you tried the GWT connection? How come your pure Java code could connect while even your telnet failed? Can you verify that behavior again?

share|improve this answer
    
I tried telnet but a weird error occurs... the result is in my edit6. Does this mean my mysql db is somehow unreachable? Although I am able to connect to it just fine from a normal Java Application? –  Eike Cochu Dec 3 '11 at 2:31
    
I can see your mysql is 5.1. Maybe your GWT uses different jdbc driver from your Java test. (latest JDBC is like 5.1-18 and it works fine with MySQL 5.5, not sure with 5.1 but should be fine ) –  baba Dec 3 '11 at 4:03
    
The mysql db is on my server, and I develop on my laptop. I wrote a small java program, which creates the database, the tables, and then fills them. Works perfectly from my laptop. Maybe Ill just reinstall mysql/install a mysql db somewhere else to test –  Eike Cochu Dec 3 '11 at 9:14
add comment

Keep in mind that by default mysql does not listen to non-localhost interfaces, you will need to open them up yourself.

share|improve this answer
    
But I am able to connect to my mysql db in Java... just not in GWT. –  Eike Cochu Dec 3 '11 at 1:57
    
First, ignore GWT and create a simple web application with a single servlet that connects to the database; install that into your container and test that it connects properly. If it does, continute to GWT. If it doesn't, the issue is with your servlet container. –  Tassos Bassoukos Dec 4 '11 at 9:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.