Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6925805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:50:13+00:00 2026-05-27T10:50:13+00:00

I am developing a simple app using GWT, Hibernate, RPC in eclipse. I am

  • 0

I am developing a simple app using GWT, Hibernate, RPC in eclipse. I am trying to display result from database on client page. In implementation of service interface, I am converting results that are in the form of list of objects to array of objects but I am getting error. Here is my code & error:

Service Interfaces:

import java.util.ArrayList;

import hibDomain.User;

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

@RemoteServiceRelativePath("testService")
public interface RpctestService extends RemoteService {

    public String addUser(String firstName,String lastName) throws IllegalArgumentException;
    public  ArrayList<User> getUser();
}
----------------

package rpctest.client;

import java.util.ArrayList;

import hibDomain.User;
import com.google.gwt.user.client.rpc.AsyncCallback;

public interface RpctestServiceAsync {

    void addUser(String firstName, String lastName,
            AsyncCallback<String> callback);

    void getUser(AsyncCallback<ArrayList<User>> asyncCallback);

}

implementation:

package rpctest.server;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
//import com.hib.HibernateUtil;

import org.hibernate.Session;
import org.hibernate.Transaction;
import hibDomain.User;
import rpctest.client.RpctestService;

public class RpctestServiceImpl extends RemoteServiceServlet  implements RpctestService {

        public String addUser(String name1, String name2)
            throws IllegalArgumentException {

              Transaction trns = null;
              Session session = HibernateUtil.getSessionFactory().openSession();
              try {
               trns = session.beginTransaction();

               User user = new User();

               user.setFirstName(name1);
               user.setLastName(name2);

               session.save(user);

               session.getTransaction().commit();
              } catch (RuntimeException e) {
               if(trns != null){
                trns.rollback();
               }
               e.printStackTrace();
              } finally{
               session.flush();
               session.close();
              }

        return name1+name2; // to test flextable entris only 
    }

    //@Override
    public  ArrayList<User> getUser()
             {

              List<User> getUser = null;

              Transaction trns = null;
              Session session = HibernateUtil.getSessionFactory().openSession();
              try {
               trns = session.beginTransaction();
               getUser = session.createQuery("from User").list();

               //* for (Iterator<User> iter = getUser.iterator(); iter.hasNext();) 
              //{
                //User user = iter.next();
                //
              //*}             

               trns.commit();
              } catch (RuntimeException e) {
               if(trns != null){
                trns.rollback();
               }
               e.printStackTrace();
              } finally{
               session.flush();
               session.close();
             }
              return getUser.toArray(new User[getUser.size()]);
        }
}

Eclipse high lights return getUser.toArray(new User[getUser.size()]); & suggests Change method return type to User[]

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:50:13+00:00Added an answer on May 27, 2026 at 10:50 am

    The method declaration says ArrayList as return type, while you are returning User[] , so Eclipse is right, and if you click on that symbol, Eclipse will suggest some corrections, which if you do, will work!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a GWT app for the Google Apps marketplace. I am using
I'm developing a simple text editing app for iPad using UITextView. I always had
I'm currently developing a simple text editing app for iPad using UITextView. I want
I'm having a problem with java sessions. I'm developing a simple web app, where
I'm developing a simple Qt 4 app and making my own dialog. I subclassed
I'm developing a desktop Mac OS X App that saves its very simple data
So I have a simple Apache with MySql I am developing a PHP app.
This is probably a simple question but I am developing a web app in
I've been developing a simple website using asp.net MVC and I'm starting to add
I've spent the last 5 months developing a gwt app, and it's now become

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.