bwhelan
04-26-2007, 04:25 PM
Hi,
I'm running up against a brick wall trying to figure out how to do this, if it is possible, or if I am doing it the right way. I'd be glad of any help.
I have a web app using Spring.NET, and the NHibernate 1.2 beta module. I have it all working when all the tiers are hosted on the same server. Now, I want to split the tiers onto a web server and a second server for the business services and database. Basically, all the NHibernate work will be done on the new app server and the services exported via remoting. So i think the only module that needs to be configured on the web server is the OpenSessionInViewModule.
Now here is the catch: I can't get OpenSessionInViewModule to work over remoting and can't find any examples of someone who has done this. OSIV needs a SessionFactory instance, but that is configured with all the other Spring NHibernate components on the business logic server. Can an instance of the Spring LocalSessionFactoryObject be remoted to the web server (i.e. is declared as a MarshalByRefObject)? Currently it is giving me a RemotingException (no detail reported). Maybe I have the remoting configuration wrong for the SessionFactory. Or should I be looking at a different way? I'd be interested how other people have managed to do this.
Here's the relevant portions of config:
Web.Config:
<httpModules>
<add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
<add name="OpenSessionInView" type="Spring.Data.NHibernate.Support.OpenSessionInViewMo dule, Spring.Data.NHibernate12"/>
</httpModules>
<appSettings>
<add key="Spring.Data.NHibernate.Support.OpenSessionInViewMo dule.SessionFactoryObjectName" value="SessionFactory" />
</appSettings>
Client Services xml config file:
<objects xmlns="http://www.springframework.net" xmlns:r="http://www.springframework.net/remoting">
<r:caoFactory id="SessionFactory" remoteTargetName="SessionFactory" serviceUrl="tcp://mongol:8005" />
<r:caoFactory id="GenericService" remoteTargetName="GenericService" serviceUrl="tcp://mongol:8005" />
</objects>
Services xml config file on Business Logic Server:
<objects xmlns="http://www.springframework.net" xmlns:r="http://www.springframework.net/remoting">
<r:caoExporter targetName="SessionFactory" infinite="false">
<r:lifeTime initialLeaseTime="2m" renewOnCallTime="1m" />
</r:caoExporter>
<r:caoExporter targetName="GenericService" infinite="false">
<r:lifeTime initialLeaseTime="2m" renewOnCallTime="1m" />
</r:caoExporter>
<object id="SessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate12">
<property name="DbProvider" ref="DbProvider"/>
<property name="MappingAssemblies">
<list>
<value>Domain.Persistence.NHibernate</value>
</list>
</property>
<property name="HibernateProperties">
<dictionary>
<entry key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
<entry key="hibernate.dialect" value="NHibernate.Dialect.MySQL5Dialect"/>
<entry key="hibernate.connection.driver" value="NHibernate.Driver.MySqlDataDriver"/>
</dictionary>
</property>
</object>
</objects>
I'm running up against a brick wall trying to figure out how to do this, if it is possible, or if I am doing it the right way. I'd be glad of any help.
I have a web app using Spring.NET, and the NHibernate 1.2 beta module. I have it all working when all the tiers are hosted on the same server. Now, I want to split the tiers onto a web server and a second server for the business services and database. Basically, all the NHibernate work will be done on the new app server and the services exported via remoting. So i think the only module that needs to be configured on the web server is the OpenSessionInViewModule.
Now here is the catch: I can't get OpenSessionInViewModule to work over remoting and can't find any examples of someone who has done this. OSIV needs a SessionFactory instance, but that is configured with all the other Spring NHibernate components on the business logic server. Can an instance of the Spring LocalSessionFactoryObject be remoted to the web server (i.e. is declared as a MarshalByRefObject)? Currently it is giving me a RemotingException (no detail reported). Maybe I have the remoting configuration wrong for the SessionFactory. Or should I be looking at a different way? I'd be interested how other people have managed to do this.
Here's the relevant portions of config:
Web.Config:
<httpModules>
<add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
<add name="OpenSessionInView" type="Spring.Data.NHibernate.Support.OpenSessionInViewMo dule, Spring.Data.NHibernate12"/>
</httpModules>
<appSettings>
<add key="Spring.Data.NHibernate.Support.OpenSessionInViewMo dule.SessionFactoryObjectName" value="SessionFactory" />
</appSettings>
Client Services xml config file:
<objects xmlns="http://www.springframework.net" xmlns:r="http://www.springframework.net/remoting">
<r:caoFactory id="SessionFactory" remoteTargetName="SessionFactory" serviceUrl="tcp://mongol:8005" />
<r:caoFactory id="GenericService" remoteTargetName="GenericService" serviceUrl="tcp://mongol:8005" />
</objects>
Services xml config file on Business Logic Server:
<objects xmlns="http://www.springframework.net" xmlns:r="http://www.springframework.net/remoting">
<r:caoExporter targetName="SessionFactory" infinite="false">
<r:lifeTime initialLeaseTime="2m" renewOnCallTime="1m" />
</r:caoExporter>
<r:caoExporter targetName="GenericService" infinite="false">
<r:lifeTime initialLeaseTime="2m" renewOnCallTime="1m" />
</r:caoExporter>
<object id="SessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate12">
<property name="DbProvider" ref="DbProvider"/>
<property name="MappingAssemblies">
<list>
<value>Domain.Persistence.NHibernate</value>
</list>
</property>
<property name="HibernateProperties">
<dictionary>
<entry key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
<entry key="hibernate.dialect" value="NHibernate.Dialect.MySQL5Dialect"/>
<entry key="hibernate.connection.driver" value="NHibernate.Driver.MySqlDataDriver"/>
</dictionary>
</property>
</object>
</objects>