This discussion is archived
4 Replies Latest reply: Jul 16, 2013 6:20 AM by 890683 RSS

How can i execute Spaces API in java main class?

890683 Newbie
Currently Being Moderated

Hi

 

I am able to execute Spaces API through portal application. However if i try to execute it in java main class, its throwing an exception

 

"SEVERE: java.io.FileNotFoundException: .\config\jps-config.xml (The system cannot find the path specified)"

oracle.wsm.common.sdk.WSMException: WSM-00145 : Keystore location or path can not be null or empty; it must be configured through JPS configuration or policy configuration override.

 

How can i set this path, so that i can execute Spaces API from java main class.

 

Need this main class to configure in cron job, to schedule a task.

 

Regards

Raj

  • 1. Re: How can i execute Spaces API in java main class?
    Daniel Merchán Expert
    Currently Being Moderated

    Hi.


    Which API are you calling, WSDL?, REST? Directly to Java API?.

     

    Regards.

  • 2. Re: How can i execute Spaces API in java main class?
    890683 Newbie
    Currently Being Moderated

    Hi Daniel

     

    Currently i have implemented create functionality in my portal application using Spaces API, which is working fine. Now the requirement is, i need to implement a "Cron Job" to schedule a task, which will execute to create space(for example once in a week). Cron job will execute only the main method. So I have created java main class, in which I have used Spaces API to perform create space operation. Then it was giving exception.

     

    Later I understood the reason, as I am executing the Space API with a simple JSE client, its failing since a simple java program has no idea of default-keystore.jks, jps-config.xml, Security Policy. Hence i have included those details in main class. Now I am getting new error,

    SEVERE: WSM-06303 The method "registerListener" was not called with required permission "oracle.wsm.policyaccess"

     

    For your reference i have attached the code below, please help. How can i use Spaces API in java main method(i mean public static void main(String[] args) by giving all required information.

     

        public static void main(String[] args) throws InstantiationException,

                                                      GroupSpaceWSException,

                                                      SpacesException {

            Class2 class2 = new Class2();

            GroupSpaceWSContext context = new GroupSpaceWSContext();

            FactoryFinder.init(null);

            context.setEndPoint("http://10.161.226.30/webcenter/SpacesWebService");

            context.setSamlIssuerName("www.oracle.com");

            context.setRecipientKeyAlias("orakey");

            Properties systemProps = System.getProperties();

            systemProps.put("java.security.policy","oracle/wss11_saml_or_username_token_with_message_protection_client_policy");

            systemProps.put("javax.net.ssl.trustStore","C:\\Oracle\\Middleware11.1.7\\wlserver_10.3\\server\\lib\\cacerts.jks");

    systemProps.put("oracle.security.jps.config","C:\\Oracle\\Middleware11.1.7\\user_projects\\domains\\workspace\\system11.1.1.7.40.64.93\\DefaultDomain\\config\\fmwconfig\\jps-config.xml");

            systemProps.put("javax.net.ssl.keyStore",C:\\Oracle\\Middleware11.1.7\\user_projects\\domains\\workspace\\system11.1.1.7.40.64.93\\DefaultDomain\\config\\fmwconfig\\consumer.jks");

            systemProps.put("javax.net.ssl.keyStorePassword", "Test12");

            System.setProperties(systemProps);

            GroupSpaceWSClient groupSpaceWSClient;

            try {

                groupSpaceWSClient = new GroupSpaceWSClient(context);

                System.out.println("URL: " +

                                   groupSpaceWSClient.getWebCenterSpacesURL());

                //delete the Space

     

     

                List<String> groupSpaces = groupSpaceWSClient.getGroupSpaces(null);

                System.out.println("GroupSpaces:: " + groupSpaces.size());

            } catch (Exception e) {

     

     

            }

     

     

     

    Regards

    Raj

  • 3. Re: How can i execute Spaces API in java main class?
    HarshaRamesh Newbie
    Currently Being Moderated

    Hi Raj,

     

    I think it would be easier, if your cron job invoked a program that in turn invoked the Spaces REST APIs to create the space. This way, you do not need to get in to understanding which jar if required at what time.

     

    Just take care of authentication, and you should be fine.

     

    Thanks,

    Harsha

  • 4. Re: How can i execute Spaces API in java main class?
    890683 Newbie
    Currently Being Moderated

    Hi Harsha

     

    Thanks for your response.

     

    I have included all required jars and while executing the unix command to execute jar. Its giving this exception

    Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: InvalidSecurity : error in processing the WS-Security security header

            at com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:188)

            at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:122)

            at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:119)

            at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89)

            at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:118)

            at $Proxy33.getGroupSpaces(Unknown Source)

            at kesko.SpacesWebServiceSoapHttpPortClient.main(SpacesWebServiceSoapHttpPortClient.java:60)

     

    This problem is quite similar to this thread: https://forums.oracle.com/thread/2553182  . How to resolve this error?


    Thanks

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points