Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

invoking a web service from a jsp ?  RSS feed

 
mohamed sellami
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello

i'm trying to invoke a WS from a jsp page, working on tomcat + jwsdp

the ws i'd created and deployed on the server is named TestCNRPS, it contains the method: int exist(int ..)

i wrote this jsp page for testing :

--------------------------
1<%@ page contentType="text/html;charset=windows-1252" import="cnrps.*" %>
2<HTML>
3<HEAD>
4<TITLE>Appel service Web</TITLE>
5</HEAD>
6
7<BODY>
8<%
9int num_cin=45475645;
10
11TestCNRPSIF_Stub stub = (TestCNRPSIF_Stub)(new TestCNRPSService_Impl().getTestCNRPSIFPort());
12stub._setProperty(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY,System.getProperty("endpoint"));
13out.println(stub.exist(num_cin));

%>
</BODY>
</HTML>
----------------------------------

but i received this exception:

java.rmi.RemoteException: Erreur de transport HTTP : java.lang.NullPointerException; nested exception is:
Erreur de transport HTTP : java.lang.NullPointerException
cnrps.TestCNRPSIF_Stub.exist(TestCNRPSIF_Stub.java:87)
org.apache.jsp.invoqueWS_jsp._jspService(invoqueWS_jsp.java:58)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:268)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:258)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:205)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


Has someone an idea ??

thx
[ September 07, 2005: Message edited by: mohamed sellami ]
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We'd need to know what's happening here:
cnrps.TestCNRPSIF_Stub.exist(TestCNRPSIF_Stub.java:87)
 
mohamed sellami
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the method exist get the identier of a pesron, connect to a database and verify if he exists.

but i think th problem is not there, cause i tried the exempl on a dos prompt with a client class having the same code and it worked fine.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the problem is there, because that's where the exception is thrown Check that none of the objects used or referenced in that line are null. If any are, let us know which ones those are, and how they are created; that might help discover the problem.
[ September 06, 2005: Message edited by: Ulf Dittmer ]
 
mohamed sellami
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
that's line 87 on TestCNRPSIF_Stub.java

86 } catch (JAXRPCException e) {
87 throw new RemoteException(e.getMessage(), e);
88 }

??

[ September 06, 2005: Message edited by: mohamed sellami ]
[ September 07, 2005: Message edited by: mohamed sellami ]
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not the class that's throwing the exception - TestCNRPSIF_Stub throws it. You need to analyze what's happening with null objects in line 87 of that class.
 
mohamed sellami
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes the exception is thrown by the TestCNRPSIF_Stub class!!!

it was a typing error, i edited the message, thx
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In that case you need to figure out where the JAXRPCException is thrown, which is caught by the catch clause.
 
mohamed sellami
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah that's right but the code inside the "TestCNRPSIF_Stub" class is very complex

but what makes me crazy is that it works using a simple class but not with a jsp page??
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the JSP page is on a different machine it could be a network issue. If it's on the same machine as your other client class, maybe it's missing libraries in the classpath.
But why speculate? The exception has a stack trace which will tell you which line causes the problem. That should be your first line of inquiry.
 
mohamed sellami
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulf

i found the fault it was in line 12 of the jsp:

i replaced System.getProperty("endpoint") with "http://localhost:8080/jaxrpc-TestCNRPS/TestCNRPS"

System.getProperty("endpoint") returned null but in the java class i maked for the test it returned "http://localhost:8080/jaxrpc-TestCNRPS/TestCNRPS"

anyway it's working fine now

thank you Ulf
[ September 07, 2005: Message edited by: mohamed sellami ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!