Oh, yeah! Just as you said, it should be wroten into <reference name="roleManager" target="Permission/roleManager" />. I only noticed that the code should specify the service name, like this: scadomain.getService(cl, ComponentName + "/" + serviceName); but I neglected it in the .composite file. Thanks a lot. jiangjian
2011/2/7 Simon Nash <[email protected]> > jiangjian wrote: > >> Hi. >> I'm using Tuscany1.6 to develope several component. I always got the >> error: >> org.osoa.sca.ServiceUnavailableException: Unable to create SCA binding >> invoker for local target User reference roleManager (bindingURI=Permission >> operation=add) >> at >> org.apache.tuscany.sca.binding.sca.impl.RuntimeSCAReferenceBindingProvider.createInvoker(RuntimeSCAReferenceBindingProvider.java:215) >> at >> org.apache.tuscany.sca.core.assembly.RuntimeWireImpl.addReferenceBindingInterceptor(RuntimeWireImpl.java:329) >> at >> org.apache.tuscany.sca.core.assembly.RuntimeWireImpl.initInvocationChains(RuntimeWireImpl.java:208) >> at >> org.apache.tuscany.sca.core.assembly.RuntimeWireImpl.getInvocationChains(RuntimeWireImpl.java:118) >> at >> org.apache.tuscany.sca.core.assembly.EndpointWireImpl.getInvocationChains(EndpointWireImpl.java:120) >> at >> org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.getInvocationChain(JDKInvocationHandler.java:298) >> at >> org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:188) >> at $Proxy35.get(Unknown Source) >> at >> com.nodeservice.framework.adapter.user.permission.RoleManagerAdapter4User.getRoleListByUserId(RoleManagerAdapter4User.java:29) >> at >> com.nodeservice.framework.users.service.UsersManagerImpl.getUserByUserNameandpwd(UsersManagerImpl.java:319) >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> at >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) >> at >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) >> at java.lang.reflect.Method.invoke(Method.java:597) >> at >> org.apache.tuscany.sca.implementation.spring.invocation.SpringInvoker.doInvoke(SpringInvoker.java:97) >> at >> org.apache.tuscany.sca.implementation.spring.invocation.SpringInvoker.invoke(SpringInvoker.java:113) >> at >> org.apache.tuscany.sca.binding.sca.impl.SCABindingInvoker.invoke(SCABindingInvoker.java:61) >> at >> org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:349) >> at >> org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:193) >> at $Proxy32.getUserByUserNameandpwd(Unknown Source) >> *Here is the .Composite file:* >> All of the components in my projects implemented using spring. >> *crucian-user.composite* : >> <component name="User"> >> <implementation.spring >> location="META-INF/sca-deployables/applicationContext-user.xml"></implementation.spring> >> <service name="usersManager"> >> <interface.java >> interface="com.nodeservice.framework.users.IUsersManager"/> >> </service> >> <reference name="sessionFactory" target="Model" /> >> <reference name="organizationManager" target="Organization" /> >> <reference name="roleManager" target="Permission" /> >> </component> >> *crucian-permission.composite:* >> <component name="Permission"> >> <implementation.spring >> location="META-INF/sca-deployables/applicationContext-permission.xml"></implementation.spring> >> <service name="permissionManager"> >> <interface.java >> interface="com.nodeservice.framework.permission.IPermissionManager"/> >> </service> >> <service name="resourceManager"> >> <interface.java >> interface="com.nodeservice.framework.resource.IResourceManager"/> >> </service> >> <service name="roleManager"> >> <interface.java >> interface="com.nodeservice.framework.role.IRoleManager"/> >> </service> >> </component> >> I debuged the error and found the error is because the "service" is null >> in RuntimeSCAReferenceBindingProvider. >> RuntimeComponentService service = >> (RuntimeComponentService)target.getContract(); >> if (*service != null*) { // not a callback wire >> SCABinding scaBinding = >> service.getBinding(SCABinding.class); >> InvocationChain chain = >> service.getInvocationChain(scaBinding, >> wire.getSource().getInterfaceContract(), operation); >> return chain == null ? null : new SCABindingInvoker(chain); >> } >> But I don't know how to correct it. Does anybody know why? >> Thanks, >> 2011-02-06 >> ------------------------------------------------------------------------ >> jiangjian >> > > > The problem might be in this line: > > <reference name="roleManager" target="Permission" /> > > You have given the Permission component as the target of the reference, > but you haven't said which service in this component should be used. > In this case, SCA will choose a default service if and only if there is > exactly one service in this component with a compatible interface. > > If the component doesn't have a service with a compatible interface, or > if it has more than one service with a compatible interface, SCA won't > be able to connect the reference to the service. > > You can find out if this is the cause of the problem by adding the > service name to the reference target. For example, you can specify: > <reference name="roleManager" target="Permission/roleManager" /> > if you want the roleManager service to be the target. > > Simon > >
