You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by "Sacauskis, Mike" <Mi...@gdit.com> on 2009/03/06 02:23:33 UTC

stack trace: PolicyValidation exception

 

I'm trying to write my own policy.  I get the following stack trace
when:

 

 

Mar 5, 2009 5:19:02 PM
org.apache.tuscany.sca.contribution.processor.ValidatingXMLStreamReader$
1 error

WARNING: XMLSchema validation problem in: null, line: 9, column: 3

cvc-complex-type.2.4.a: Invalid content was found starting with element
'operation'. One of '{WC[##other:"http://www.osoa.org/xmlns/sca/1.0"]}'
is expected.

Exception in thread "main" org.osoa.sca.ServiceRuntimeException:
org.osoa.sca.ServiceRuntimeException:
org.apache.tuscany.sca.contribution.service.ContributionResolveException
: PolicyValidation exception when processing implementation of component
'HelloWorldServiceComponent' due to Policy Intent
'{http://gdit.com/}foobar' is not defined in this domain  

      at
org.apache.tuscany.sca.host.embedded.SCADomain.createNewInstance(SCADoma
in.java:264)

      at
org.apache.tuscany.sca.host.embedded.SCADomain.newInstance(SCADomain.jav
a:69)

      at helloworld.Launch.main(Launch.java:13)

Caused by: org.osoa.sca.ServiceRuntimeException:
org.apache.tuscany.sca.contribution.service.ContributionResolveException
: PolicyValidation exception when processing implementation of component
'HelloWorldServiceComponent' due to Policy Intent
'{http://gdit.com/}foobar' is not defined in this domain  

      at
org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain.addContributi
on(DefaultSCADomain.java:274)

      at
org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain.init(DefaultS
CADomain.java:152)

      at
org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain.<init>(Defaul
tSCADomain.java:109)

      at
org.apache.tuscany.sca.host.embedded.SCADomain.createNewInstance(SCADoma
in.java:230)

      ... 2 more

Caused by:
org.apache.tuscany.sca.contribution.service.ContributionResolveException
: PolicyValidation exception when processing implementation of component
'HelloWorldServiceComponent' due to Policy Intent
'{http://gdit.com/}foobar' is not defined in this domain  

      at
org.apache.tuscany.sca.assembly.xml.CompositeProcessor.resolve(Composite
Processor.java:885)

      at
org.apache.tuscany.sca.assembly.xml.CompositeProcessor.resolve(Composite
Processor.java:80)

      at
org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProc
essor.resolve(ExtensibleStAXArtifactProcessor.java:109)

      at
org.apache.tuscany.sca.assembly.xml.CompositeDocumentProcessor.resolve(C
ompositeDocumentProcessor.java:138)

      at
org.apache.tuscany.sca.assembly.xml.CompositeDocumentProcessor.resolve(C
ompositeDocumentProcessor.java:53)

      at
org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProce
ssor.resolve(ExtensibleURLArtifactProcessor.java:86)

      at
org.apache.tuscany.sca.contribution.service.impl.ContributionServiceImpl
.processResolvePhase(ContributionServiceImpl.java:464)

      at
org.apache.tuscany.sca.contribution.service.impl.ContributionServiceImpl
.addContribution(ContributionServiceImpl.java:348)

      at
org.apache.tuscany.sca.contribution.service.impl.ContributionServiceImpl
.contribute(ContributionServiceImpl.java:161)

      at
org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain.addContributi
on(DefaultSCADomain.java:272)

      ... 5 more

Caused by: org.apache.tuscany.sca.policy.util.PolicyValidationException:
Policy Intent '{http://gdit.com/}foobar' is not defined in this domain  

      at
org.apache.tuscany.sca.policy.util.PolicyValidationUtils.validateIntents
(PolicyValidationUtils.java:66)

      at
org.apache.tuscany.sca.assembly.xml.CompositeProcessor.resolveImplIntent
sAndPolicySets(CompositeProcessor.java:914)

      at
org.apache.tuscany.sca.assembly.xml.CompositeProcessor.resolve(Composite
Processor.java:867)

 

 

These are my file:

 

(intents definitions.xml)

<?xml version="1.0" encoding="ASCII"?>

<!--

 * Licensed to the Apache Software Foundation (ASF) under one

 * or more contributor license agreements.  See the NOTICE file

 * distributed with this work for additional information

 * regarding copyright ownership.  The ASF licenses this file

 * to you under the Apache License, Version 2.0 (the

 * "License"); you may not use this file except in compliance

 * with the License.  You may obtain a copy of the License at

 * 

 *   http://www.apache.org/licenses/LICENSE-2.0

 * 

 * Unless required by applicable law or agreed to in writing,

 * software distributed under the License is distributed on an

 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

 * KIND, either express or implied.  See the License for the

 * specific language governing permissions and limitations

 * under the License.    

-->

<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" 

                                constrains="sca:implementation.java">

                                <description>

                                                FooBar Policy

                                </description>

                </intent>

</definitions>

 

HelloWorld.composite

 

<?xml version="1.0" encoding="UTF-8"?>

<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"

                targetNamespace="http://gidt.com/"

    xmlns:gdit="http://gdit.com/"

    name="helloworld">

 

    <component name="HelloWorldServiceComponent">

                    <implementation.java
class="helloworld.HelloWorldImpl">

                                <operation name="sayWorld"
requires="gdit:foobar"/>

                </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>

 

And the policy definitions file:

<?xml version="1.0" encoding="UTF-8"?>

<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:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"

    xmlns:gdit="http://gdit.com/">

 

    <!-- PolicySets -->

    <policySet name="FooBarPolicy" provides="gdit:foobar"
appliesTo="sca:implementation.java"

        xmlns="http://www.osoa.org/xmlns/sca/1.0">

    </policySet>

</definitions>

 

 

Any help would be greatly appreciated.

 

 

Mike Sacauskis

 


RE: stack trace: PolicyValidation exception

Posted by "Sacauskis, Mike" <Mi...@gdit.com>.
No, that's not it.

-----Original Message-----
From: Luciano Resende [mailto: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 <Mi...@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/

RE: stack trace: PolicyValidation exception

Posted by "Sacauskis, Mike" <Mi...@gdit.com>.
(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 [mailto: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 <Mi...@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/

Re: stack trace: PolicyValidation exception

Posted by Luciano Resende <lu...@gmail.com>.
Should your intent be                 <intent name="gdit:FooBarPolicy"
instead of                 <intent name="FooBarPolicy" ?

On Thu, Mar 5, 2009 at 5:23 PM, Sacauskis, Mike <Mi...@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/