Добрый день.
Пытаюсь сделать первую программы на Java для Web.
В NetBeans 7.4 создал проект Веб-приложение. + добавил платформу GWT и Hibernate
Подправил/добавил файлы, но проект не компилируется.
1.
2.
3.
4.
5.
6.
7.
8.
GWT Compiling client-side code.
Compiling module org.yournamehere.Main
Finding entry point classes
[ERROR] Unable to find type 'org.yournamehere.client.MainEntryPoint'
[ERROR] Hint: Previous compiler errors may have made this type unavailable
[ERROR] Hint: 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
C:\Users\ivan\Documents\NetBeansProjects\HelloWeb\nbproject\build-gwt.xml:331: The following error occurred while executing this line:
C:\Users\ivan\Documents\NetBeansProjects\HelloWeb\nbproject\build-gwt.xml:480: Java returned: 1
В чем может быть проблема?
Файлы.
web.xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<servlet>
<servlet-name>GWTService</servlet-name>
<servlet-class>org.yournamehere.server.sampleservice.GWTServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>GWTService</servlet-name>
<url-pattern>/org.yournamehere.Main/sampleservice/gwtservice</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>welcomeGWT.html</welcome-file>
</welcome-file-list>
</web-app>
hibernate.cfg.xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.FirebirdDialect</property>
<property name="hibernate.connection.driver_class">org.firebirdsql.jdbc.FBDriver</property>
<property name="hibernate.connection.url">jdbc:firebirdsql:localhost:web</property>
<property name="hibernate.connection.username">SYSDBA</property>
<property name="hibernate.connection.password">masterkey</property>
<mapping class="org.yournamehere.logic.Product"/>
</session-factory>
</hibernate-configuration>
Main.gwt.xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.7.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.7.0/distro-source/core/src/gwt-module.dtd">
<module>
<inherits name="com.google.gwt.user.User"/>
<entry-point class="org.yournamehere.client.MainEntryPoint"/>
<source path="logic"/>
<!-- Do not define servlets here, use web.xml -->
</module>
MainEntryPoint.java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
package org.yournamehere.client;
//GWTServiceUsageExample.java
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import org.yournamehere.client.sampleservice.GWTService;
import org.yournamehere.client.sampleservice.GWTServiceAsync;
import org.yournamehere.logic.Product;
public class MainEntryPoint implements EntryPoint {
public MainEntryPoint() {
}
public static GWTServiceAsync getService() {
return GWT.create(GWTService.class);
}
public void onModuleLoad() {
final Label tex = new Label();
Product p = new Product();
p.setName("Один");
p.setProduct(1);
//create an async callback to handle the result:
AsyncCallback callback = new AsyncCallback() {
@Override
public void onFailure(Throwable arg0) {
//display error text if we can't get the quote:
tex.setText("Errot");
}
@Override
public void onSuccess(Object result) {
//display the retrieved quote in the label:
tex.setText((String) result);
}
};
getService().setProduct(p,callback);
}
}
GWTService.java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
package org.yournamehere.client.sampleservice;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
import org.yournamehere.logic.Product;
@RemoteServiceRelativePath("sampleservice/gwtservice")
public interface GWTService extends RemoteService {
public String setProduct(Product p);
}
GWTServiceAsync.java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
package org.yournamehere.client.sampleservice;
import com.google.gwt.user.client.rpc.AsyncCallback;
import org.yournamehere.logic.Product;
/**
*
* @author ivan
*/
public interface GWTServiceAsync {
public void setProduct(Product p, AsyncCallback<String> asyncCallback);
}
HibernateUtil.java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
package org.yournamehere.client.sampleservice;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.SessionFactory;
/**
* Hibernate Utility class with a convenient method to get Session Factory
* object.
*
* @author ivan
*/
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
// Create the SessionFactory from standard (hibernate.cfg.xml)
// config file.
sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
} catch (Throwable ex) {
// Log the exception.
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
Product.java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
package org.yournamehere.logic;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
@Table(name = "PRODUCT")
public class Product {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "GEN_PRODUCT_ID")
@SequenceGenerator(allocationSize = 1,name = "GEN_PRODUCT_ID", sequenceName = "GEN_PRODUCT_ID")
@Column(name = "NAME", length = 50)
private int product;
@Column(name = "NAME")
String name;
public Product() {
}
public String getName() {
return name;
}
public int getProduct() {
return product;
}
public void setName(String name) {
this.name = name;
}
public void setProduct(int prod) {
this.product = prod;
}
}
GWTServiceImpl.java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
package org.yournamehere.server.sampleservice;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import org.hibernate.Session;
import org.yournamehere.client.sampleservice.GWTService;
import org.yournamehere.client.sampleservice.HibernateUtil;
import org.yournamehere.logic.Product;
/**
*
* @author ivan
*/
public class GWTServiceImpl extends RemoteServiceServlet implements GWTService {
@Override
public String setProduct(Product p) {
Session sess = null;
try
{
sess = HibernateUtil.getSessionFactory().openSession();
sess.beginTransaction();
sess.save(p);
sess.getTransaction().commit();
}
catch(Exception ex)
{
return "NO";
}finally
{
if(sess != null && sess.isOpen())
sess.close();
}
return "Yes";
}
}
Структура файлов