Error Handling Beans.xml In Meta-inf/beans.xml
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up CDI: beans.xml, where do I put you? up vote 33 down vote favorite 8 I am using Weld as CDI implementation. My integration test, that tries to assemble object graph instantiating Weld container works well, when I have empty beans.xml in src/test/java/META-INF/beans.xml. Here is that simple test: public class WeldIntegrationTest { @Test public void testInjector() { new Weld().initialize(); // shouldn't throw exception } } Now when I run mvn clean install, I always get: Missing beans.xml file in META-INF! My root folders are "src" and "web" which contains WEB-INF folder, but I also tried to use default maven structure and renamed "web" to "webapp" and moved it to src/main. I tried all the reasonable locations I could thought of: - src/main/java/META-INF/beans.xml - src/test/java/META-INF/beans.xml - web/WEB-INF/beans.xml - src/main/webapp/WEB-INF/beans.xml - src/main/webapp/META-INF/beans.xml - src/main/webapp/META-INF/(empty) and src/main/webapp/WEB-INF/beans.xml Nothing works so far :/ java java-ee maven cdi jboss-weld share|improve this question edited Oct 24 '12 at 20:31 maba 26k66287 asked Oct 24 '12 at 19:28 Xorty 6,6781265114 In my CDI project the beans.xml is in src\main\webapp\WEB-INF, and in my war file it is in WEB-INF dir also. –kaos Oct 24 '12 at 19:49 add a comment| 2 Answers 2 active oldest votes up vote 63 down vote accepted For EJB and JAR packaging you should place the beans.xml in src/main/resources/META-INF/. For WAR packaging you should place the beans.xml in src/main/webapp/WEB-INF/. Remember that only .java files should be put in the src/main/java and src/test/java directories. Resources like .xml files should be in src/main/resources. share|improve this answer edited Oct 24 '12 at 20:38 answered Oct 24 '12 at 20:27 maba 26k66287 Perfect, in my case it works in src/main/resources/META-INF –Xorty Oct 24 '12 at 20:31 In my case I'm testing cdi-unit (uses Weld) I have to put it in my src –dalvarezmartinez1 Jan 10 '14 at 15:36 @dalvarezmartinez1 I bet you could move beans.xml
not work correctly without it enabled. Please turn JavaScript back on and reload this page. All Places > Weld > Discussions Please enter a title. You can not post a blank message. Please type your message and try again. 12 Replies Latest reply on Jul 3, 2013 7:55 AM by klauskinski one beans.xml for all subdeployments possible? klauskinski Jul 2, 2013 3:23 AM Hi,I have http://stackoverflow.com/questions/13056336/cdi-beans-xml-where-do-i-put-you one EAR file containing multiple jar files below lib/.In the past all the jar files in lib/ which are providing beans contained a beans.xml and it worked fine.Now I need several jar files also for another application which uses Spring and not https://developer.jboss.org/thread/229978 CDI. Because of that, the beans.xml is now a problem as weld (which is starting automatically during the JBoss deployment) is conflicting with spring.The plan is now to remove the beans.xml files from each jar file and only have one beans.xml file in the encapsulating ear file for the CDI applications handling the beans creation with Weld of all subdeployments.But - it is not working.I placed the beans.xml below META-INF/ of the ear but it looks like no beans are created from the subdeployments:
appears when a beans.xml exists Summary: "Crete Beans.xml" warning appears when a https://netbeans.org/bugzilla/show_bug.cgi?id=203710 beans.xml exists Status: RESOLVED FIXED Product: javaee Classification: Unclassified Component: CDI https://netbeans.org/bugzilla/show_bug.cgi?id=231433 Version: 7.2 Hardware: PC Windows 7 Priority: P2 with 3 votes (vote) TargetMilestone: 7.2 Assigned To: Sergey Petrov QA Contact: issues@javaee URL: Whiteboard: 71patch1-verified Keywords: REGRESSION Duplicates: 207356 207485 207623 (view as bug list) Depends on: Blocks: Show dependency tree /graph Reported: 2011-10-14 11:28 error handling UTC by rveldpau Modified: 2013-07-22 04:48 UTC (History) CC List: 8 users (show) blindner hantsy hpgisler jlahoda kganfield mmirilovic nameless1 pjiricka See Also: Issue Type: DEFECT Exception Report : Attachments Add an attachment (proposed patch, testcase, etc.) Note You need to log in before you can comment on or make changes to this bug. Description rveldpau error handling beans.xml 2011-10-14 11:28:15 UTC Product Version = NetBeans IDE 7.1 Beta (Build 201109252201) Operating System = Windows 7 version 6.1 running on amd64 Java; VM; Vendor = 1.6.0_24 Runtime = Java HotSpot(TM) 64-Bit Server VM 19.1-b02 The error message "Crete Beans.xml" appears even if you have beans.xml in your built application. The default location that the beans.xml is created is in your src/main/java folder under META-INF. Since this is not really java, I put it in src/main/resources in a folder named META-INF. Both are valid, but Netbeans complains that a beans.xml doesn't exist if you have it in my location. Also, I have not found a way to turn this message off in "Option/Editor/Hints" Oh, and as a final note... it should probably be "Create" and not "Crete" Comment 1 Jan Lahoda 2011-10-17 07:56:52 UTC A quick search over built NB reveals that this hint is provided by web.beans module, which maps to javaee/code. Comment 2 Martin Janicek 2011-10-21 09:21:59 UTC I think that this is CDI related --> reassigni
"CDI artifact is found but there is no beans.xml file." Summary: Erroneous error "CDI artifact is found but there is no beans.xml file." Status: RESOLVED DUPLICATE of bug 230730 Product: javaee Classification: Unclassified Component: CDI Version: 7.3 Hardware: PC Windows 7 Priority: P3 (vote) TargetMilestone: TBD Assigned To: Sergey Petrov QA Contact: issues@javaee URL: Whiteboard: Keywords: Depends on: Blocks: Show dependency tree /graph Reported: 2013-06-18 11:46 UTC by mccomber Modified: 2013-08-08 20:14 UTC (History) CC List: 2 users (show) arturo_serrano zeratul2k See Also: Issue Type: DEFECT Exception Report : Attachments IDE log (49.04 KB, text/plain) 2013-06-18 11:46 UTC, mccomber Details View All Add an attachment (proposed patch, testcase, etc.) Note You need to log in before you can comment on or make changes to this bug. Description mccomber 2013-06-18 11:46:40 UTC Product Version = NetBeans IDE 7.3 (Build 201306052037) Operating System = Windows 7 version 6.1 running on x86 Java; VM; Vendor = 1.7.0_17 Runtime = Java HotSpot(TM) Client VM 23.7-b01 After updating the IDE and plugins I noticed all my beans in the project I had open where red underlined with "CDI artifact is found but there is no beans.xml file." beans.xml already exists in WEB-INF. Clicking the hint "create beans.xml" does nothing. I deleted beans.xml by hand (outside of the IDE) and then clicked the hint to create it. The file was created yet the error exists still in all the beans. Comment 1 mccomber 2013-06-18 11:46:45 UTC Created attachment 135960 [details] IDE log Comment 2 chrisjr 2013-06-19 08:58:22 UTC I am also seeing this bug with NB 7.3.1. I have just upgraded from NetBeans 7.2 in order to try and resolve [this other bug|http://stackoverflow.com/questions/10757793/netbeans-warning-on-event-injection], but this new bug is even worse! I'm going to try downgrading to NB 7.2.1 instead. For the record: I have a WAR project, and my beans.xml file is in my WEB-INF directory. Comment 3 zeratul2k 2013-06-24 13:22:30 UTC I can confirm this behaviour after updating a Netbeans 7.3. It's very distracting to have false-positive red lines on files I'm working on. Comment 4 Sergey Petrov 2013-06-27 11:17:47 UTC For 7.3.1 it may have sense to try to create meta-inf folder with beans.xml just to avoid this warning, but I don't know if it may or nor broke any functionality. *** This bug has been marked as a duplicate of bug 230730 *** Comment