I want to start a thread on server startup. My thread pulls data from db and put it in JMS queue. all the beans are defined in Spring config files. JMS queues and DB connection factory (CONNECTION-FACTORY)are configured on weblogic.
I’m trying to put my thread starting code in contextInitialized method of ContextLoaderListener or init method of servlet. However I’m getting following exception while starting server:
nested exception is
javax.naming.NoPermissionException:
User anonymous does not have
permission on CONNECTION-FACTORY to
perform lookup operation.
My code works perfectly if i put it in doGet method of Servlet and hit the url after server startup. However I dont want to start thread manually.
I think that I’m getting this error because all the beans are not initialized properly.
Where do i put my code so that thread starts automatically after server startup?
Found solution for this one. For exception
javax.naming.NoPermissionException, we should add following lines to theweblogic.xml. It initiazes webapp with user and enable JNDI lookup on deployment