GWT project Class in other package can not be found in source packages ¿?
/*ERROR in FormViewer.java*/DB_Test rsTest = new DB_Test(); /*- org.ifoc.form.server.DB_Test can not be found in source packages. Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly.*/ Structure: /src -org.ifoc.form -FormViewer.gwt.xml -org.ifoc.form.client -FormViewer.java ERROR¿? -org.ifoc.form.server -DB_Conn.java -DB_Test.java ___ Form.Viewer.gwt.xml --- module inherits name=com.google.gwt.user.User/ inherits name=com.google.gwt.user.theme.standard.Standard/ entry-point class=org.ifoc.form.client.FormViewer/ inherits name=com.extjs.gxt.ui.GXT/ inherits name=org.ifoc.form.FormViewer/ inherits name=org.ifoc.form.FormViewer/ !-- -- source path='org.ifoc.form.client'/ source path='org.ifoc.form.server'/ source path='org.ifoc.form.shared'/ /module FormViewer.java - package org.ifoc.form.client; import org.ifoc.form.server.DB_Test; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.FlexTable; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.VerticalPanel; /** * Entry point classes define codeonModuleLoad()/code. */ public class FormViewer implements EntryPoint { private TextBox txtbxFirst; private Button btnSave; private TextBox txtbxLast; public void onModuleLoad() { RootPanel rootPanel = RootPanel.get(); VerticalPanel verticalPanel = new VerticalPanel(); rootPanel.add(verticalPanel, 10, 10); verticalPanel.setSize(430px, 280px); FlexTable flexTable = new FlexTable(); verticalPanel.add(flexTable); flexTable.setSize(210px, 20px); Label lblInsertAPerson = new Label(Insert a person); flexTable.setWidget(0, 1, lblInsertAPerson); Label lblFirst = new Label(First); flexTable.setWidget(1, 0, lblFirst); txtbxFirst = new TextBox(); flexTable.setWidget(1, 1, txtbxFirst); Label lblLast = new Label(Last); flexTable.setWidget(2, 0, lblLast); txtbxLast = new TextBox(); flexTable.setWidget(2, 1, txtbxLast); btnSave = new Button(Save); btnSave.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { /*ERROR*/ DB_Test rsTest = new DB_Test(); /*- org.ifoc.form.server.DB_Test can not be found in source packages. Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly.*/ rsTest.setData(txtbxFirst.getName(), txtbxLast.getName()); } }); flexTable.setWidget(3, 1, btnSave); } } DB_Test.java -- package org.ifoc.form.server; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; /** * I extend the DB_Conn abstract class, then I don't have to rewrite code * * @author branflake2267 * */ public class DB_Test extends DB_Conn { /** * constructor - nothing to do */ public DB_Test() { // nothing to do } /** * get how many chapters are in a book * * @param book * @return */ public int setData(String first, String last) { int resultado=0; String query = INSERT INTO test (first, last) VALUES ('+first +','+last+'); try { Connection connection = getConn(); Statement select = connection.createStatement(); ResultSet result = select.executeQuery(query); //rsSize = getResultSetSize(result); // size the array // clean up result.close(); connection.close(); } catch (Exception e) { System.err.println(Mysql Statement Error: + query); e.printStackTrace(); resultado = -1; } return resultado; } } .classpath ?xml version=1.0 encoding=UTF-8? classpath classpathentry kind=src path=src/
Re: GWT project Class in other package can not be found in source packages ¿?
You can't have a server class in a client class: You have import org.ifoc.form.server.DB_Test; in the class org.ifoc.form.client.FormViewer Gardella Juan 2011/2/28 jmsanchezbz jmsanche...@gmail.com /*ERROR in FormViewer.java*/DB_Test rsTest = new DB_Test(); /*- org.ifoc.form.server.DB_Test can not be found in source packages. Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly.*/ Structure: /src -org.ifoc.form -FormViewer.gwt.xml -org.ifoc.form.client -FormViewer.java ERROR¿? -org.ifoc.form.server -DB_Conn.java -DB_Test.java ___ Form.Viewer.gwt.xml --- module inherits name=com.google.gwt.user.User/ inherits name=com.google.gwt.user.theme.standard.Standard/ entry-point class=org.ifoc.form.client.FormViewer/ inherits name=com.extjs.gxt.ui.GXT/ inherits name=org.ifoc.form.FormViewer/ inherits name=org.ifoc.form.FormViewer/ !-- -- source path='org.ifoc.form.client'/ source path='org.ifoc.form.server'/ source path='org.ifoc.form.shared'/ /module FormViewer.java - package org.ifoc.form.client; import org.ifoc.form.server.DB_Test; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.FlexTable; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.VerticalPanel; /** * Entry point classes define codeonModuleLoad()/code. */ public class FormViewer implements EntryPoint { private TextBox txtbxFirst; private Button btnSave; private TextBox txtbxLast; public void onModuleLoad() { RootPanel rootPanel = RootPanel.get(); VerticalPanel verticalPanel = new VerticalPanel(); rootPanel.add(verticalPanel, 10, 10); verticalPanel.setSize(430px, 280px); FlexTable flexTable = new FlexTable(); verticalPanel.add(flexTable); flexTable.setSize(210px, 20px); Label lblInsertAPerson = new Label(Insert a person); flexTable.setWidget(0, 1, lblInsertAPerson); Label lblFirst = new Label(First); flexTable.setWidget(1, 0, lblFirst); txtbxFirst = new TextBox(); flexTable.setWidget(1, 1, txtbxFirst); Label lblLast = new Label(Last); flexTable.setWidget(2, 0, lblLast); txtbxLast = new TextBox(); flexTable.setWidget(2, 1, txtbxLast); btnSave = new Button(Save); btnSave.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { /*ERROR*/ DB_Test rsTest = new DB_Test(); /*- org.ifoc.form.server.DB_Test can not be found in source packages. Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly.*/ rsTest.setData(txtbxFirst.getName(), txtbxLast.getName()); } }); flexTable.setWidget(3, 1, btnSave); } } DB_Test.java -- package org.ifoc.form.server; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; /** * I extend the DB_Conn abstract class, then I don't have to rewrite code * * @author branflake2267 * */ public class DB_Test extends DB_Conn { /** * constructor - nothing to do */ public DB_Test() { // nothing to do } /** * get how many chapters are in a book * * @param book * @return */ public int setData(String first, String last) { int resultado=0; String query = INSERT INTO test (first, last) VALUES ('+first +','+last+'); try { Connection connection = getConn(); Statement select = connection.createStatement(); ResultSet result = select.executeQuery(query); //rsSize = getResultSetSize(result); // size the array // clean up result.close(); connection.close(); } catch (Exception e) { System.err.println(Mysql Statement Error: + query);