how to solve the error in GWT ?

Posted by megala on Stack Overflow See other posts from Stack Overflow or by megala
Published on 2010-02-25T09:56:03Z Indexed on 2010/03/26 4:43 UTC
Read the original article Hit count: 476

Filed under:

I created one GWT project in eclipse.It contained the following codings

Program 1:Creategroup

package com.crimson.creategroup;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.users.User;

@Entity(name="CreateGroup")
public class Creategroup {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Key key;
    @Basic 
    private User author;
    @Basic
    private String groupname;
    @Basic 
    private String groupid;
    @Basic  
    private String groupdesc;
    @Basic 
    private String emailper;

    public Key getKey() {
        return key;
    }
    public void setAuthor(User author) {
        this.author = author;
    }
    public User getAuthor() {
        return author;
    }
    public void setGroupname(String groupname) {
        this.groupname = groupname;
    }
    public String getGroupname() {
        return groupname;
    }
    public void setGroupid(String groupid) {
        this.groupid = groupid;
    }
    public String getGroupid() {
        return groupid;
    }
    public void setGroupdesc(String groupdesc) {
        this.groupdesc = groupdesc;
    }
    public String getGroupdesc() {
        return groupdesc;
    }
    public void setEmailper(String emailper) {
        this.emailper = emailper;
    }
    public String getEmailper() {
        return emailper;
    }
    public Creategroup(String groupname,String groupid,String groupdesc ,String emailper) {
        this.groupname = groupname;
        this.groupid = groupid;
        this.groupdesc = groupdesc;
        this.emailper=emailper;
    }
}

Program 2:Creategroupservlet

package com.crimson.creategroup;

import java.io.IOException;

import javax.persistence.EntityManager;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;
import java.util.logging.Logger;
public class Creategroupservlet extends HttpServlet{
      private static final long serialVersionUID = 1L;
        private static final Logger log = Logger.getLogger(Creategroupservlet.class.getName());

        public void doPost(HttpServletRequest req, HttpServletResponse resp)
                    throws IOException {
            UserService userService = UserServiceFactory.getUserService();
            User user = userService.getCurrentUser();


            String groupname=req.getParameter("gname");
            String groupid=req.getParameter("groupdesc");
            String groupdesc=req.getParameter("gdesc");
            String email=req.getParameter("eperm");

           if (groupname == null) {
                System.out.println("Complete all the details");
            }
            if (user != null) {
                log.info("Greeting posted by user " + user.getNickname() + "\n " + groupname+"\n" + groupid + "\n" + groupdesc + "\n" + email);
                final EntityManager em = EMF.get();
                try {
                    Creategroup group = new Creategroup(groupname,groupid,groupdesc,email);
                    em.persist(group);
                } finally {
                    em.close();
                }
            } else {
                throw new IllegalArgumentException("anonymous posts not permitted!");
            }

            resp.sendRedirect("/group.jsp");
        }
    }

Program 3:EMF

package com.crimson.creategroup;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class EMF {
    private static final EntityManagerFactory emfInstance = Persistence.createEntityManagerFactory("transactions-optional");

    private EMF() {
    }

    public static EntityManager get() {
        return emfInstance.createEntityManager();
    }
}

Program 4:index.jsp

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.google.appengine.api.users.User" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link type="text/css" rel="stylesheet" href="Group.css">
    <title>Add Group into  DataStore</title>
  </head>

  <body>
    <div id="nav">
    <%
        UserService userService = UserServiceFactory.getUserService();
        User user = userService.getCurrentUser();
        if (user != null) {
            response.sendRedirect("/group.jsp");
    %>
    <%
        } else {
    %>
           <a href="<%= userService.createLoginURL(request.getRequestURI()) %>">Sign in</a>
    <%
        }
    %>
    </div>

    <h1>Create Group</h1>

    <table>
      <tr>
        <td colspan="2" style="font-weight:bold;">
         This demo uses secured resources, so you need to be logged into your Gmail account.</td>        
      </tr>
    </table>
  </body>
</html>

program 5:group.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.List" %>
<%@ page import="javax.persistence.EntityManager" %>
<%@ page import="com.google.appengine.api.users.User" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>
<%@ page import="com.crimson.creategroup.Creategroup" %>
<%@ page import="com.crimson.creategroup.EMF" %>

<html>
  <body>

<%
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    if (user != null) {
%>
<p>Hello, <%= user.getNickname() %>! (You can
<a href="<%= userService.createLogoutURL(request.getRequestURI()) %>">sign out</a>.)</p>
<%
    } else {
        response.sendRedirect("/index.jsp");
    }
%>

<%
    final EntityManager em = EMF.get();
    try {
        String query = "select from " + Creategroup.class.getName();
        List<Creategroup> groups = (List<Creategroup>) em.createQuery(query).getResultList();
        if (groups.isEmpty()) {
%>
            <p>This table not having any group</p>
<%
        } else {
            for (Creategroup g : groups) {
%>
                <p><b><%= g.getAuthor().getNickname() %></b> wrote:</p>
                <blockquote><%= g. getGroupname() %></blockquote>
                <blockquote><%= g. getGroupid() %></blockquote>
                <blockquote><%= g. getGroupdesc() %></blockquote>
                <blockquote><%= g. getEmailper() %></blockquote>
<%
            }
        }
    } finally {
        em.close();
    }
%>

    <form action="/sign" method="post">
    <input type="text" name="Groupname" size="25">
    <input type="text" name="Groupid" size="25">
    <input type="text" name="Groupdesc" size="250">
    <input type="text" name="Emaildesc" size="25">

      <div><input type="submit" value="CREATE GROUP" /></div>
    </form>

  </body>
</html>

Program 6:Web.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
  <!-- Servlets -->
  <servlet>
    <servlet-name>Creategroupservlet</servlet-name>
    <servlet-class>com.crimson.creategroup.Creategroupservlet</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>Creategroupservlet</servlet-name>
    <url-pattern>sign in</url-pattern>
  </servlet-mapping>

  <!-- Default page to serve -->
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

Program 7:persistence.xml

<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
        http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">

    <persistence-unit name="transactions-optional">
        <provider>org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider</provider>
        <properties>
            <property name="datanucleus.NontransactionalRead" value="true"/>
            <property name="datanucleus.NontransactionalWrite" value="true"/>
            <property name="datanucleus.ConnectionURL" value="appengine"/>
        </properties>
    </persistence-unit>

</persistence

but is shows the following error

Missing required argument 'module[s]'
Google Web Toolkit 2.0.0
DevMode [-noserver] [-port port-number | "auto"] [-whitelist whitelist-string] [-blacklist blacklist-string] [-logdir directory] [-logLevel level] [-gen dir] [-codeServerPort port-number | "auto"] [-server servletContainerLauncher] [-startupUrl url] [-war dir] [-extra dir] [-workDir dir] module[s]

How to solve this thanks in advance?

© Stack Overflow or respective owner

Related posts about gwt