{"action":"created","issue":{"url":"https://api.github.com/repos/wildfly-extras/wildfly-camel/issues/978","labels_url":"https://api.github.com/repos/wildfly-extras/wildfly-camel/issues/978/labels{/name}","comments_url":"https://api.github.com/repos/wildfly-extras/wildfly-camel/issues/978/comments","events_url":"https://api.github.com/repos/wildfly-extras/wildfly-camel/issues/978/events","html_url":"https://github.com/wildfly-extras/wildfly-camel/issues/978","id":116392438,"number":978,"title":"Camel-CDI is not working properly if application packaged as ear","user":{"login":"sverkera","id":347473,"avatar_url":"https://avatars.githubusercontent.com/u/347473?v=3","gravatar_id":"","url":"https://api.github.com/users/sverkera","html_url":"https://github.com/sverkera","followers_url":"https://api.github.com/users/sverkera/followers","following_url":"https://api.github.com/users/sverkera/following{/other_user}","gists_url":"https://api.github.com/users/sverkera/gists{/gist_id}","starred_url":"https://api.github.com/users/sverkera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sverkera/subscriptions","organizations_url":"https://api.github.com/users/sverkera/orgs","repos_url":"https://api.github.com/users/sverkera/repos","events_url":"https://api.github.com/users/sverkera/events{/privacy}","received_events_url":"https://api.github.com/users/sverkera/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/wildfly-extras/wildfly-camel/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/wildfly-extras/wildfly-camel/milestones/8","html_url":"https://github.com/wildfly-extras/wildfly-camel/milestones/3.2.0","labels_url":"https://api.github.com/repos/wildfly-extras/wildfly-camel/milestones/8/labels","id":1294839,"number":8,"title":"3.2.0","description":"","creator":{"login":"tdiesler","id":244946,"avatar_url":"https://avatars.githubusercontent.com/u/244946?v=3","gravatar_id":"","url":"https://api.github.com/users/tdiesler","html_url":"https://github.com/tdiesler","followers_url":"https://api.github.com/users/tdiesler/followers","following_url":"https://api.github.com/users/tdiesler/following{/other_user}","gists_url":"https://api.github.com/users/tdiesler/gists{/gist_id}","starred_url":"https://api.github.com/users/tdiesler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdiesler/subscriptions","organizations_url":"https://api.github.com/users/tdiesler/orgs","repos_url":"https://api.github.com/users/tdiesler/repos","events_url":"https://api.github.com/users/tdiesler/events{/privacy}","received_events_url":"https://api.github.com/users/tdiesler/received_events","type":"User","site_admin":false},"open_issues":13,"closed_issues":31,"state":"open","created_at":"2015-09-08T07:40:09Z","updated_at":"2015-11-13T14:28:28Z","due_on":"2015-11-30T23:00:00Z","closed_at":null},"comments":3,"created_at":"2015-11-11T18:27:04Z","updated_at":"2015-11-15T11:36:48Z","closed_at":null,"body":"I have an application where I am heavily utilizing Named beans from Camel routes, these beans are a mix of POJO's, Stateless and Statefull Session Beans. The application is packaged as an ear containing ejb jar and war.\r\n\r\nAfter upgrading from Wildfly 8.2.0 / Wildfly-Camel 2.2.0 to Wildfly 9.0.1 / Wildfly-Camel 3.1.0 I noticed that the Camel routes in many, but not all, cases are not able to find the named beans.\r\n\r\nCases which doesn't work:\r\n- file filter (file://target/cdifilefilter/?recursive=true&filter=#cdiFileFilter)\r\n- bean reference ( .bean(\"namedBean\"), since .beanRef is deprecated)\r\n- poll strategy for FTP consumer\r\n\r\nCases which does work:\r\n- refering to a bean in .to instead of .bean ( .to(\"bean:namedBean\") )\r\n\r\nI then attempted to use the camel-cdi implementation from https://github.com/astefanutti/camel-cdi but it gives the same problem.\r\n\r\nAfter setting up Arquillian for my project I could narrow down on the issue, specifically on the file filter example. I then found that if I package the testcase as a .jar or .war then it works but not when I do the exact same thing and package it as a .ear.\r\n\r\nI have created testcases to demonstrate the issue on Wildfly-Camel test projects, first an variant of org.wildfly.camel.test.cdi.CDIIntegrationTest which creates a EnterpriseArchive deployment but then it will not be able to find the seda component.\r\n\r\nThen two testcases for file and filter where one deploys as jar and the other as ear, this is exacly the same as the testcase I made in my project. The testcase deployed as ear will fail with the following message:\r\n\r\norg.apache.camel.FailedToCreateRouteException: Failed to create route route1: Route(route1)[[From[file://target/cdifilefilter/?recursive=t... because of Failed to resolve endpoint: file://target/cdifilefilter/?filter=%23cdiFileFilter&recursive=true due to: Could not find a suitable setter for property: filter as there isn't a setter method with same type: java.lang.String nor type conversion possible: No type converter available to convert from type: java.lang.String to the required type: org.apache.camel.component.file.GenericFileFilter with value #cdiFileFilter\r\n\r\nPatch to add these testcases attached\r\n[cdi-ear-tests.txt](https://github.com/wildfly-extras/wildfly-camel/files/32143/cdi-ear-tests.txt)\r\n"},"comment":{"url":"https://api.github.com/repos/wildfly-extras/wildfly-camel/issues/comments/156805430","html_url":"https://github.com/wildfly-extras/wildfly-camel/issues/978#issuecomment-156805430","issue_url":"https://api.github.com/repos/wildfly-extras/wildfly-camel/issues/978","id":156805430,"user":{"login":"sverkera","id":347473,"avatar_url":"https://avatars.githubusercontent.com/u/347473?v=3","gravatar_id":"","url":"https://api.github.com/users/sverkera","html_url":"https://github.com/sverkera","followers_url":"https://api.github.com/users/sverkera/followers","following_url":"https://api.github.com/users/sverkera/following{/other_user}","gists_url":"https://api.github.com/users/sverkera/gists{/gist_id}","starred_url":"https://api.github.com/users/sverkera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sverkera/subscriptions","organizations_url":"https://api.github.com/users/sverkera/orgs","repos_url":"https://api.github.com/users/sverkera/repos","events_url":"https://api.github.com/users/sverkera/events{/privacy}","received_events_url":"https://api.github.com/users/sverkera/received_events","type":"User","site_admin":false},"created_at":"2015-11-15T11:36:48Z","updated_at":"2015-11-15T11:36:48Z","body":"Back to the original issue. When tracing on the working setup I see that the bean lookup is done on the beanmanager for my ejb jar and there the bean is found:\r\n\r\nWeld BeanManager for Ingester-1.0.0-SNAPSHOT.ear/Ingester-core-1.0.0-SNAPSHOT.jar/ [bean count=76]\r\n\r\nBut in the non-working case the beanmanager used is the one for camel-cdi jar:\r\nWeld BeanManager for cdi-filefilter-ear-test.ear.external.jar:file:/C:/Users/Sverker/.m2/repository/org/apache/camel/camel-cdi/2.16.0/camel-cdi-2.16.0.jar!/META-INF/beans.xml [bean count=42]\r\n\r\nComparing the code of CdiBeanRegistry class between 2.15.0 and 2.16.0 I see that the former let Deltaspike find the correct BeanManager using the classloader while the latter uses one that has been injected, which will be that for camel-cdi jar. This behaviour was introduced in 2.16.0\r\n\r\nEither the correct way is the old behaviour to find BeanManager like Deltaspike does or that the app server should handle some kind of delegation to the correct manager."}}