Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Restful webservice error .A HTTP GET method,... throws java.sql.SQLException, should not consume any

DevM3Oct 27 2016

I'm trying to create a restful service that take some parameters and retrieve data . First I created java class and method to write my business after that I created the restful service.

When I test I get the following error.

<org.glassfish.jersey.internal.Errors> <Errors> <logErrors> <Following issues have been detected:

WARNING: A HTTP GET method, public java.lang.String restservice.getEmployees.getEmpDepartement(java.lang.Integer) throws java.sql.SQLException, should not consume any form parameter.

>

<Oct 27, 2016 2:51:10 PM AST> <Error> <HTTP> <BEA-101216> <Servlet: "Jersey" failed to preload on startup in Web application: "RestWS-RestService-context-root".

org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.

[[FATAL] A HTTP GET method, public java.lang.String restservice.getEmployees.getEmpDepartement(java.lang.Integer) throws java.sql.SQLException, should not consume any form parameter.; source='ResourceMethod{httpMethod=GET, consumedTypes=[], producedTypes=[application/xml], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class restservice.getEmployees, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@68a00d2d]}, definitionMethod=public java.lang.String restservice.getEmployees.getEmpDepartement(java.lang.Integer) throws java.sql.SQLException, parameters=[Parameter [type=class java.lang.Integer, source=EmpNo, defaultValue=null]], responseType=class java.lang.String}, nameBindings=[]}']

    at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:444)

    at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:162)

    at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:304)

    at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)

    at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)

    Truncated. see log file for complete stacktrace

>

<Oct 27, 2016 2:51:10 PM AST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID "102657007781914" for task "0". Error is: "weblogic.application.ModuleException: org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.

[[FATAL] A HTTP GET method, public java.lang.String restservice.getEmployees.getEmpDepartement(java.lang.Integer) throws java.sql.SQLException, should not consume any form parameter.; source='ResourceMethod{httpMethod=GET, consumedTypes=[], producedTypes=[application/xml], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class restservice.getEmployees, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@68a00d2d]}, definitionMethod=public java.lang.String restservice.getEmployees.getEmpDepartement(java.lang.Integer) throws java.sql.SQLException, parameters=[Parameter [type=class java.lang.Integer, source=EmpNo, defaultValue=null]], responseType=class java.lang.String}, nameBindings=[]}']"

weblogic.application.ModuleException: org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.

[[FATAL] A HTTP GET method, public java.lang.String restservice.getEmployees.getEmpDepartement(java.lang.Integer) throws java.sql.SQLException, should not consume any form parameter.; source='ResourceMethod{httpMethod=GET, consumedTypes=[], producedTypes=[application/xml], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class restservice.getEmployees, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@68a00d2d]}, definitionMethod=public java.lang.String restservice.getEmployees.getEmpDepartement(java.lang.Integer) throws java.sql.SQLException, parameters=[Parameter [type=class java.lang.Integer, source=EmpNo, defaultValue=null]], responseType=class java.lang.String}, nameBindings=[]}']

    at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)

    at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)

    at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:216)

    at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:211)

    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)

    Truncated. see log file for complete stacktrace

Caused By: org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.

[[FATAL] A HTTP GET method, public java.lang.String restservice.getEmployees.getEmpDepartement(java.lang.Integer) throws java.sql.SQLException, should not consume any form parameter.; source='ResourceMethod{httpMethod=GET, consumedTypes=[], producedTypes=[application/xml], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class restservice.getEmployees, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@68a00d2d]}, definitionMethod=public java.lang.String restservice.getEmployees.getEmpDepartement(java.lang.Integer) throws java.sql.SQLException, parameters=[Parameter [type=class java.lang.Integer, source=EmpNo, defaultValue=null]], responseType=class java.lang.String}, nameBindings=[]}']

    at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:444)

    at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:162)

    at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:304)

    at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)

    at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)

    Truncated. see log file for complete stacktrace

>

<Oct 27, 2016 2:51:10 PM AST> <Error> <Deployer> <BEA-149202> <Encountered an exception while attempting to commit the 1 task for the application "RestWS".>

<Oct 27, 2016 2:51:10 PM AST> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application "RestWS".>

<Oct 27, 2016 2:51:10 PM AST> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004

weblogic.application.ModuleException: org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.

[[FATAL] A HTTP GET method, public java.lang.String restservice.getEmployees.getEmpDepartement(java.lang.Integer) throws java.sql.SQLException, should not consume any form parameter.; source='ResourceMethod{httpMethod=GET, consumedTypes=[], producedTypes=[application/xml], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class restservice.getEmployees, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@68a00d2d]}, definitionMethod=public java.lang.String restservice.getEmployees.getEmpDepartement(java.lang.Integer) throws java.sql.SQLException, parameters=[Parameter [type=class java.lang.Integer, source=EmpNo, defaultValue=null]], responseType=class java.lang.String}, nameBindings=[]}']:org.glassfish.jersey.server.model.ModelValidationException:Validation of the application resource model has failed during application initialization.

[[FATAL] A HTTP GET method, public java.lang.String restservice.getEmployees.getEmpDepartement(java.lang.Integer) throws java.sql.SQLException, should not consume any form parameter.; source='ResourceMethod{httpMethod=GET, consumedTypes=[], producedTypes=[application/xml], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class restservice.getEmployees, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@68a00d2d]}, definitionMethod=public java.lang.String restservice.getEmployees.getEmpDepartement(java.lang.Integer) throws java.sql.SQLException, parameters=[Parameter [type=class java.lang.Integer, source=EmpNo, defaultValue=null]], responseType=class java.lang.String}, nameBindings=[]}']

    at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:444)

    at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:162)

    at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:304)

    at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)

    at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)

    Truncated. see log file for complete stacktrace

>

[02:51:10 PM] Deployment cancelled.

#### Cannot run application RestWS due to error deploying to IntegratedWebLogicServer.

[02:51:10 PM] ----  Deployment incomplete  ----.

[02:51:10 PM] Remote deployment failed (oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer)

[02:51:10 PM] Cancel requested

[Application RestWS stopped and undeployed from IntegratedWebLogicServer]

-And this is the java class

@Path("restservice")

public class getEmployees {

         some code

//This is the method

    @GET

    @Produces("application/xml")

    public String getEmpDepartement(@FormParam("EmpNo") Integer empId) throws SQLException {

        Statement stmt;

        ResultSet rset;

        String query;

        String empFName="";

        String empLName="";

        int deptId=0;

        Connection conn = getDBConnection();

        query = "SELECT * FROM Employees where employee_id = "+empId;

        stmt = conn.prepareStatement(query);

        rset = stmt.executeQuery(query);

        while (rset.next()) {

            empFName=(rset.getString("FIRST_NAME"));

            empLName=(rset.getString("LAST_NAME"));

            deptId=Integer.parseInt((rset.getString("DEPARTMENT_ID")));

        }

        ResponseParams resP=new ResponseParams();

        resP.setEmpFName(empFName);

        resP.setEmpLName(empLName);

        resP.setDeptId(deptId);

       

        return (resP.getEmpFName() +resP.getEmpLName()+resP.getDeptId());

    }

}

I'm using Jdeveloper 12.1.3 . Would anyone help me to fix this error ?

Thanks

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 24 2016
Added on Oct 27 2016
0 comments
1,892 views