Unable to test restful service - java

I am very new to Restful Services and I followed some guidelines given be the boss to make it. When I am using the URL to test it via browser, it shows not found. Console is not showing any error or exception (However, I removed almost 100 errors to reach this point), but still the result is same.
This is my directory structure
This is my RDRresource.java (Includes the service I want to test)
package org.uclab.IMP.rs.rdr;
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.uclab.IMP.*;
import com.google.gson.Gson;
import org.uclab.IMP.datamodel.*;
import org.uclab.IMP.datamodel.RDR.*;
import org.uclab.IMP.datamodel.RDR.dataadapter.*;
/**
* Facade for the Restful Web service to handle the data curation functions
*/
#Path("rdr")
public class RDRresource {
#Context
private UriInfo context;
/**
* Creates a new instance of DataCurationResource
*/
public RDRresource() {
}
private static final Logger logger = LoggerFactory.getLogger(RDRresource.class);
/**
* This function is using to get user by ID
* #param UserID
* #return a list of object Users with "Error", "No Error" and new added ID
*/
#GET
#Produces("application/json")
#Consumes("application/json")
#Path("RetriveRules")
public List<Rules> RetriveRules() {
Rules objOuterRules = new Rules();
List<Rules> objListRules = new ArrayList<Rules>();
try
{
objOuterRules.setRuleID(Long.parseLong("RuleID"));
DataAccessInterface objDAInterface = new RuleDataAdapter();
AbstractDataBridge objADBridge = new DatabaseStorage(objDAInterface);
objListRules = objADBridge.RetriveRules();
logger.info("Get all rules successfully, rules Details="+objOuterRules);
}
catch(Exception ex)
{
logger.info("Error in getting user");
}
return objListRules;
}
This is my web.xml file
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Restful Web Application</display-name>
<servlet>
<servlet-name>jersey-serlvet</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>org.uclab.IMP.rs.rdr</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-serlvet</servlet-name>
<url-pattern>/webresources/*</url-pattern>
</servlet-mapping>
</web-app>
URL I am trying and result is here

Related

a strange name next to the webapp name shown in eclipse server tab

My pom is as follow:
<modelVersion>4.0.0</modelVersion>
<groupId>net.codejava</groupId>
<artifactId>EhrmsWs</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
and in eclipse,web project settings, context root is
EhrmsWs
but when I add this webapp to wildfly runtime, there is a name
MyWebsite-0.0.1-SNAPSHOT.war
where does this name come from and what does it represents?
my context root is still
http://127.0.0.1:8080/EhrmsWs
?
the application is a simple web service example, I access using postman, request is
http://127.0.0.1:8080/EhrmsWs/rest/products/
but it returns 404 - Not Found, why?
the web.xml setting is as follow:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>EhrmsWs</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>net.codejava.ws</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
the service class is as follow:
package net.codejava.ws;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
#Path("/products")
public class ProductResource {
private ProductDAO dao = ProductDAO.getInstance();
#GET
#Produces(MediaType.APPLICATION_JSON)
public Response list() {
List<Product> listProducts = dao.listAll();
if (listProducts.isEmpty()) {
return Response.noContent().build();
}
return Response.ok(listProducts).build();
}
//.....
}
[Edit on 20220816]
Now the request
http://localhost:8080/EhrmsWs/rest/products
can pass to resource ProductResource.java, but I write a similar resource TrainingHist.java with similar method as follow:
package net.codejava.ws;
import java.util.List;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
#Path("/trainingHist")
public class TrainingHistResource {
private TrainingHistDAO dao = TrainingHistDAO.getInstance();
#GET
#Produces(MediaType.APPLICATION_JSON)
public Response list() {
List<TrainingHist> listTrainingHists = dao.listAll();
if (listTrainingHists.isEmpty()) {
return Response.noContent().build();
}
return Response.ok(listTrainingHists).build();
}
}
then I send the get request
http://localhost:8080/EhrmsWs/rest/trainingHist
but it returns 404 not found, why?

There are no servelet mappings specified in web.xml for controller servelet

Hi I am trying to run my controller java but I am getting error of There are no servelet mappings specified in web.xml for controller servelet
I just wanted to ask how can to do servelet mapping I will really appreciate any advice thank you
here is my controller code
package com.kb.model;
import com.kb.model.tbl_batch;
import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.faces.bean.ManagedBean;
#ManagedBean
public class Controller extends HttpServlet {
static final long serialVersionUID = 1L;
#Override
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
HttpSession httpSession = request.getSession();
tbl_dao dao = new tbl_dao();
ArrayList<tbl_batch> list = dao.getData();
httpSession.setAttribute("studentDetails", list);
RequestDispatcher dispatcher = request
.getRequestDispatcher("500kusers_hibernate.jsp");
dispatcher.forward(request, response);
}
}
this my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com
/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>Pager Tag</display-name>
<welcome-file-list>
<welcome-file>500kusers_hibernate.jsp</welcome-file>
</welcome-file-list>
<servlet>
<display-name>Controller</display-name>
<servlet-name>Controller</servlet-name>
<servlet-class>
com.kb.model.Controller
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Controller</servlet-name>
<url-pattern>/Controller</url-pattern>
</servlet-mapping>

Cannot make Jersey 2.x hook the CORS filter

I need to enable the CORS headers on jersey server side because otherwise the Angualr frontend is getting:
XMLHttpRequest cannot load http://localhost:8080/api/products.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:9000' is therefore not allowed access.
As Jersey documentation explained I set up the filter and made it discoverable using web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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_2_5.xsd">
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>ny.devtest.endtoend.config.ApplicationConfig</param-value>
<param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
<param-name>ny.devtest.endtoend</param-name>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>*</url-pattern>
</servlet-mapping>
</web-app>
The filter interceptior implementation:
package ny.devtest.endtoend;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ContainerResponseFilter;
import javax.ws.rs.ext.Provider;
import java.io.IOException;
#Provider
public class ResponseCorsFilter implements ContainerResponseFilter {
public ResponseCorsFilter() {
System.out.println("ServerResponseFilter initialization");
}
#Override
public void filter(ContainerRequestContext containerRequestContext, ContainerResponseContext containerResponseContext) throws IOException {
containerResponseContext.getHeaders().add("X-Powered-By", "Jersey :-)");
containerResponseContext.getHeaders().add("Access-Control-Allow-Origin", "*");
containerResponseContext.getHeaders().add("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
}
}
It is not working.
UPDATE:
package ny.devtest.endtoend.config;
import ny.devtest.endtoend.api.OrderResource;
import org.eclipse.persistence.jaxb.BeanValidationMode;
import org.eclipse.persistence.jaxb.MarshallerProperties;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.moxy.json.MoxyJsonConfig;
import org.glassfish.jersey.moxy.json.MoxyJsonFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.ServerProperties;
import org.glassfish.jersey.server.validation.ValidationConfig;
import org.glassfish.jersey.server.validation.internal.InjectingConstraintValidatorFactory;
import javax.validation.ParameterNameProvider;
import javax.validation.Validation;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ResourceContext;
import javax.ws.rs.core.Context;
import javax.ws.rs.ext.ContextResolver;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
public class ApplicationConfig extends ResourceConfig {
private void ApplicationInit(){
// Resources.
packages(OrderResource.class.getPackage().getName());
// Validation.
property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
property(ServerProperties.BV_DISABLE_VALIDATE_ON_EXECUTABLE_OVERRIDE_CHECK, true);
// Providers - JSON.
register(JacksonFeature.class);
register(MoxyJsonFeature.class);
register(new MoxyJsonConfig().setFormattedOutput(true)
.property(MarshallerProperties.BEAN_VALIDATION_MODE, BeanValidationMode.NONE)
.resolver());
}
public ApplicationConfig() {
ApplicationInit();
// Bindings (#Inject)
register(new ApplicationBinder());
}
public ApplicationConfig(AbstractBinder customBinder) {
ApplicationInit();
register(customBinder);
}
#Override // << NOT WORKING
public void filter(ContainerRequestContext containerRequestContext, ContainerResponseContext containerResponseContext) throws IOException {
containerResponseContext.getHeaders().add("X-Powered-By", "Jersey :-)");
containerResponseContext.getHeaders().add("Access-Control-Allow-Origin", "*");
containerResponseContext.getHeaders().add("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
}
}
Let's try it:
package ny.devtest.endtoend.config;
import org.glassfish.jersey.server.ResourceConfig;
import ...
public class ApplicationConfig extends ResourceConfig {
private void ApplicationInit(){
// Resources.
packages(OrderResource.class.getPackage().getName());
// Register CORS filter.
register(ny.devtest.endtoend.ResponseCorsFilter.class);
// Register the rest you need
...
}
public ApplicationConfig() {
ApplicationInit();
// Bindings (#Inject)
register(new ApplicationBinder());
}
...
}
And configure in web.xml like that
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>ny.devtest.endtoend.config.ApplicationConfig</param-value>
</init-param>
<!-- Add parameter for CORS filter -->
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>
ny.devtest.endtoend
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>*</url-pattern>
</servlet-mapping>
There are a few options to configure this
The way you are trying to do (in the web.xml). With this, you are 1) specifying the wrong init-param name. It should be jersey.config.server.provider.classnames and 2) You need to specify the (fully qualified) name of the filter class as the init-param value, not the package.
You have a java configuration class (ApplicationConfig), so you can just register the filter there
If you are using package (or classpath) scanning it should automatically pick up the filter and register it, because of the #Provider annotation.
For help with 2 or 3, please show your ApplicationConfig class. I'm not sure if you are directly subclassing Application or ResourceConfig. They are different in how they are configured.

Add new endpoint to existing App Engine backend server in Android Studio

I have an App Engine backend with Google Cloud Messaging setup in my local Android Studio.
It has the original endpoints as follows:
Messaging Endpoint
Registration Endpoint
I have created a new Java file and added a new class called UserRegistration as follows:
package com.xxxxx.gcmbackend;
import com.google.api.server.spi.config.Api;
import com.google.api.server.spi.config.ApiMethod;
import com.google.api.server.spi.config.ApiNamespace;
import com.google.api.server.spi.response.CollectionResponse;
import java.util.List;
import java.util.logging.Logger;
import javax.inject.Named;
import static com.xxxxxx.gcmbackend.OfyService.ofy;
#Api(
name = "register",
version = "v1",
namespace = #ApiNamespace(
ownerDomain = "gcmbackend.xxxxx.com",
ownerName = "gcmbackend.xxxxx.com",
packagePath=""
)
)
public class UserRegistrationEndpoint {
private static final Logger log = Logger.getLogger(RegistrationEndpoint.class.getName());
#ApiMethod(name = "register")
public void registerDevice(#Named("regId") String regId, #Named("username") String username, #Named("phone") String phone) {
if(findRecord(regId) != null) {
log.info("Device " + regId + " already registered, skipping register");
return;
}
RegistrationRecord record = new RegistrationRecord();
record.setRegId(regId);
record.setUsername(username);
record.setPhone(phone);
ofy().save().entity(record).now();
}
private RegistrationRecord findRecord(String regId) {
return ofy().load().type(RegistrationRecord.class).filter("regId", regId).first().now();
}
}
However, when deployed, I don't see this endpoint in the API explorer. How do I add a new working endpoint to an App Engine backend with Google Cloud Messaging?
Going through existing code structure, I found out that every new API must be added to the web.xml file. I added my new endpoint as:
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
<filter>
<filter-name>ObjectifyFilter</filter-name>
<filter-class>com.googlecode.objectify.ObjectifyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ObjectifyFilter</filter-name>
<url-pattern></url-pattern>
</filter-mapping>
<servlet>
<servlet-name>SystemServiceServlet</servlet-name>
<servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class>
<init-param>
<param-name>services</param-name>
<param-value>com.xxxxx.gcmbackend.RegistrationEndpoint, com.xxxxx.gcmbackend.MessagingEndpoint, com.xxxxx.gcmbackend.UserRegistrationEndpoint</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>SystemServiceServlet</servlet-name>
<url-pattern>/_ah/spi/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>

restful webservice in java and mysql

I am new to the restful webservices. I am new creating restful webservice in java using jersey . This webservice is getting data from mysql database and should display the response in xml..
But i am always getting the response error 500 from apache tomcat 7. In the console no error or exception is shown except the println method is diplaying the strings passed to it..but server is giving 500 error.. Please help me
userData.java
package com.userdb;
import javax.xml.bind.annotation.XmlRootElement;
#XmlRootElement
public class userData {
public String name;
public int iduser;
public userData(){}
public userData(String name, int iduser) {
this.name = name;
this.iduser = iduser;
}
public String getName() {
return name;
}
public int getIduser() {
return iduser;
}
public void setName(String name) {
this.name = name;
}
public void setIduser(int iduser) {
this.iduser = iduser;
}
}
airtime.java
package com.userdb;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
#Path("/resttest")
public class airtime {
ResultSet rs=null;
String msg="hello";
Connection con=null;
#GET
#Produces(MediaType.APPLICATION_XML)
#Path("/get_users")
public List<userData> get_users(){
List<userData> retUser=new ArrayList<>();
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb", "root", "");
System.out.println("DriveManager");
PreparedStatement ps=con.prepareStatement("SELECT * FROM users");
rs=ps.executeQuery();
System.out.println(rs);
while(rs.next()){
userData obj=new userData();
obj.setIduser(rs.getInt("iduser"));
obj.setName(rs.getString("name"));
retUser.add(obj);
System.out.println("userData obj added to list");
}
con.close();
} catch (Exception e){
e.printStackTrace();
}
return retUser;
}
}
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>userdb</display-name>
<servlet>
<servlet-name>Jersey WebService</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.userdb</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey WebService</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
</web-app>
Solution 1:
Adjust the top of userData.java to contain the following lines at the top your file:
package com.userdb;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAccessType;
#XmlAccessorType(XmlAccessType.FIELD)
#XmlRootElement
public class userData
{...}
Explanation: You will notice that an XmlAccessorType annotation and an XMLAccessType has been added. This configuration is required when using setters in your object. You will notice that adjusting the code to not use setters (with the above excluded) will also allow you to view your RESTful service in a browser.
Solution 2:
A quicker alternative, is to set your public variables name and iduser to private. This will also avoid the clash when mapping to xml.
There should be a warning something like "...messagebodywriter not found for media type=application/xml ...".
The possible cause may be that you didn't include this dependency.
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-jaxb</artifactId>
<version>2.21.1</version>
</dependency>
this is my workable pom dependencies
<dependencies>
<!-- jersey dependency -->
<dependency>
<groupId>org.glassfish.jersey.bundles</groupId>
<artifactId>jaxrs-ri</artifactId>
<version>2.21.1</version>
</dependency>
<!-- make jersey auto marshel to json -->
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.21.1</version>
</dependency>
<!-- make jersey auto marshel to xml -->
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-jaxb</artifactId>
<version>2.21.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>stax2-api</artifactId>
<version>3.1.4</version>
</dependency>
</dependencies>
a workable web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>Rest</display-name>
<servlet>
<servlet-name>MyApplication</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.blithe.resource</param-value>
</init-param>
<init-param>
<param-name>jersey.config.server.provider.scanning.recursive</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>MyApplication</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
</web-app>
workable resource
package com.blithe.resource;
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import com.blithe.model.User;
#Path("helloworld")
public class HelloWorldResource
{
#GET
#Produces(MediaType.APPLICATION_XML)
public List<User> getStringArray(){
List<User> list = new ArrayList<>();
User u = new User();
u.setName("testName");
list.add(u);
return list;
}
}
and the model
package com.blithe.model;
import javax.xml.bind.annotation.XmlRootElement;
#XmlRootElement
public class User {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Hope this will help you.
By the way, it is better not to include too many dependencies which might duplicate in your pom.xml, since some of them might conflict to each other. And it will cost a lot of time on debugging. So it's better to find out what dependencies are really needed.
Cheers!
Gregory Nikitas is right. The issue in your model class should also be taken care of.

Categories