netbeans and web services error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • henrymania
    New Member
    • Sep 2007
    • 14

    #1

    netbeans and web services error

    hi,

    I am developing a web services in netbeans 5.5.1 and using sun application server as my container .

    i was able to run the application once....i mean i was able to see my servlet page which is my client but was gettin some exceptions...am not worried abt the exception at the moment...


    i went back to the servlet code made some chnges ....and from then on i am gettin a deployment error in build-impl.xml file
    here is my error as follows....


    In-place deployment at D:\abhijeet_y\C alculatorWSAppl ication\build\w eb
    Start registering the project's server resources
    Finished registering server resources
    moduleID=Calcul atorWSApplicati on
    deployment started : 0%
    D:\abhijeet_y\C alculatorWSAppl ication\nbproje ct\build-impl.xml:474: Deployment error:
    The module has not been deployed.
    See the server log for details.
    BUILD FAILED (total time: 3 minutes 19 seconds)
  • ak1dnar
    Recognized Expert Top Contributor
    • Jan 2007
    • 1584

    #2
    Just double check whether you are using built in tomcat or sun application server. and your JDK version is?

    Comment

    • henrymania
      New Member
      • Sep 2007
      • 14

      #3
      hi thanx for replyin ......i am using sun java application serv er.......
      and my jdk version is 1.5.....

      u kno what it sometimes happpen that i have to restart mt server....so it gets deployed sometimes....bu t the odds of that happpening are very less...

      am sure there is a soln....

      just to give u more details..

      am getiin a error on line no 474 in build-impl.xml file....which has clienturlpart and forceredeploy variables...... .

      clienturl is already set with a servlet which is the raltive url in
      properties file...
      but there is no entry for forceredeploy

      Comment

      • henrymania
        New Member
        • Sep 2007
        • 14

        #4
        one more doubt ....

        this is my code for servlet....that is my web service client....

        /*
        * addservlet.java
        *
        * Created on September 28, 2007, 10:35 AM
        */

        package org.me.calculat or;

        import java.io.*;
        import java.net.*;
        import java.rmi.Remote ;
        import java.rmi.Remote Exception;
        import javax.servlet.* ;
        import javax.servlet.h ttp.*;

        /**
        *
        * @author Administrator
        * @version
        */
        public class addservlet extends HttpServlet {

        /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
        * @param request servlet request
        * @param response servlet response
        */
        protected void processRequest( HttpServletRequ est request, HttpServletResp onse response)
        throws ServletExceptio n, IOException {
        response.setCon tentType("text/html;charset=UT F-8");
        PrintWriter out = response.getWri ter();

        out.println("<h tml>");
        out.println("<h ead>");
        out.println("<t itle>Servlet addservlet</title>");
        out.println("</head>");
        out.println("<b ody>");

        out.println("<p >Enter the two numbers:</p>");
        out.println("<f orm method=\"post\" >");
        out.println("<i nput type=\"text\" name=\"no1\" size=\"25\">");
        out.println("<i nput type=\"text\" name=\"no2\" size=\"25\">");
        out.println("<b r>");
        out.println("<p >");
        out.println("<i nput type=\"submit\" value=\"Submit\ ">");
        out.println("</form>");


        String s1 = request.getPara meter("no1");
        String s2 = request.getPara meter("no2");

        // out.println(req uest.getParamet er("no1"));
        // out.println(req uest.getParamet er("no2"));
        out.println(s1) ;
        out.println(s2) ;
        int n1=0;
        int n2=0;
        if (s1 != null && s2 != null)
        {
        n1= Integer.parseIn t(s1);
        n2=Integer.pars eInt(s2);

        // int n1,n2;
        // n1= 2 ; n2 = 3;

        if ( n1 >=0 && n2 >= 0 ) {

        try { // This code block invokes the add operation on web service
        out.println(get CalculatorWSSEI Port().add(n1,n 2) );
        } catch(java.rmi. RemoteException ex) {
        // TODO handle remote exception
        out.println("<p >Caught an exception <p>" + ex);

        } catch(Exception ex) {
        // TODO handle custom exceptions here
        out.println("<p >Caught an exception <p>" + ex);

        }

        }
        }
        // out.println("<h 1>Servlet addservlet at " + request.getCont extPath () + "</h1>");
        out.println("</body>");
        out.println("</html>");

        out.close();
        }

        // <editor-fold defaultstate="c ollapsed" desc="HttpServl et methods. Click on the + sign on the left to edit the code.">
        /** Handles the HTTP <code>GET</code> method.
        * @param request servlet request
        * @param response servlet response
        */
        protected void doGet(HttpServl etRequest request, HttpServletResp onse response)
        throws ServletExceptio n, IOException {
        processRequest( request, response);
        }

        /** Handles the HTTP <code>POST</code> method.
        * @param request servlet request
        * @param response servlet response
        */
        protected void doPost(HttpServ letRequest request, HttpServletResp onse response)
        throws ServletExceptio n, IOException {
        processRequest( request, response);
        }

        /** Returns a short description of the servlet.
        */
        public String getServletInfo( ) {
        return "Short description";
        }
        // </editor-fold>

        private org.me.calculat or.CalculatorWS getCalculatorWS () {
        org.me.calculat or.CalculatorWS calculatorWS = null;
        try {
        javax.naming.In itialContext ic = new javax.naming.In itialContext();
        calculatorWS = (org.me.calcula tor.CalculatorW S) ic.lookup("java :comp/env/service/CalculatorWS");
        } catch(javax.nam ing.NamingExcep tion ex) {
        // TODO handle JNDI naming exception
        }
        return calculatorWS;
        }

        private org.me.calculat or.CalculatorWS SEI getCalculatorWS SEIPort() {
        org.me.calculat or.CalculatorWS SEI calculatorWSSEI Port = null;
        try {
        calculatorWSSEI Port = getCalculatorWS ().getCalculato rWSSEIPort();
        } catch(javax.xml .rpc.ServiceExc eption ex) {
        // TODO handle service exception
        }
        return calculatorWSSEI Port;
        }
        }


        whenever the deployment is succesfull..... .i am able to see my servlet...

        but when i enter two numbers in the text box.....i get an exception...
        as follows.....

        Caught an exception

        java.rmi.Remote Exception: HTTP transport error: java.net.Malfor medURLException : no protocol: REPLACE_WITH_AC TUAL_URL; nested exception is: HTTP transport error: java.net.Malfor medURLException : no protocol: REPLACE_WITH_AC TUAL_URL

        my web service which i creatde simply has two more files.....

        .CalculatorWSSE I
        .CalculatorWSIm pl
        i have included an add function that is it....


        your help would be kindly apppreciated... .

        Comment

        • ak1dnar
          Recognized Expert Top Contributor
          • Jan 2007
          • 1584

          #5
          I think you are trying this sample application from the netbeans.org, right?
          As I could understand the problem is with your web service, not with the web service client servlet. could you please show us the coding for web service.

          Comment

          • henrymania
            New Member
            • Sep 2007
            • 14

            #6
            yes ur right am doing the sample code....

            AND HERE ARE TEH TWO FILES FOR MY WEB SERVICE
            -------------------------------------------------------------------------------------------------
            1)CalculatorWSI mpl .java
            package org.me.calculat or;

            import java.rmi.Remote Exception;

            public class CalculatorWSImp l implements CalculatorWSSEI {


            // Enter web service operations here. (Popup menu: Web Service->Add Operation)
            /**
            * Web service operation
            */
            public int add(int i, int j) throws RemoteException {
            // TODO implement operation
            int k = i + j ;
            return k;
            }
            }
            ----------------------------------------------------------------------------------------------------------
            2)CalculatorWSS EI.java

            package org.me.calculat or;

            import java.rmi.Remote ;
            import java.rmi.Remote Exception;


            public interface CalculatorWSSEI extends Remote {
            /**
            * Web service operation
            */
            public int add(int i, int j) throws RemoteException ;

            /**
            * Web service operation
            */


            }

            Comment

            • henrymania
              New Member
              • Sep 2007
              • 14

              #7
              kindly pls help me ajax am stuck on this problem for a very long time

              my web service files are written above

              Comment

              • ak1dnar
                Recognized Expert Top Contributor
                • Jan 2007
                • 1584

                #8
                There is no web service Opration in your Web service. See this "example" here there is a one Named "add"
                [CODE=java]
                package org.me.calc;

                import javax.jws.WebMe thod;
                import javax.jws.WebPa ram;
                import javax.jws.WebSe rvice;

                @WebService()
                public class CalcServer {


                @WebMethod(oper ationName = "add")
                public int add(@WebParam(n ame = "num1")
                int num1, @WebParam(name = "num2")
                int num2) {
                int resultNum;
                resultNum=num1+ num2;
                return resultNum;
                }

                }[/CODE]

                NOTE: Please use the CODE Tags

                Comment

                • henrymania
                  New Member
                  • Sep 2007
                  • 14

                  #9
                  thanx ya u know actually am a starter....


                  but the problem is still not solved...now the netbeans that am using ...


                  i copied ur add code...and impoted the pacakes...

                  but it gives an error sayin.... pacakge javax.jws.WebMe thod;
                  import javax.jws.WebPa ram;
                  import javax.jws.WebSe rvice;

                  does not exixts......


                  do i have to intall anything else for these packages...

                  Comment

                  • ak1dnar
                    Recognized Expert Top Contributor
                    • Jan 2007
                    • 1584

                    #10
                    Originally posted by henrymania
                    thanx ya u know actually am a starter....


                    but the problem is still not solved...now the netbeans that am using ...


                    i copied ur add code...and impoted the pacakes...

                    but it gives an error sayin.... pacakge javax.jws.WebMe thod;
                    import javax.jws.WebPa ram;
                    import javax.jws.WebSe rvice;

                    does not exixts......


                    do i have to intall anything else for these packages...
                    As the your error describes the JAX-WS is not available in your project library. I'm using netbeans 6 and J2SDK 6 here in my end. So I'm not sure about the configuration settings that much. because I didn't add any of this here.

                    since you have used 5.5.1, you may have to add the JAX-WS to the application.I'm not sure about this, but you can try. if the jax-ws jar is not there on the "library" (expand project tree view) right click on the library, and you can find "Add jar" or something similar to this. Or from the "update manager" tool you can find the jax-ws. Find out the Jax-ws file url from your tutorial.
                    Thanks!

                    Comment

                    • henrymania
                      New Member
                      • Sep 2007
                      • 14

                      #11
                      Thanx a ton .....it works ...u saved a lot of time and certainly made my day.. i just had to install java webservice development pack....and add the xxx.jar in the project as u said....

                      actually am a starter at this as i said before...

                      i just need 3 more answers to my questions below

                      1)for every function do we have to mention @WebMethod
                      as it is in ur add method ...but was not in mine....i mean wat is the significance. of that is it a keyword or something.....i mean i was doin a sample eg...so didi not find that @webmethod thing......

                      2)can u provide me link where i can study the basics of web services..
                      actually am confused as to where to start of from

                      3)and wat are the pre-requirement for studying web services...

                      i am well verse with core java,servlets,j sp,

                      Comment

                      • ak1dnar
                        Recognized Expert Top Contributor
                        • Jan 2007
                        • 1584

                        #12
                        Glad you got it working.

                        Originally posted by henrymania
                        1)for every function do we have to mention @WebMethod
                        as it is in ur add method ...but was not in mine....i mean wat is the significance. of that is it a keyword or something.....i mean i was doin a sample eg...so didi not find that @webmethod thing......
                        For each and every "operation" there you have to set @WebMethod annotation. and "add" is the operation(metho d) name for my sample. you can use any name for this.
                        2)can u provide me link where i can study the basics of web services..
                        actually am confused as to where to start of from
                        Since your IDE is netbeans refer to netbeans docs.
                        3)and wat are the pre-requirement for studying web services...
                        ummm....may be one of our expert will be able to answer for this. read the documentation, that's enough if you know how to absorb 'em.

                        Comment

                        • henrymania
                          New Member
                          • Sep 2007
                          • 14

                          #13
                          thanx a ton once again for all that help...

                          Regards abhi

                          Comment

                          Working...