-
1. Re: ServiceDeployedListener
kcbabo Feb 12, 2013 6:50 PM (in response to anikulin)Need a bit more info to provide some guidance. Are the services in the same application or different applications? Based on the reference to injection and a constructor, I'm assuming we are talking about CDI services here? Another thing to try would be putting the method invocation in a @PostConstruct method instead of the constructor, but that's just a shot in the dark until we have more info on what the app is doing.
-
2. Re: ServiceDeployedListener
anikulin Feb 14, 2013 5:24 PM (in response to kcbabo)Yes, that's a CDI services, which work in the same application.
I have such service implementations in my application:
@Service(NewsService.class)public class NewsServiceBean implements NewsService {
@Inject
@Reference
private DBNewsService dbService;
....
}
@Service(DBNewsService.class)
public class DBNewsServiceBean implements DBNewsService {
...
}
And i want to invoke method from DBNewsServiceBean in NewsServiceBean right after application deployment.
Thanks
-
3. Re: ServiceDeployedListener
kcbabo Feb 14, 2013 6:28 PM (in response to anikulin)In that scenario, it's up to CDI in terms of when injected beans are available. Did you try the invocation from a @PostConstruct method? If that doesn't work, we can dig deeper.
-
4. Re: ServiceDeployedListener
anikulin Feb 15, 2013 11:55 AM (in response to kcbabo)Yes, I've tried. I added an annotated method, it's invoked and starts running, but when it reaches the line with the reference service, i have have such error:
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_10]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_10]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_10]
at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_10]
at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:267)
at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:263)
at org.jboss.weld.introspector.jlr.WeldMethodImpl.invoke(WeldMethodImpl.java:174)
at org.jboss.weld.bean.AbstractClassBean.defaultPostConstruct(AbstractClassBean.java:391)
... 16 more
Caused by: java.lang.reflect.UndeclaredThrowableException
at $Proxy36.addEconomicEvent(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_10]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_10]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_10]
at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_10]
at org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:44)
at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105)
at org.jboss.weld.proxies.DBNewsService$1366014918$Proxy$_$$_WeldClientProxy.addEconomicEvent(DBNewsService$1366014918$Proxy$_$$_WeldClientProxy.java)
at com.magick.alpha.service.NewsServiceBean.processEconomicNews(NewsServiceBean.java:66)
at com.magick.alpha.service.NewsServiceBean.initialize(NewsServiceBean.java:46)
... 26 more
Caused by: org.switchyard.component.bean.BeanComponentException: A service reference to service 'DBNewsService' is not bound into this client proxy instance. A reference configuration to the service may be required in the application configuration.
at org.switchyard.component.bean.ClientProxyBean$ClientProxyInvocationHandler.invoke(ClientProxyBean.java:274)
... 36 more
Thanks -
5. Re: ServiceDeployedListener
kcbabo Feb 15, 2013 12:13 PM (in response to anikulin)That stack trace helps. I assumed from your first post that the invocation proxy was not available, but that's not the case. What's missing is the service reference in the invocation proxy which is added in a callback from our deployer. Can you paste the switchyard.xml for your app? I'm curious if the document order of the service component definitions can be changed to get this to resolve.
-
6. Re: ServiceDeployedListener
rcernich Feb 15, 2013 12:14 PM (in response to anikulin)Hey Anton,
Shot in the dark here, but does your component also declare a reference, in the switchyard.xml file? I suspect that's the cause of, "A service reference to service 'DBNewsService' is not bound into this client proxy instance." Add a reference to DBNewsService on your "NewsServiceBean" component.
Hope that helps,
Rob
-
7. Re: ServiceDeployedListener
anikulin Feb 15, 2013 12:22 PM (in response to anikulin)I declared neither interfaces not references in my switchyard.xml. It looks like this and contains only SOAP binding for one of services.I used annotation @Service to declare interfaces and references. Should i also do this explicitly in switchyard.xml?
<?xml version="1.0" encoding="UTF-8"?>
<switchyard xmlns="urn:switchyard-config:switchyard:1.0"
xmlns:bean="urn:switchyard-component-bean:config:1.0" xmlns:camel="urn:switchyard-component-camel:config:1.0"
xmlns:common_selector="urn:switchyard-component-common-selector:config:1.0"
xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
xmlns:soap="urn:switchyard-component-soap:config:1.0" name="alpha"
targetNamespace="urn:com.magick:alpha:0.0.1-SNAPSHOT">
<sca:composite name="alpha" targetNamespace="urn:com.magick:alpha:0.0.1-SNAPSHOT">
<sca:service name="DBNewsServicePortType" promote="DBNewsService/DBNewsService">
<sca:interface.wsdl
interface="DBNewsService.wsdl#wsdl.porttype(DBNewsServicePortType)" />
<soap:binding.soap>
<soap:contextMapper />
<soap:wsdl>DBNewsService.wsdl</soap:wsdl>
<soap:socketAddr>:8080</soap:socketAddr>
<soap:contextPath>alpha</soap:contextPath>
</soap:binding.soap>
</sca:service>
<sca:service name="NewsService" promote="NewsService/NewsService">
<sca:interface.java interface="com.magick.alpha.service.NewsService" />
<camel:binding.camel configURI="timer://myTimer?period=43200s&delay=2s">
<common_selector:operationSelector operationName="processEconomicNews"/>
</camel:binding.camel>
</sca:service>
</sca:composite>
</switchyard>
-
8. Re: ServiceDeployedListener
kcbabo Feb 15, 2013 12:23 PM (in response to anikulin)Can you post the switchyard.xm that's in target/classes/META-INF in your project after a build?
-
9. Re: ServiceDeployedListener
anikulin Feb 15, 2013 1:44 PM (in response to kcbabo)Yes, sure. Thanks for help.
-
switchyard.xml 3.1 KB
-
-
10. Re: ServiceDeployedListener
kcbabo Feb 17, 2013 9:38 PM (in response to anikulin)1 of 1 people found this helpfulThe culprit here is that CDI discovery and the SY application events (e.g. service registration) have independent lifecycles. CDI discovery happens first and beans are initialized before SY services are registered. This isn't a problem for SY applications *unless* you try to use SY services based on the CDI lifecycle, which is what happens when you try to invoke a service in the bean's constructor or even an @PostConstruct method. The best path forward is probably for our bean service activator to push a CDI event when a service has been completely started - at this point the services and service references are available. You could then add an @Observes method to your bean service which performs the invocation based on the start event.
If this sounds acceptable, please file a JIRA requesting the change: -
11. Re: ServiceDeployedListener
anikulin Feb 25, 2013 12:52 PM (in response to kcbabo)Thanks a lot! That sounds good, I created a JIRA task.
-
12. Re: ServiceDeployedListener
synclpz Jul 1, 2013 4:33 AM (in response to anikulin)Any news on that topic? I think I'm facing the same issue at the moment?
Could you post a link to this JIRA?