PDA

View Full Version : Set port in RmiServiceExporter



cburghardt
Jan 16th, 2006, 09:15 AM
Hi,

I export 3 beans as RMI services. I want to programmatically set the serviceport to something different than 1099 so I retrieve the beans from the ApplicationContext and call RmiServiceExporter#setRegistryPort
But as the bean has already been initialized when I retrieve it I need to shutdown the registry (for all 3 beans), set the new port and restart. How can I do that? I already tried to call "destroy", set the port and then "afterPropertiesSet" but then I get an RMI exception that the "ObjectID" is already in use :confused:


Regards,

Carsten

Costin Leau
Jan 16th, 2006, 10:46 AM
Can you post the relevant appContext configuration and stacktrace? If you want to set the bean programatically then try using a bean post processor so you can inject the port before the beans are injected into other beans.
A FactoryBean might help if your object creation is complex.

cburghardt
Jan 16th, 2006, 12:35 PM
Great, the post-processor did it! Thanks a lot. I registered one bean as post-processor and changed the rmi port.