GWT-RPC with MySQL problem

18 views
Skip to first unread message

Joe Williams

unread,
Jul 16, 2007, 10:25:35 AM7/16/07
to Google Web Toolkit
My application, when deployed to the local tomcat server, runs just
fine using url http://localhost:8080/example/DataAccess.html.

However, it fails in both hosted and web mode with the following
logged to the console:

"java.sql.SQLException: Cannot connect to MySQL server on localhost:
3306. Is there a MySQL server running on the machine/port you are
trying to connect to? (java.lang.NumberFormatException)"

It used to work in these two environments while I was developing the
code but I can't find out what I did to cause this situation. Any
help/pointers will be appreciated.

Reinier Zwitserloot

unread,
Jul 16, 2007, 12:07:51 PM7/16/07
to Google Web Toolkit
Two possible options here.

1) You are accessing MySQL directly from your hosted mode. This can't
possibly work. In hosted mode it looks like it works but GWT cannot
compile this because its impossible in javascript. Given that your
topic title involves 'GWT-RPC', sounds like this is NOT the case, so
on to #2:

2) Your question is not related to GWT. Please ask on another forum.
When you ask on another forum, make sure you include a lot more
details, because the only thing I can tell you is:

You cannot connect to the MySQL server on localhost; possibly you
aren't running it. //See how I read the error back to you? Errors tend
to be useful. You should read them!

The numberFormatException is interesting though. Almost sounds like a
parameter is being misread. Try and get the stacktrace of the NFE and
you might find out more.

On Jul 16, 4:25 pm, Joe Williams <joe.c.willi...@gmail.com> wrote:
> My application, when deployed to the local tomcat server, runs just

> fine using urlhttp://localhost:8080/example/DataAccess.html.

Dan Morrill

unread,
Jul 18, 2007, 8:16:23 AM7/18/07
to Google-We...@googlegroups.com
Hi, Joe!

Can you explain what you mean by "deployed to the local tomcat server"?  Is this an actual app that you have deployed previously, but are now having problems with?

You say it doesn't work in web mode, but you also say that it works "deployed to the local tomcat server".  A deployment would itself normally be web mode.  Do you mean that you compiled it previously for deployment, and that it won't compile anymore?

If so, does the compiler produce any error messages?  Also, in hosted mode, can you try running it with the argument "-logLevel TRACE" and see if that produces any additional, useful info?

- Dan

Joe Williams

unread,
Jul 18, 2007, 6:48:24 PM7/18/07
to Google Web Toolkit
Dan:

Thanks. I'm still having the problem and is making development very
cumbersome for me. I'll try and stay away from saying 'web mode' or
'hosted mode' (I'm sure I'm using the terms inorrectly being new to
Ajax and GWT). I'll just describe what I do.

I use Eclipse 3.3. If I invoke DataAccess-shell.cmd I get the error
described below after the client widgets appear in the gwt window. If
I press the 'compile/browse' button on the gwt window, a browser
window opens, the client widgets appear, but the same error occurs.

However, if I now package the binaries and generated files (this in
www/com.all.some.DataAccess) into a WAR file and transfer it to my
local tomcat server, it all works flawlessly.

This is the error that appears on the console log:

------


java.sql.SQLException: Cannot connect to MySQL server on localhost:
3306. Is there a MySQL server running on the machine/port you are
trying to connect to? (java.lang.NumberFormatException)

at com.mysql.jdbc.Connection.connectionInit(Unknown Source)
at com.mysql.jdbc.jdbc2.Connection.connectionInit(Unknown
Source)
at com.mysql.jdbc.Driver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:
525)
at java.sql.DriverManager.getConnection(DriverManager.java:
171)
at com.all.some.server.DataServlet.getData(DataServlet.java:
43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:
348)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.j:
222)
etc....
-----

(I added a printStackTrace() to the servlet)

The pertinent servlet line (43) is :

public class DataServlet extends RemoteServiceServlet implements
DataService {
...
Connection con = null;
...
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql://localhost:
3306/javatest","root",""); <=== line 43
...
con.close();
..
} catch (Exception e) {
e.printStackTrace();
}
...

I tried -logLevel TRACE : Doesn't seem to yield any better
information.

Thanks!

On Jul 18, 8:16 am, "Dan Morrill" <morri...@google.com> wrote:
> Hi, Joe!
>
> Can you explain what you mean by "deployed to the local tomcat server"? Is
> this an actual app that you have deployed previously, but are now having
> problems with?
>
> You say it doesn't work in web mode, but you also say that it works
> "deployed to the local tomcat server". A deployment would itself normally
> be web mode. Do you mean that you compiled it previously for deployment,
> and that it won't compile anymore?
>
> If so, does the compiler produce any error messages? Also, in hosted mode,
> can you try running it with the argument "-logLevel TRACE" and see if that
> produces any additional, useful info?
>
> - Dan
>

> On 7/16/07, Joe Williams <joe.c.willi...@gmail.com> wrote:
>
>
>
>
>
> > My application, when deployed to the local tomcat server, runs just

> > fine using urlhttp://localhost:8080/example/DataAccess.html.


>
> > However, it fails in both hosted and web mode with the following
> > logged to the console:
>
> > "java.sql.SQLException: Cannot connect to MySQL server on localhost:
> > 3306. Is there a MySQL server running on the machine/port you are
> > trying to connect to? (java.lang.NumberFormatException)"
>
> > It used to work in these two environments while I was developing the
> > code but I can't find out what I did to cause this situation. Any

> > help/pointers will be appreciated.- Hide quoted text -
>
> - Show quoted text -

Joe Williams

unread,
Jul 18, 2007, 1:16:31 PM7/18/07
to Google Web Toolkit
After two days, I still cannot resolve the problem. When deployed to
the local tomcat server (via a WAR file) ECERYTHING WORKS PERFECTLY,
but when I attempt DataAccess-shell.cmd (or compile/browse) in the
development environment, I get:

-------------------------


java.sql.SQLException: Cannot connect to MySQL server on localhost:
3306. Is there a MySQL server running on the machine/port you are
trying to connect to? (java.lang.NumberFormatException)

at com.mysql.jdbc.Connection.connectionInit(Unknown Source)
at com.mysql.jdbc.jdbc2.Connection.connectionInit(Unknown
Source)
at com.mysql.jdbc.Driver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:
525)
at java.sql.DriverManager.getConnection(DriverManager.java:
171)
at com.all.some.server.DataServlet.getData(DataServlet.java:

42)


at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:
348)
at

com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:
222)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:
174)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:
709)
--------------------------
and the servlet code is simply:

public class DataServlet extends RemoteServiceServlet implements
DataService {
...

public TestTaker[] getData(int skip) {


Connection con = null;
...
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql://localhost:
3306/javatest","root","");

...

The last line is line 42 mentioned in the trace above.
(replacing 'localhost' with '127.0.0.1' does not help - this
suggestion was made to someone having a similar problem nearly a year
ago)

Any help will really be appreciated.

Ian Bambury

unread,
Jul 19, 2007, 3:18:06 AM7/19/07
to Google-We...@googlegroups.com
If it works OK on another server but doesn't on your own machine and says it can't find the MySQL server when running on your own machine, then it does rather sound like MySQL isn't running on your development machine.
 
Ian

 

Joe Williams [c]

unread,
Jul 19, 2007, 6:47:44 AM7/19/07
to Google-We...@googlegroups.com
Long before I installed GWT I had a local installation of tomcat and mysql on my development machine (installed via xampp).
When I say "deployed to the local tomcat server", I'm refering to this. In fact, the full path is c:\servers\xampp\tomcat\webapps\example. I invoke the application with http://localhost:8080/example/DataAccess.html and all works fine.
Thanks.
[ SECURITY NOTICE ]
To: google-we...@googlegroups.com.
For your security, joe.c.w...@gmail.com
digitally signed this message on 19 July 2007 at 10:48:04 UTC.
Verify this digital signature at http://www.ciphire.com/verify.
[ CIPHIRE DIGITAL SIGNATURE ]

Joe Williams

unread,
Jul 19, 2007, 12:58:46 PM7/19/07
to Google Web Toolkit
I don't want to leave this thread dangling, so this post serves to
inform that I've reinstalled eclipse, GWT, and GWT Designer and all
functionaility is back to normal. Thanks for the help.

On Jul 19, 6:47 am, "Joe Williams [c]" <joe.c.willi...@gmail.com>
wrote:

Dan Morrill

unread,
Jul 19, 2007, 4:24:24 PM7/19/07
to Google-We...@googlegroups.com
Hi, Joe!

Sorry for the delay in my reply -- I've been clearing out a buried inbox.

It seems like you've got it all sorted out now, though.  Let me know if I can help with anything!

Thanks,

- Dan

prady

unread,
Sep 7, 2007, 12:50:21 AM9/7/07
to Google Web Toolkit
hi ..try giving a password to the MySQL server. dont leave blank in
the following line..

"con = DriverManager.getConnection("jdbc:mysql://localhost:3306/
javatest","root",""); "


try it & c.. :) coz i too had faced the same prob

Reply all
Reply to author
Forward
0 new messages