Connecting to database with eclipse

4 views
Skip to first unread message

Cryssyenddo

unread,
Apr 4, 2009, 8:14:51 AM4/4/09
to Google Web Toolkit
Hi,

I'm fresh to GWT.
I'm using eclipse to develop a GWT appication and i'm having problems
connecting to my database.

project name is vCarePortal. I've included my JDBC in eclipse in the
project libraries, and here's my method at my vCarePortal.server
package:

private Statement stmt;
private String url = "jdbc:mysql://cpcc-2009:3306/";
private String db = "charityportal";
private String driver = "com.mysql.jdbc.Driver";
private String user = "root";
private String password = "password";

/** Connect to database */
public void connectDatabase(){
try{

Class.forName(driver);
System.out.println("Driver loaded");

Connection connection = DriverManager.getConnection(url
+db,user,password);
System.out.println("Database Connected");

stmt = connection.createStatement();
}



catch (Exception ex) {
ex.printStackTrace();
}
}

But when i tried to run it, these errors popped out:

[ERROR] Unable to instantiate
'vCarePortal.server.DiscussionBoardServiceImpl'
java.lang.ClassNotFoundException:
vCarePortal.server.DiscussionBoardServiceImpl
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.google.gwt.dev.shell.GWTShellServlet.tryGetOrLoadServlet
(GWTShellServlet.java:936)
at com.google.gwt.dev.shell.GWTShellServlet.service
(GWTShellServlet.java:277)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext
(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal
(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext
(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext
(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke
(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext
(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext
(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:
929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:
160)
at org.apache.coyote.http11.Http11Processor.process
(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol
$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt
(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run
(ThreadPool.java:683)
at java.lang.Thread.run(Unknown Source)


I have no idea what is wrong with my method here. Can anyone please
help me?

Vitali Lovich

unread,
Apr 5, 2009, 1:53:55 AM4/5/09
to Google-We...@googlegroups.com
It seems like a problem with your client-side code. I'm pretty sure
it's a problem with your web.xml file (not declaring your servlet) or
with the path you use to instantiate the RPC interface.

Cryssyenddo

unread,
Apr 5, 2009, 5:00:40 AM4/5/09
to Google Web Toolkit
I found two web.xml in my project files,

first one in tomcat -> conf -> gwt
which has a long list of session mapping and mime mapping

second web.xml file is in tomcat -> webapps -> ROOT -> WEB-INF which
looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<web-app>

<servlet>
<servlet-name>shell</servlet-name>
<servlet-class>com.google.gwt.dev.shell.GWTShellServlet</servlet-
class>
</servlet>

<servlet-mapping>
<servlet-name>shell</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>

</web-app>

could anyone please tell me how to declare my jdbc here?

Thanks a million...


Vitali Lovich

unread,
Apr 5, 2009, 5:17:37 AM4/5/09
to Google-We...@googlegroups.com
I dunno about the JDBC configuration, but you're servlet mapping seems
wrong - it should, AFAIK, point to your RPC class, not some GWT class
(unless that's what you called it?). As for setting up JDBC with
tomcat, a simple google search should help you.

Cryssyenddo

unread,
Apr 5, 2009, 5:37:58 AM4/5/09
to Google Web Toolkit
Do you mean this part?:

<servlet>
<servlet-name>shell</servlet-name>
<servlet-
class>com.google.gwt.dev.shell.GWTShellServlet</servlet-class>
</servlet>

I was wondering if changed these mapping, would be able to test run my
GWT app in hosted mode?


On the other hand, I thought i just need to point to my RPC class in
my module xml as in like eg. my module name is DiscussionBoard, so i
did this in my "DicussionBoard.gwt.xml":

<module>

<!-- Inherit the core Web Toolkit stuff.
-->
<inherits name='com.google.gwt.user.User'/>

<!-- Specify the app entry point class.
-->
<entry-point class='vCarePortal.client.DiscussionBoard'/>

<!-- Specify the remote services path -->
<servlet path="/DiscussionBoardServices"
class="vCarePortal.server.DiscussionBoardServiceImpl" />

<!-- Specify the application specific style sheet.
-->
<stylesheet src='DiscussionBoard.css' />



</module>

Vitali Lovich

unread,
Apr 5, 2009, 5:52:03 AM4/5/09
to Google-We...@googlegroups.com
The gwt.xml is for the gwt framework & is used, I believe, during the
compilation phase so that the compiler generates the appropriate RPC
calls & knows how to compile your code.

How are you planning on running your app in hosted mode through
compiled javascript deployed in tomcat? Contradiction. Either you
run in hosted mode where GWT uses javascript magic to communicate with
special wrapper code that interfaces the browser with your code
running in a real JVM, or you trully compile the code into javascript
& have the browser execute the code natively.

The servlet mapping has absolutely nothing to do with the above
(except for it having to match up with the client code). It informs
the application server (Tomcat in your example) how to configure the
server-side code.

So what you've done in your example is redirected all HTTP
communication targetted at your server to GWTShellServlet. What you
probably want is:


<servlet>
<servlet-name>shell</servlet-name>
<servlet-
class>vCarePortal.server.DiscussionBoardServiceImpl</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>shell</servlet-name>
<url-pattern>DicussionBoard/DiscussionBoardServices</url-pattern>
</servlet-mapping>

the url-pattern, I believe, should be modulename/path-set-up-in-client-code

I haven't used the old tomcat set up in a long time, so your mileage
may vary (but the above seems right & pretty close to the 1.6
configuration).

Cryssyenddo

unread,
Apr 5, 2009, 7:02:25 AM4/5/09
to Google Web Toolkit
Thanks, but when i applied the changes...here's what i got:

HTTP Status 404 - /vCarePortal.DiscussionBoard/DiscussionBoard.html

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

type Status report

message /vCarePortal.DiscussionBoard/DiscussionBoard.html

description The requested resource (/vCarePortal.DiscussionBoard/
DiscussionBoard.html) is not available.


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


does it has anything to do with the Tomcat's version? Because i'm
using Apache Tomcat 5.0.28

Cryssyenddo

unread,
Apr 5, 2009, 7:06:14 AM4/5/09
to Google Web Toolkit
oh, by the way, i got these errors too:

[WARN] Parse error in application web.xml
org.xml.sax.SAXParseException: Error at (12, 20: Invalid <url-pattern>
DiscussionBoard/DiscussionBoardServices in servlet mapping
at org.apache.commons.digester.Digester.createSAXException
(Digester.java:2540)
at org.apache.commons.digester.Digester.createSAXException
(Digester.java:2566)
at org.apache.commons.digester.Digester.endElement(Digester.java:
1061)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement
(Unknown Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement
(Unknown Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl
$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next
(Unknown Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument
(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse
(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse
(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown
Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse
(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl
$JAXPSAXParser.parse(Unknown Source)
at org.apache.commons.digester.Digester.parse(Digester.java:1548)
at org.apache.catalina.startup.ContextConfig.applicationConfig
(ContextConfig.java:263)
at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:
624)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent
(ContextConfig.java:216)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent
(LifecycleSupport.java:119)
at org.apache.catalina.core.StandardContext.start
(StandardContext.java:4290)
at org.apache.catalina.core.ContainerBase.addChildInternal
(ContainerBase.java:823)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:
807)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:
595)
at org.apache.catalina.core.StandardHostDeployer.install
(StandardHostDeployer.java:277)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:
832)
at org.apache.catalina.startup.HostConfig.deployDirectories
(HostConfig.java:701)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:
432)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:983)
at org.apache.catalina.startup.HostConfig.lifecycleEvent
(HostConfig.java:349)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent
(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:
1091)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:
1083)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:
478)
at org.apache.catalina.startup.Embedded.start(Embedded.java:846)
at com.google.gwt.dev.shell.tomcat.EmbeddedTomcatServer.<init>
(EmbeddedTomcatServer.java:244)
at com.google.gwt.dev.shell.tomcat.EmbeddedTomcatServer.start
(EmbeddedTomcatServer.java:69)
at com.google.gwt.dev.GWTShell.startUp(GWTShell.java:778)
at com.google.gwt.dev.GWTShell.run(GWTShell.java:582)
at com.google.gwt.dev.GWTShell.main(GWTShell.java:357)

does it mean that my RPC services aren't working?

Cryssyenddo

unread,
Apr 7, 2009, 11:15:36 AM4/7/09
to Google Web Toolkit
Anyone? please? i need this to work...

eggsy

unread,
Apr 8, 2009, 4:08:57 AM4/8/09
to Google Web Toolkit
Hi there,

Ok lets take it step by step.

Can you show us your client side RPC interface classes.

You should have something like the following:

-------
package com.company.client.rpc;

import java.util.List;

import com.company.client.dto.PupilDTO;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

@RemoteServiceRelativePath("teachers")
public interface TeacherService extends RemoteService
{
public List<PupilDTO> getPupils(Integer teacherId);
}

-----


package com.company.client.rpc;

import java.util.List;

import com.company.client.dto.PupilDTO;
import com.google.gwt.user.client.rpc.AsyncCallback;

public interface TeacherServiceAsync
{
public void getPupils(Integer teacherId,
AsyncCallback<List<PupilDTO>> callback);
}


----

Take not of the @RemoteServiceRelativePath("teachers") thats very
important. Do you have this?

Eggsy

Cryssyenddo

unread,
Apr 8, 2009, 8:41:08 AM4/8/09
to Google Web Toolkit
No, i don't have it. Here's my client side RPC interface:



package vCarePortal.client;

import java.sql.Date;
import com.google.gwt.user.client.rpc.AsyncCallback;

public interface DiscussionBoardServiceAsync {

public void getForums(int forumAccessLevel, AsyncCallback<Forum[]>
callback);

public void getTopics(int forumID, int topicAccessLevel,
AsyncCallback<Topic[]> callback);

public void getThreads(int topicID, int threadAccessLevel,
AsyncCallback<Thread[]> callback);

public void getDiscussionPosts(int threadID, AsyncCallback<ThreadReply
[]> callback);

public void getUser(String password, String userID,
AsyncCallback<Contributor> callback);

public void countThreads(int topicID, AsyncCallback<Integer>
callback);

public void countThreadReplies(int threadID, AsyncCallback<Integer>
callback);

public void getLatestThreadReply (int threadID, AsyncCallback<String[]
> callback);

public void getImageURL (String imageID, AsyncCallback<String>
callback);


public void createForum(String forumName, String forumDescription,
String userID, int accessLevel, AsyncCallback<Void> callback);

public void modifyForum (int forumID, String forumName, String
forumDescription, int accessLevel, AsyncCallback<Void> callback);

public void deteleForum (int forumID, AsyncCallback<Void> callback);

public void createTopic (String topicTitle, String topicDescription,
int topicAccessLevel, String creatorID, int forumID,
AsyncCallback<Void> callback);

public void modifyTopic(int topicID, String topicName, String
topicDescription, int topicAccessLevel, AsyncCallback<Void> callback);

public void deteleTopic (int topicID, AsyncCallback<Void> callback);

public void addThread (String threadTitle, String threadDesc, int
threadAccessLevel, int threadCreatorID, int topicID,
AsyncCallback<Void> callback);

public void modifyThread(int threadID, String threadTilte, String
threadDescription, int threadAcessLevel, AsyncCallback<Void>
callback);

public void deleteThread(int threadID, AsyncCallback<Void> callback);

public void addThreadReply(int threadID, int replierID, Date
replyTimestamp, String replyContent, AsyncCallback<Void> callback);

public void modifyThreadReply(int threadReplyID, Date
modifyTimestamp, String replyContent, AsyncCallback<Void> callback);

public void deleteThreadReply(int threadReplyID, AsyncCallback<Void>
callback);
}

Cryssyenddo

unread,
Apr 8, 2009, 8:44:05 AM4/8/09
to Google Web Toolkit
package vCarePortal.client;

import java.sql.Date;

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

public interface DiscussionBoardService extends RemoteService {

public Forum[] getForums(int forumAccessLevel);

public Topic[] getTopics(int forumID, int topicAccessLevel);

public Thread[] getThreads(int topicID, int threadAccessLevel);

public ThreadReply[] getDiscussionPosts(int threadID);

public Contributor getUser(String password, String userID);

public int countThreads(int topicID);

public int countThreadReplies(int threadID);

public String[] getLatestThreadReply (int threadID);

public String getImageURL (String imageID);


public void createForum(String forumName, String forumDescription,
String userID, int accessLevel);

public void modifyForum (int forumID, String forumName, String
forumDescription, int accessLevel);

public void deteleForum (int forumID);

public void createTopic (String topicTitle, String topicDescription,
int topicAccessLevel, String creatorID, int forumID);

public void modifyTopic(int topicID, String topicName, String
topicDescription, int topicAccessLevel);

public void deteleTopic (int topicID);

public void addThread (String threadTitle, String threadDesc, int
threadAccessLevel, int threadCreatorID, int topicID);

public void modifyThread(int threadID, String threadTilte, String
threadDescription, int threadAcessLevel);

public void deleteThread(int threadID);

public void addThreadReply(int threadID, int replierID, Date
replyTimestamp, String replyContent);

public void modifyThreadReply(int threadReplyID, Date
modifyTimestamp, String replyContent);

public void deleteThreadReply(int threadReplyID);
}

eggsy

unread,
Apr 8, 2009, 10:36:27 AM4/8/09
to Google Web Toolkit
Are you using GWT 1.4 or 1.5?

If you are using 1.5 add the line:

@RemoteServiceRelativePath("teachers")

in the same place as where I have mine - replace teachers with
whatever path you want for your servlet.

next thing is how to call the servlet using RPC this should be done
like so:

TeacherServiceAsync teacherService = (TeacherServiceAsync) GWT.create
(TeacherService.class);

teacherService.getPupils(teacherId, new AsyncCallback<List<PupilDTO>>
()
{

public void onFailure(Throwable caught)
{
// TODO Auto-generated method stub

}

public void onSuccess(List<PupilDTO> result)
{
// TODO Do something with the result
}

});

----

You can see how my client side code matches up now - is this making
sense so far and do you have something similar? This is how GWT RPC
should be implemented client side.

eggsy

unread,
Apr 8, 2009, 10:40:49 AM4/8/09
to Google Web Toolkit
Next you need to have server side class something like this:

-----
package com.company.server.gwt;
public class TeacherServiceImpl extends RemoteServiceServlet
implements TeacherService
{
private static final long serialVersionUID = 1L;

public List<PupilDTO> getPupils(Integer teacherId)
{
List<PupilDTO> results = performYourServerSideAction();
return results;
}

}


---

Then in your GWT.xml file you need to link the server to the client
with servlet mappings like so:

<servlet path="/teachers"
class="com.company.server.gwt.TeacherServiceImpl"/>

Notice I use /teachers to map to my server side class.

Thats pretty much it. Your DB code that you have already shown us
should go on the server side either in your ServiceImpl class or
another server side bean (preferred)
Message has been deleted

Cryssyenddo

unread,
Apr 8, 2009, 11:03:09 AM4/8/09
to Google Web Toolkit
I've made the modifications to my codes, and yet the same error still
pop out...here's the modifications i've done:


package vCarePortal.client;

import java.sql.Date;

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

@RemoteServiceRelativePath("DiscussionBoardServices")
public interface DiscussionBoardService extends RemoteService {

public Forum[] getForums(int forumAccessLevel);

public Topic[] getTopics(int forumID, int topicAccessLevel);

public Thread[] getThreads(int topicID, int threadAccessLevel);

public ThreadReply[] getDiscussionPosts(int threadID);

public Contributor getUser(String password, String userID);
----------------------------------------------------------------------------------------------------------

As you suggested, I've seperated the sql queries from my impl class:


package vCarePortal.server;

import java.sql.Date;

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

import vCarePortal.client.Contributor;
import vCarePortal.client.DiscussionBoardService;
import vCarePortal.client.Topic;
import vCarePortal.client.Forum;
import vCarePortal.client.Thread;
import vCarePortal.client.ThreadReply;


public abstract class DiscusisonBoardServiceImpl extends
RemoteServiceServlet
implements DiscussionBoardService{


/**
* Get information on all forums
*/
public Forum[] getForums(int forumAccessLevel) {

return QueryExecutor.getForums(forumAccessLevel);
}

/**
* Get topics of selected forum
*/
public Topic[] getTopics(int forumID, int accessLevel){

return QueryExecutor.getTopics(forumID, accessLevel);
}


-----------------------------------------------------------------------------------
Here's the connector class:



package vCarePortal.server;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class DatabaseConnector {

private static Statement stmt;
private static String url = "jdbc:mysql://cpcc-2009:3306/";
private static String db = "charityportal";
private static String driver = "com.mysql.jdbc.Driver";
private static String user = "root";
private static String password = "Abcd1234";
private static Connection connection;

public static Statement getConnection(){
try{

Class.forName(driver);
System.out.println("Driver loaded");

connection = DriverManager.getConnection(url
+db,user,password);
System.out.println("Database Connected");

stmt = connection.createStatement();
}
catch (Exception ex) {
ex.printStackTrace();
}
return stmt;
}

public static void closeConnection(){
try{
stmt.close();
connection.close();
}
catch(Exception e){
e.getMessage();
}

}
}
____________________________________________________________

And then here's my gwt.xml file:

<module>

<!-- Inherit the core Web Toolkit stuff.
-->
<inherits name='com.google.gwt.user.User'/>

<!-- Other module inherits
-->

Cryssyenddo

unread,
Apr 8, 2009, 11:06:19 AM4/8/09
to Google Web Toolkit
and by the way, i'm using gwt1.5.3

Cryssyenddo

unread,
Apr 8, 2009, 11:38:32 AM4/8/09
to Google Web Toolkit
I solved the problem...I made a typo error at my impl class.
I've made the corrections and it works now.

I'm wondering, how should i call a service properly? In this piece of
code below, i'm trying to get an array Forum object which the data i
retrieved form my database and then i intend topopulate my panel with
the buttons with each representing a forum.

I've double checked that my database wasn't empty. But I kept hitting
a null exception. So i'm wondering did i call the services the right
way. Here are the two methods i used; first for calling the RPC to get
all the forum records and the second method to populate the panel with
forum buttons:



/**
* Method to retrieve list of forums from server
*/
protected void getForums() {
if(services == null){
services = (DiscussionBoardServiceAsync)GWT.create
(DiscussionBoardService.class);
}

ServiceDefTarget serviceURL = (ServiceDefTarget) services;
String address = GWT.getModuleBaseURL()
+"DiscussionBoardServices";
serviceURL.setServiceEntryPoint(address);

AsyncCallback<Forum[]> callback = new AsyncCallback<Forum[]>()
{
public void onFailure(Throwable caught) {
String details = caught.getMessage();
Window.alert(details);
}
public void onSuccess(Forum[] result) {
buildMainPage(result);
}
};

services.getForums(user.getUserClass(), callback);
}

/**
* Method to build and display main page display contents
* @param receivedForumList
*/
private void buildMainPage(Forum[] receivedForumList){
// Initialise all components
discussionBoardTitle = new Label("v-Care Discussion Board
Title");
main_Panel = new VerticalPanel();
main_Selection = new HorizontalPanel();
forumList = new Forum[receivedForumList.length];
forumButtons = new Button[receivedForumList.length];

pageFlag = PAGE_MAIN;

forumButtonListsner = new ForumButtonListener();

main_Panel.setCellHorizontalAlignment(discussionBoardTitle,
HasHorizontalAlignment.ALIGN_CENTER);

for(int i =0; i<receivedForumList.length; i++){
forumButtons[i] = new Button(receivedForumList[i].getForumName
());
forumButtons[i].addClickListener(forumButtonListsner);
forumButtons[i].setStyleName("forumButton");
forumList[i] = receivedForumList[i];

main_Selection.add(forumButtons[i]);
}

// If user is admin then insert admin options
if (userClass <= 2) {
// Create admin buttons
admin_AddForumButton = new Button("Add Forum");

// Add button listeners
admin_AddForumButton.addClickListener(this);

// Add admin options
main_Panel.insert(main_AdminOptions, 1);
}

RootPanel.get().clear();
RootPanel.get().add(main_Panel);
}

eggsy

unread,
Apr 8, 2009, 11:54:22 AM4/8/09
to Google Web Toolkit
Can you confirm (server side) that the array of objects isn't null?

If so this sounds like GWT might not be able to handle objects of type
Forum.

GWT can only handle objects declared under the client side packages
and wont be able to handle any database POJO object declared at server
level.

For some more background info:

http://www.dotnetguru2.org/bmarchesson/index.php?p=786&more=1&c=1&tb=1&pb=1

You'll need to create some form of client side DTO object
alternatively if you can move over to using Hibernate you can use a
package called Hibernate4GWT

I've also compiled a tutorial on this at:

http://eggsylife.blogspot.com/2007/11/hibernate-spring-google-web-toolkit.html

That is part two of the tutorial with my DTO objects.

Cryssyenddo

unread,
Apr 8, 2009, 12:16:20 PM4/8/09
to Google Web Toolkit
Yes, i did created an object class "Forum" at client side, and i've
just confirmed that the array from server side is null.

I've found out the problem with result set is we can do execute
queries one after another...so i changed the order of my result set
codes, that solves the problem.

Anyway, thanks a million for helping me through that database
connection and RPC declaring problem, i really appreciate that :D

eggsy

unread,
Apr 9, 2009, 5:40:07 AM4/9/09
to Google Web Toolkit
No worries!!

Glad you got it sorted

Eggsy
Reply all
Reply to author
Forward
0 new messages