Search code examples
javaxmljakarta-eejavabeansjava-ee-6

Beans.xml and SessionScoped


Today my employeer told me to optimize the web application. And I want to change all the controllers to @ConversationScoped and only use @SessionScoped for only controllers that I need for all Session. When I was changing the first controller to @ConversationScoped. The IDE(Netbeans 7.4) told me that I needed a beans.xml. Okay I create the beans.xml and everything that I needed. When I started to deploy It throw me this message

Same interception type cannot be specified twice on the same class

Then I changed again to @SessionScoped and restart my server(GlassFish 3.1.2) and everything is ok. Then I only created the beans.xml deploy and threw me again that error msg. Delete the beans.xml, restart server and everything is ok. I checked my project and no. I don't have two beans.xml.


Solution

  • I found that I have two @PostConstruct in one controller. The strange thing that this error I got it only with beans.xml.

    If you have two annotations like @PreDestroy @PostConstruct it will trhew you and error.