I have one question on spring beans dependency injection.
I have one bean which needs to be loaded during startup and inside this bean i have one dependency bean which i want to load during the first request.
so i made the lazy-init true for that bean. but because of @autowired annotation when first bean is loaded it tries to find the dependency bean which is not available in the contained(lazy loading is set true).
so how can i inject this dependency to load during first request ?
suggest me except Application context /bean factory loading
By definition an eagerly loaded bean can not have dependencies on a lazy one or it will nullify the lazy load. My first question is can you describe why the need for lazy loading? Lazy loading is often misused and I would take a close look at if that is the best solution, it is even more suspicious since you have a bean that you apparently think needs to be eager yet has a dependency on the lazy. Most likely something is wrong with your dependencies or that bean should not really be lazy in the first place.
lazy load should be reserved for very expensive initialization scenarios which make sense to put off. If you think about it, usually it makes more sense to pay the piper at startup then at runtime when a request comes in, unless of course it is unlikely that request will ever come. If start-up performance is a huge concern you may want to consider lazy loaded beans. Another disadvantage of them, is that if something goes wrong during initialization you will not know at start-up but rather it may pop up hours, days or weeks later. I can count the number of times I have used lazy initialized beans on one hand.
That said with RMI (I assume you are using Spring for this) have a look at the lookupStubOnStartup property of the RmiProxyFactoryBean. Try setting it to false.
I am having the same issue. I tired setting lookup-home-on-startup="false", it did solves the initialization issue.
However, when my client tries to call the remote server, it encounters an error: No EJB receiver available for handling combination for invocation context.
By setting the above to true, it will work.
Any idea how to resolve this?