Stack Exchange
Java Restful Web Service running only Android 4.4 Mobile not other
I build a Java Restfull Web Service to be called by ionic apps running on Android Mobil devices.
The code is successfully running on Android 4.4 Mobile.
but not running on any other android mobile devices  with os :android lollipop, marshmallow.
webservices web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
    <display-name>test</display-name>
    <servlet>
        <servlet-name>Jersey REST Service</servlet-name>
        <!-- <servlet-class>com.sun.jersey.server.impl.container.servlet.ServletAdaptor</servlet-class> -->
        <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>test</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Jersey REST Service</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
</web-app>

Rest webservice code
package test;

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;

@Path("/test")
public class test_Services
{
    @POST
    @Consumes("application/x-www-form-urlencoded")
    @Path("/insertTest")
    public String InsertTest(String json)
    {
        System.out.println("POST JSON>>>>>>>>>>>>>"+json);
        return json.toString();
    }
}

Rest webservice dependencies

Here is Hybride Application using ionic and angularjs code
$http({
    method: 'POST',                
    url: 'http://mapps.testlab.local:8080/test/test/insertTest',
    data: data,
    headers: {                   
        "Content-Type": "application/x-www-form-urlencoded"
    }
}).then(function successCallback(res) {
}, function errorCallback(err) {           
    deferred.reject(res.err);            
});

When i debug that using chrome on Android lollipop and marshmallow it gives me the following error:
Failed to load resource: net::ERR_NAME_NOT_RESOLVED

Please help me to fix this issue.
I am using JAVA using Eclipse Mars.1

show android code that calls the service, and if there are any error logs too

@Yazan sorry for that i cannot show you android app code.

@Yazan the error that show on android app side is "Failed to load resource: net::ERR_NAME_NOT_RESOLVED" on chrome browser.

did you try to use other clients?

@Yazan other clients means?

other browser, a code in android app...

@Yazan no, android app can only debug on chrome.

Please show the code that consumes the web service

@ACV you mean, the android app code?

@user3441151 yes. Because what you are saying doesn't make sense...

@Yazan please check android code on my update question.

check these links http://stackoverflow.com/questions/28018617/chrome-give-error-failed-to-load-resource-neterr-name-not-resolved-while and
http://stackoverflow.com/questions/4390134/failed-to-load-resource-under-chrome

@user3441151 your android code does not seems to be android code though .

@WannaBeGeek this is angular js code.

@ankitaggarwal are you want to say, this is the chrome browser problem?

it can be. try to load the same page in incognito mode and see

@ankitaggarwal if you see my code i write on my service System.out.println("POST JSON>>>>>>>>>>>>>"+json); so when Application hit service URL, tomcat log does not show anything.

@ankitaggarwal in android 4.4 case JSON print on tomcat log.

Literally, there are thousands of things that could go wrong given the information above.

@PrashantGhimire please mentioned it.

@Yazan i checked my /etc/hosts.allow on my Ubuntu server there is tomcat running and file content is "mysqld: ALL
mysqld: 192.168.1.0/255.255.255.0" so is that create any issue?

no i think this allows mysql server to get connection from any IP within the range of network 192.168.1.x already your tomcat is connecting to mysql, it's not directly approached, so this should not be an issue AFAIK

@Yazan can i debug that using Tomcat log? Is that possible when "http://mapps.testlab.local:8080/test/test/insertTest" hit by Android device Tomcat log show something?

@Yazan currently in my case when "mapps.testlab.local:8080/test/test/insertTest" hit by Android device Tomcat log does not show anything.

When you say Android 4.4 Mobile, lollipop, marshmallow is it a smartphone or an PC emulator ?

when i call ping mapps.testlab.local on my pc i get unknown host error meaning that there is no dns server that knows  how to translate "mapps.testlab.local" to an ip adress. Do all your android devices have access to a dns-server via wlan-intranet that know "mapps.testlab.local" ? or are the non-working devices connected to the internet that does not know "mapps.testlab.local"?

you must be doing something wrong. As the method is POST call to server, you can't hit the restService using simple browser and you have to use some browser extension like-POSTMAN in google chrome. First install the extension then call the webUrl using the POSTMAN. If you got some response means your api got called. Now you have to call the right api and debug the api is it working fine or not. This may resolve your issue.
As you were saying you are trying to hit the weburl from android device, but the code provided by you is not at all android source.
