Tuscany
  1. Tuscany
  2. TUSCANY-2908

stack trace: PolicyValidation exception

    Details

    • Type: Test Test
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Java SCA Policy
    • Labels:
      None
    • Environment:
      windows xp using eclipse plug-in tool 1.3.2.
    • Patch Info:
      Patch Available

      Description

      (1) I've gained some insight into the issue. It seams there are a default set of policies as well as some other classes that are loaded when I Do SCADomain scaDomain = SCADomain.newInstance("helloworld.composite");. They are:

      org.apache.tuscany.sca.policy.security.SecurityPolicyDefinitionsProvider
      org.apache.tuscany.sca.binding.ws.axis2.WSBindingDefinitionsProvider
      org.apache.tuscany.sca.binding.sca.SCABindingDefinitionsProvider
      org.apache.tuscany.sca.policy.logging.LoggingPolicyDefinitionsProvider

      This is done in the class org.apache.tuscany.sca.definitions.imp.DefaultSCADefinitionsProviderExtensionPoint and the method loadProviders. My composite file is as follows:

      <?xml version="1.0" encoding="UTF-8"?>
      <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
      targetNamespace="http://helloworld"
      xmlns:hw="http://helloworld.gdit.com."
      xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
      name="helloworld">
      <component name="HelloWorldServiceComponent">
      <implementation.java class="helloworld.HelloWorldImpl">
      <operation name="sayWorld" requires="tuscany:logging"/>
      </implementation.java>
      <service name="HelloWorld">
      <interface.java interface="helloworld.HelloWorld"></interface.java>
      <binding.ws/>
      </service>
      <reference name="helloService" target="HelloComponent" />
      <reference name="worldService" target="WorldComponent" />
      </component>
      <component name="HelloComponent">
      <implementation.java class="helloworld.HelloServiceImpl"/>
      </component>
      <component name="WorldComponent">
      <implementation.java class="helloworld.WorldServiceImpl">
      </implementation.java>
      </component>
      </composite>

      (2)The Composite file specifies thet <operations name="sayWorld" requires="tuscany.logging"> which specifies that it the method sayWorld needs to be logged. I have a definitions file associated with my test programs which specifies the policy:
      <?xml version="1.0" encoding="UTF-8"?>
      <definitions xmlns="http://www.osoa.org/xmlns/sca/1.0"
      targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0"
      xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
      xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
      xmlns:helloWorld="http://HelloWorld">
      <!-- PolicySets -->
      <policySet name="JDKLoggingPolicy" provides="tuscany:logging" appliesTo="sca:implementation.java"
      xmlns="http://www.osoa.org/xmlns/sca/1.0">
      <!--tuscany:jdkLogger name="HelloWorld">
      <logLevel>FINER</logLevel>
      </tuscany:jdkLogger-->
      </policySet>
      </definitions

      (3)My Understanding (and it may be wrong) is that the requires in the composite file is supposed to map to <policySet name="JDKLoggingPolicy" provides="tuscany:logging" appliesTo="sca:implementation.java" xmlns="http://www.osoa.org/xmlns/sca/1.0"> line in the definitions.xml file and somehow this is supposed to map to the implementation of the logger. This apparently is not the case. I ran my test program without the definitions.xml file associated with it and it still runs without error. What I found is that the <operation name="sayWorld" requires="tuscany:logging"/> maps to the intent for the logger which is in the definitions.xml file in the logger package. The file is as follows:

      <?xml version="1.0" encoding="ASCII"?>
      <definitions xmlns="http://www.osoa.org/xmlns/sca/1.0"
      targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0"
      xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
      xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0">

      <!-- Policy Intents Defined by the SCA Runtime -->
      <intent name="logging"
      constrains="sca:implementation.java">
      <description>
      All messages to and from this implementation must be logged
      </description>
      </intent>
      </definitions>

      If I change the intent name="logging" to something I then get the Policy violation error. So this leads me to the following questions and possible issues:

      1. Where does the list of polices that are being loaded as described in (1) above come from?
      2. Is there a way for me to add my policy to this list or somehow get it resolved to my intent so that I can define my own policies?
      3. Is the policy set the method of mapping a policy to an intent?
      4. Is the definitions file associated with the composite app even used?

      I have my own driver and will uploaded it to the jira when the SCA Policy component is created.

      ----Original Message----
      From: Luciano Resende luckbr1975@gmail.com
      Sent: Thursday, March 05, 2009 7:32 PM
      To: user@tuscany.apache.org
      Subject: Re: stack trace: PolicyValidation exception

      Should your intent be <intent name="gdit:FooBarPolicy"
      instead of <intent name="FooBarPolicy" ?

      On Thu, Mar 5, 2009 at 5:23 PM, Sacauskis, Mike <Mike.Sacauskis@gdit.com> wrote:
      > <definitions xmlns="http://www.osoa.org/xmlns/sca/1.0"
      >
      >
      > targetNamespace="http://gdit.com/"
      >
      >
      > xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
      >
      > xmlns:gdit="http://gdit.com/">
      >
      >
      >
      > <!-- Policy Intents Defined by the SCA Runtime -->
      >
      > <intent name="FooBarPolicy"


      Luciano Resende
      Apache Tuscany, Apache PhotArk
      http://people.apache.org/~lresende
      http://lresende.blogspot.com/

      1. ws.zip
        10 kB
        Michael Sacauskis

        Activity

        Hide
        Michael Sacauskis added a comment -

        This is a zip of my eclipse project which attempts to use the logger policy defined in modules policy-logging.

        Show
        Michael Sacauskis added a comment - This is a zip of my eclipse project which attempts to use the logger policy defined in modules policy-logging.
        Hide
        Michael Sacauskis added a comment -

        I have some time to do some work on this issue if someone can answer of point me in the direction of the answers to my questions.

        Show
        Michael Sacauskis added a comment - I have some time to do some work on this issue if someone can answer of point me in the direction of the answers to my questions.
        Hide
        Luciano Resende added a comment -

        Let me try to respond to your questions :

        1. Where does the list of polices that are being loaded as described in (1) above come from?

        It comes from modules that either you or the runtime added to the classpath of your application. These modules then contribute policies to the runtime.
        In your case, the modules seems to be policy-security, policy-security-ws or binding-ws-axis2-policy, policy-logging

        2. Is there a way for me to add my policy to this list or somehow get it resolved to my intent so that I can define my own policies?
        Let's consider the policy-logging as an example here.When you provide a new itent (in your module definitions.xml),

        <intent name="logging" constrains="sca:implementation.java sca:implementation.spring">
        <description>
        All messages to and from this implementation must be logged
        </description>
        </intent>

        You then use the LoggingPolicyDefinitionsProvider (registering it via META-INF\services\org.apache.tuscany.sca.provider.SCADefinitionsProvider)
        to parse the definitions.xml and provide your intent using SCADefinitions model class.

        Then, you still need to provide a processor to read the policySet from the app definitions.xml, and you do that by providing the a xxxPolicyProcessor
        and registering it via META-INF\services\org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor. In this case, the processor
        is being registered for the following QName

        {http://tuscany.apache.org/xmlns/sca/1.0}

        jdkLogger, so when the definitions.xml is being parsed,
        and this qName is found, your processor is going to be invoked to provide the right model for the policySet.

        The last piece here is to provide some functionality for this policy when the method get invoked, and this is what the interceptor does.

        3. Is the policy set the method of mapping a policy to an intent?
        Yes

        4. Is the definitions file associated with the composite app even used?
        Yes, this is where you put the policySet

        BTW, I tried your sample, and it looks like you have missed the other project your ws app depends on.

        Show
        Luciano Resende added a comment - Let me try to respond to your questions : 1. Where does the list of polices that are being loaded as described in (1) above come from? It comes from modules that either you or the runtime added to the classpath of your application. These modules then contribute policies to the runtime. In your case, the modules seems to be policy-security, policy-security-ws or binding-ws-axis2-policy, policy-logging 2. Is there a way for me to add my policy to this list or somehow get it resolved to my intent so that I can define my own policies? Let's consider the policy-logging as an example here.When you provide a new itent (in your module definitions.xml), <intent name="logging" constrains="sca:implementation.java sca:implementation.spring"> <description> All messages to and from this implementation must be logged </description> </intent> You then use the LoggingPolicyDefinitionsProvider (registering it via META-INF\services\org.apache.tuscany.sca.provider.SCADefinitionsProvider) to parse the definitions.xml and provide your intent using SCADefinitions model class. Then, you still need to provide a processor to read the policySet from the app definitions.xml, and you do that by providing the a xxxPolicyProcessor and registering it via META-INF\services\org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor. In this case, the processor is being registered for the following QName {http://tuscany.apache.org/xmlns/sca/1.0} jdkLogger, so when the definitions.xml is being parsed, and this qName is found, your processor is going to be invoked to provide the right model for the policySet. The last piece here is to provide some functionality for this policy when the method get invoked, and this is what the interceptor does. 3. Is the policy set the method of mapping a policy to an intent? Yes 4. Is the definitions file associated with the composite app even used? Yes, this is where you put the policySet BTW, I tried your sample, and it looks like you have missed the other project your ws app depends on.
        Hide
        Michael Sacauskis added a comment -

        This zip does not have a dependency on another project.

        Show
        Michael Sacauskis added a comment - This zip does not have a dependency on another project.

          People

          • Assignee:
            Unassigned
            Reporter:
            Michael Sacauskis
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development