1

I have been trying to connect a smartgwt client app to a MySQL server.
I have already created server side implementation 'MySQLConection' and client side synchronous and asynchrous interface.
I created a RPC object in my entry point class but every time I try to launch it I am getting

Line 13: No source code is available for type java.lang.ClassNotFoundException; did you forget to inherit a required module?
Line 13: No source code is available for type java.sql.SQLException; did you forget to inherit a required module?

at line 13 i have

ArrayList onLoad() throws ClassNotFoundException, SQLException, IOException;

I have already added tag in *.gwt.xml file and also include the jar files

Here is my Connection code

public Connection MySQLConnection() {
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            
            e.printStackTrace();
            return null;
        }

        Connection connection = null;

        try {
            connection = (Connection) DriverManager.getConnection(url, user, pass);

        } catch (SQLException e) {
            
            e.printStackTrace();
            return null;
        }
    
        return connection;
    }

Here is my *gwt.xml code

<module rename-to='Abc'>
    <inherits name="com.google.gwt.user.User" />
    <inherits name="com.google.gwt.user.theme.standard.Standard" />
    <inherits name="com.smartgwt.SmartGwt" />
    <entry-point class="com.xyz.client.Abc" />


    <!-- Inherit the default GWT style sheet. You can change -->
    <!-- the theme of your GWT application by uncommenting -->
    <!-- any one of the following lines. -->
    <!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
    <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
    <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->

    <!-- Other module inherits -->
    <!-- <inherits name="com.smartgwt.SmartGwt"/> -->
    <inherits name="com.smartgwt.SmartGwtNoTheme" />
    <inherits name="com.smartclient.theme.enterpriseblue.EnterpriseBlue" />
    <inherits name="com.smartclient.theme.enterpriseblue.EnterpriseBlueResources" />

    <servlet class="com.xyz.server.MySQLConnection" path="/MySQLConnection" />
    <source path='client' />
    <source path='shared' />

    

</module>

I am calling the connection in entry class as follows

rpc = (DBConnectionAsync) GWT.create(DBConnection.class);
Nimantha
  • 6,405
  • 6
  • 28
  • 69
raven
  • 23
  • 3

1 Answers1

0

You're getting this problem because you must be writing some code that accesses ClassNotFoundException, SQLException, IOException, in a class that is contained in the client folder.

Any class in this folder cannot access every Java class.

Your server side logic should be written in a class that is contained by server folder.

To understand the project structure of GWT, have a look at the following link:

https://developers.google.com/web-toolkit/doc/1.6/DevGuideOrganizingProjects#DevGuideDirectoriesPackageConventions

To understand why you cannot use every class in client package, have a look at the following link:

GWT - did you forget to inherit a required module?

Community
  • 1
  • 1
RAS
  • 8,100
  • 16
  • 64
  • 86
  • RAS i have written that logic in server folder.. but the Async interface needs the declaration of the method (which is on server logic) that i want to execute from the client code .. The problem is my method requires to throws exception so i have to mention it `void fetchNames(String Query,AsyncCallback> callback) throws SQLException, ClassNotFoundException, IOException;` – raven Jun 19 '13 at 09:39
  • yes but even if you import any of these classes, GWT will complain. You have to find an alternative. – RAS Jun 19 '13 at 09:46