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 1072071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:48:06+00:00 2026-05-16T20:48:06+00:00

I am writing an application where i have to interact with MS SQL database.

  • 0

I am writing an application where i have to interact with MS SQL database. In my application i am creating web services (using javax.jws) for accessing database tables. i am creating one operation(method) in web service with return type java.lang.Object[][] as follows :

@WebMethod(operationName = “get_HistoryInfoByUser”)

public java.lang.Object[][] get_HistoryInfoByUser(@WebParam(name = "email_Id")
String email_Id) throws Exception{
   java.lang.Object[][] historyInfo = null;

     // some code here

  return historyInfo;
}

and for calling web service operation(method) in my application, i am writing following
code:

public Object[][] get_HistoryInfoByUser(String email_Id) {

      java.util.List<net.java.dev.jaxb.array.AnyTypeArray> historyInfo = null;

    try {

        historyInfo = port.getHistoryInfoByUser(email_Id);

    } catch (Exception_Exception ex) {
        ex.printStackTrace();
    }
       return (Object[][]) historyInfo.toArray();
 }

but i am getting an Exception

Exception in thread “Thread-8”
java.lang.ClassCastException:
[Ljava.lang.Object; cannot be cast to
[[Ljava.lang.Object;

Web service operation return type is java.util.List(net.java.dev.jaxb.array.AnyTypeArray)
and i need return type java.lang.Object[][].

Please can you give me any suggestion, which will help me to overcome with this problem.

  • 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-16T20:48:06+00:00Added an answer on May 16, 2026 at 8:48 pm

    Casting is not used for transforming objects, it’s used for reclassifying the type of an object. It is there to tell the compiler that a variable should be treated like a different class. If you try to cast a variable to some type it is not compatible with, you get the ClassCastException.

    Object ojc = new ArrayList();
    obj.add(new Object()); //Compiler error because Object does not have an add method
    ArrayList lst = (ArrayList)obj;
    lst.add(new Object()); //Works because now the compiler knows that the variable is an ArrayList
    MyClass myClass = (MyClass)obj; //ClassCastException because the object is not actually a MyClass object
    myClass.add(new Object()); //Assuming MyClass defines and add method that takes and object, this line compiles
    

    In your case, Object[] and Object[][] are completely different types and not something that you can cast between. Instead, you need to first make the 2D array and then set your array to be the first member of the 2D array.

    Object[][] result = new Object[1][];
    result[0] = historyInfo.toArray();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently writing a web application that have about 6-12 pages. On each one
I have been writing an application using ASP.Net MVC4, where the majority of the
I am writing an application that writes to SQL Compact files that have a
I'm writing an application which have two modes; one view mode and one edit
I'm writing single-page web application. Client interacts with server using AJAX retrieving quite complex
I am writing an application which will have around 5 tables and records up
I am writing a web application using PHP. I want to use the MVC
I am writing an application to interact with smart card currently using Java. I
I'm writing an application which have to take a picture and send it to
I am writing a PHP application that will have the ability to edit settings

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.