6 Replies Latest reply on Oct 4, 2012 11:08 AM by marco gentile

    Cannot find ServiceFactory implementation Problem

    Dipak Patel Newbie

      Hello All,

       

      I have created one web service and hosted it in JBoss. Now i want to use that web service in another class using following code.

       

      -------------------------------------------------------------------

      public static void main(String[] args) throws Exception

      {

        try

        {

         String urlstr = "http://localhost:8080/SimpleWebServiceAnnotationProject?wsdl";

         System.out.println("Contacting webservice at " + urlstr);

       

         URL url = new URL(urlstr);

        

       

         String ns = "http://simple.ws.jboss.org/";

         QName qname = new QName(ns, "SimpleServiceAnnotation");

         QName port = new QName(ns, "SimpleAnnotationPort");

         QName operation = new QName(ns, "getMessage");

       

        

         ServiceFactory factory = ServiceFactory.newInstance(); 

         Service service = factory.createService(url, qname);

         Call call = service.createCall(port, operation);

       

         System.out.println("output:" + call.invoke(null));

        }

        catch (Exception e)

        {

         e.printStackTrace();

        }

      }

      -------------------------------------------------------------------

      If i run this code then it alwasys shows me following error.

      Contacting webservice at http://localhost:8080/SimpleWebServiceAnnotationProject?wsdl
      javax.xml.rpc.ServiceException: Cannot find ServiceFactory implementation
      at javax.xml.rpc.ServiceFactory.newInstance(ServiceFactory.java:115)
      at applications.JaxRpcDIIClient.main(JaxRpcDIIClient.java:28)

       

      ------------------------------------------------------------------------------------------------

       

      I am using JBoss 7.1.1 Final version.

      I can Browse the web service http://localhost:8080/SimpleWebServiceAnnotationProject?wsdl in internet explorer.

       

      Is there any library is missing?

      Can any one help me  what i missing here?

      Thanks

      Dipak

        • 1. Re: Cannot find ServiceFactory implementation Problem
          marco gentile Newbie

          Same here!! Can anybody give us hints or advices?

          • 2. Re: Cannot find ServiceFactory implementation Problem
            Dipak Patel Newbie

            Hi I have solved this problem using following video.

             

            Please follow it. Use Same jBoss version which you will see in video.

             

            http://www.youtube.com/watch?v=F8TzX46bA1M

            • 3. Re: Cannot find ServiceFactory implementation Problem
              Alessio Soldano Master

              First of all, next time please use the user section of the forum (https://community.jboss.org/en/jbossws), not the dev one.

              This said, be aware that the code above is making use of JAX-RPC api, is that really what you're trying to do?

              If that's the case, then you're basically having a service load / classpath issue. Is you client running in-container? If it's not in-container, consider adding the jbossws-native-core-4.0.2.GA.jar from AS 7.1.1.Final in your classpath (that contains the META-INF/services/javax.xml.rpc.ServiceFactory reference you need).

              • 4. Re: Cannot find ServiceFactory implementation Problem
                marco gentile Newbie

                Hi,

                thanks for your replies.

                I achieved to create a java client (java project) to connect to SugarCRM, without errors.

                Below, I write a snippet of code:

                 

                -------------------------------------------------

                ....

                import javax.xml.rpc.ServiceFactory;

                ....

                String sessionID = null;

                 

                        try {

                            // Create a URL end point for the client

                            URL wsdlUrl = null;

                            if (END_POINT_URL.isEmpty()) {

                                wsdlUrl = new URL(

                                        new SugarsoapLocator().getsugarsoapPortAddress()

                                                + "?wsdl");

                            } else {

                                wsdlUrl = new URL(END_POINT_URL);

                            }

                 

                            System.out.println("URL endpoint created successfully!");

                 

                            // Create Service for test configuration

                            ServiceFactory serviceFactory = ServiceFactory.newInstance();

                            Service service = serviceFactory.createService(wsdlUrl,

                                    new SugarsoapLocator().getServiceName());

                 

                            System.out.println("Service created successfully");

                            System.out.println("Service Name:"

                                    + service.getServiceName().toString());

                            System.out.println("Service WSDL:"

                                    + service.getWSDLDocumentLocation().toString());

                 

                            // Trying to create a stub

                            SugarsoapBindingStub binding = new SugarsoapBindingStub(wsdlUrl,

                                    service);

                            binding.setTimeout(TIMEOUT);

                            System.out.println("Stub created successfully!");

                 

                            /**

                             * Try to login on SugarCRM

                             *

                             * 1) Prepare a MD5 hash password 2) Prepare a User Auth object 3)

                             * Execute login

                             */

                 

                            // 1. Prepare a MD5 hash password

                            MessageDigest messageDiget = MessageDigest.getInstance("MD5");

                            messageDiget.update(USER_PASSWORD.getBytes());

                 

                            // 2. Prepare a User Auth object

                            User_auth userAuthInfo = new User_auth();

                            userAuthInfo.setUser_name(USER_NAME);

                            userAuthInfo.setPassword((new BigInteger(1, messageDiget.digest()))

                                    .toString(16));

                            userAuthInfo.setVersion("0.1");

                 

                            try {

                                // 3. Execute login

                                Set_entry_result loginResult = binding.login(userAuthInfo,

                                        APPLICATION_NAME);

                                System.out.println("Login Successfully for " + USER_NAME);

                                System.out.println("Your session Id: " + loginResult.getId());

                                sessionID = loginResult.getId();

                            } catch (RemoteException ex) {

                                System.out.println("Login failed. Message: " + ex.getMessage());

                                ex.printStackTrace();

                            }

                -------------------------------------------------

                 

                I created an eclipse web project, using JBoss 7.1.1 Final version as server.

                I created a "login.xhtml" page.. submit button launches a function that belongs to "Login" class.. this function includes upper code.

                When I debug my project on server, eclipse reports this error:

                 

                -------------------------------------------------

                17:33:54,550 INFO  [stdout] (http-localhost-127.0.0.1-8080-2) URL endpoint created successfully!

                 

                17:33:55,803 ERROR [stderr] (http-localhost-127.0.0.1-8080-2) javax.xml.rpc.ServiceException: Failed to create factory: org.jboss.ws.core.jaxrpc.client.ServiceFactoryImpl

                 

                17:33:55,807 ERROR [stderr] (http-localhost-127.0.0.1-8080-2)     at javax.xml.rpc.ServiceFactory.newInstance(ServiceFactory.java:110)

                 

                17:33:55,811 ERROR [stderr] (http-localhost-127.0.0.1-8080-2)     at com.brokers.sib.Login.authorization(Login.java:78)

                 

                17:33:55,814 ERROR [stderr] (http-localhost-127.0.0.1-8080-2)     at com.brokers.sib.Login$Proxy$_$$_WeldClientProxy.authorization(Login$Proxy$_$$_WeldClientProxy.java)

                 

                17:33:55,817 ERROR [stderr] (http-localhost-127.0.0.1-8080-2)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                 

                17:33:55,821 ERROR [stderr] (http-localhost-127.0.0.1-8080-2)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                 

                17:33:55,824 ERROR [stderr] (http-localhost-127.0.0.1-8080-2)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                .....

                -------------------------------------------------

                 

                Alessio Soldano I follow your hints but nothing changes. I hope to have given you more info.

                • 5. Re: Cannot find ServiceFactory implementation Problem
                  marco gentile Newbie

                  Previous error message came out after adding jbossws-native-core-4.0.2.GA.jar in web project and in classpath.

                  Without this updates, output was:

                   

                  -------------------------------------------

                  10:08:41,682 INFO  [stdout] (http-localhost-127.0.0.1-8080-1) URL endpoint created successfully!

                   

                  10:08:41,704 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) javax.xml.rpc.ServiceException: Cannot find ServiceFactory implementation

                   

                  10:08:41,707 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at javax.xml.rpc.ServiceFactory.newInstance(ServiceFactory.java:115)

                   

                  10:08:41,709 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at com.brokers.sib.Login.authorization(Login.java:78)

                   

                  10:08:41,711 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at com.brokers.sib.Login$Proxy$_$$_WeldClientProxy.authorization(Login$Proxy$_$$_WeldClientProxy.java)

                   

                  10:08:41,714 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                   

                  10:08:41,716 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                   

                  10:08:41,718 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                   

                  10:08:41,721 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at java.lang.reflect.Method.invoke(Method.java:597)

                   

                  10:08:41,723 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.el.parser.AstValue.invoke(AstValue.java:262)

                   

                  10:08:41,725 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)

                   

                  10:08:41,727 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:39)

                   

                  10:08:41,730 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)

                   

                  10:08:41,732 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)

                   

                  10:08:41,735 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)

                   

                  10:08:41,737 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)

                   

                  10:08:41,740 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at javax.faces.component.UICommand.broadcast(UICommand.java:315)

                   

                  10:08:41,742 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)

                   

                  10:08:41,745 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)

                   

                  10:08:41,747 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)

                   

                  10:08:41,749 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

                   

                  10:08:41,751 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

                   

                  10:08:41,754 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)

                   

                  10:08:41,756 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)

                   

                  10:08:41,758 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

                   

                  10:08:41,761 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)

                   

                  10:08:41,764 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)

                   

                  10:08:41,766 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

                   

                  10:08:41,769 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)

                   

                  10:08:41,771 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)

                   

                  10:08:41,774 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)

                   

                  10:08:41,776 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)

                   

                  10:08:41,779 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

                   

                  10:08:41,781 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

                   

                  10:08:41,784 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)

                   

                  10:08:41,786 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)

                   

                  10:08:41,788 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)

                   

                  10:08:41,791 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)

                   

                  10:08:41,793 ERROR [stderr] (http-localhost-127.0.0.1-8080-1)     at java.lang.Thread.run(Thread.java:662)