wood burning stoves 2.0*
The moose likes Spring and the fly likes One spring bean initialized 2 times when start the jboss, but 1 time when just publish in STS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "One spring bean initialized 2 times when start the jboss, but 1 time when just publish in STS" Watch "One spring bean initialized 2 times when start the jboss, but 1 time when just publish in STS" New topic
Author

One spring bean initialized 2 times when start the jboss, but 1 time when just publish in STS

Peter Saw
Greenhorn

Joined: Jun 20, 2007
Posts: 10
I am using STS and JBoss.
Have a strange problem since this week Monday. It works fine before.
One spring service bean (@Service) will be autowired in another bean.

When start the jboss, find the bean is initialized 2 times.
When just publish, the bean is initialized 1 time only.

I have a transactional method in the bean with @Transactional.
After start the jboss, the transactional works.
But if publish, the transactional does not works.

Anyone has ever experience this? What's the possible reason?

Some questions can be raised.
In which situation or senario the bean could be initialized 2 times automatically?
Why Spring @Transactional dose not work?
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1648
    
    7

When start the jboss, find the bean is initialized 2 times.
When just publish, the bean is initialized 1 time only.


What do you mean by start and publish? Is start starting the server and publish right clicking the server in STS while it is running in debug and publishing changes to the server? If so what kind of changes are you publishing while its running? You cant make changes to annotations etc without restarting the server.

What do you mean by is initialized 2 times? Are you initializing the same XML twice in your web.xml? Are the beans defined multiple times in different web contexts? Do you have multiple component scanners scanning the same packages? Do you have @Configuration classes being picked up twice? In the end in most cases you will end up with a single spring bean but things like I have listed can cause multiple initializations.

That is about the most help I can give you without seeing more of your actual configuration. Also perhaps your start-up log showing the multiple initialization may help. Some times dropping the logging level down to debug for your Spring stuff can help you better debug whats happening on start-up.

Good Luck



[How To Ask Questions][Read before you PM me]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: One spring bean initialized 2 times when start the jboss, but 1 time when just publish in STS
 
Similar Threads
Spring Transaction Problem
Rapid Application Development
Spring Transaction
Beginner about spring should have to start with Springroo
Spring DM versus JSR-291