0

I am running hive jdbc code which is hosted in tomcat. I am getting the following exception.

 com.sun.jersey.spi.container.ContainerResponse.mapMappableContainerException The RuntimeException could not be mapped to a response, re-throwing to the HTTP container

java.lang.NullPointerException

at AthenaTec.Hive_ORC.RESTservice.getMsg(RESTservice.java:254)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

My code.

public class RESTservice {
final private static String driverName = "org.apache.hive.jdbc.HiveDriver";
@POST
@Path("/data")
public Response getMsg(@FormParam("data") String JSONString)
Connection con = null;
Statement prepstmt = null;
ResultSet rs = null;
JSONObject obj = new JSONObject(JSONString);
try {
String city = (String) obj.getJSONObject("page_1").get("city");
String locality = (String) obj.getJSONObject("page_1").get("locality");
String result = "'" + city + "'" + "," + locality + "'" ;
Class.forName(driverName);
con = DriverManager.getConnection("jdbc:hive2://192.168.2.40:10000/default", "ec2-user", "Abc123!@#");
prepstmt = con.createStatement();
String stmt = "INSERT INTO TABLE real_estate.addressinformation_orc VALUES(" + result + ")";
rs = prepstmt.executeQuery(stmt);
System.out.println("Query executed successfully");
return Response.status(200).entity("query executed successfully").build();
catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        System.exit(1);
    }

When i test with the postman i am getting the following exception.

java.lang.NullPointerException
AthenaTec.Hive_ORC.RESTservice.getMsg(RESTservice.java:254)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:606)
com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Cœur
  • 37,241
  • 25
  • 195
  • 267
Nimmy
  • 59
  • 1
  • 1
  • 7

0 Answers0