<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=davsclaus" rel="nofollow">Claus Ibsen</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-536?redirect=false" rel="nofollow">SPR-536</a></strong> and commented</p>
<p dir="auto">In relation to this thread in the forum<br>
<a href="http://forum.springframework.org/viewtopic.php?t=1213&amp;start=30" rel="nofollow">http://forum.springframework.org/viewtopic.php?t=1213&amp;start=30</a></p>
<p dir="auto">I need a Hibernate SessionInViewInterceptor that can be used by Spring AOP ProxyFactoryBean.</p>
<p dir="auto">The existing ones in org.springframework.orm.hibernate.support is tied to the web tier = (servlet filter, or spring web framework).</p>
<p dir="auto">I need a non web realted one that I can used in my ejb tier.<br>
The reason is in short to support multiple schemas for Hibernate.<br>
Read the forum to understand the problem more.</p>
<p dir="auto">My workaround was to copy the code from org.springframework.orm.hibernate.support.OpenSessionInViewFilter and remove the web related.</p>
<p dir="auto">I have attached the source file I am using.</p>
<p dir="auto">And this is the relevant part from my spring .xml file</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;!-- DAO --&gt;
&lt;bean id=&quot;SaldoOversigtDAO2&quot; class=&quot;org.springframework.aop.framework.ProxyFactoryBean&quot;&gt;
	&lt;property name=&quot;proxyInterfaces&quot;&gt;&lt;value&gt;com.bmd.selfserviceejb.dao.SaldoOversigtDAO2&lt;/value&gt;&lt;/property&gt;
	&lt;property name=&quot;target&quot;&gt;&lt;ref local=&quot;SaldoOversigtDAO2Target&quot;/&gt;&lt;/property&gt;
	&lt;property name=&quot;interceptorNames&quot;&gt;
    	&lt;list&gt;
        	&lt;value&gt;hibernateSessionInViewInterceptor&lt;/value&gt;
        &lt;/list&gt;
	&lt;/property&gt;	
&lt;/bean&gt;
&lt;bean id=&quot;SaldoOversigtDAO2Target&quot; class=&quot;com.bmd.selfserviceejb.dao.SaldoOversigtDAO2Impl&quot;&gt;
	&lt;property name=&quot;sessionFactory&quot;&gt;&lt;ref local=&quot;sessionFactory&quot;/&gt;&lt;/property&gt;
&lt;/bean&gt;

&lt;bean id=&quot;hibernateSessionInViewInterceptor&quot; class=&quot;com.bmd.selfserviceejb.spring.HibernateSessionInViewInterceptor&quot;&gt;
	&lt;property name=&quot;sessionFactory&quot;&gt;&lt;ref local=&quot;sessionFactory&quot;/&gt;&lt;/property&gt;
&lt;/bean&gt;"><pre class="notranslate"><code class="notranslate">&lt;!-- DAO --&gt;
&lt;bean id="SaldoOversigtDAO2" class="org.springframework.aop.framework.ProxyFactoryBean"&gt;
	&lt;property name="proxyInterfaces"&gt;&lt;value&gt;com.bmd.selfserviceejb.dao.SaldoOversigtDAO2&lt;/value&gt;&lt;/property&gt;
	&lt;property name="target"&gt;&lt;ref local="SaldoOversigtDAO2Target"/&gt;&lt;/property&gt;
	&lt;property name="interceptorNames"&gt;
    	&lt;list&gt;
        	&lt;value&gt;hibernateSessionInViewInterceptor&lt;/value&gt;
        &lt;/list&gt;
	&lt;/property&gt;	
&lt;/bean&gt;
&lt;bean id="SaldoOversigtDAO2Target" class="com.bmd.selfserviceejb.dao.SaldoOversigtDAO2Impl"&gt;
	&lt;property name="sessionFactory"&gt;&lt;ref local="sessionFactory"/&gt;&lt;/property&gt;
&lt;/bean&gt;

&lt;bean id="hibernateSessionInViewInterceptor" class="com.bmd.selfserviceejb.spring.HibernateSessionInViewInterceptor"&gt;
	&lt;property name="sessionFactory"&gt;&lt;ref local="sessionFactory"/&gt;&lt;/property&gt;
&lt;/bean&gt;
</code></pre></div>
<hr>
<p dir="auto"><strong>Affects:</strong> 1.1.2</p>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/10360/HibernateSessionInViewInterceptor.java" rel="nofollow">HibernateSessionInViewInterceptor.java</a> (<em>4.29 kB</em>)</li>
</ul>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=akmal" rel="nofollow">Akmal Sarhan</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-1893?redirect=false" rel="nofollow">SPR-1893</a></strong> and commented</p>
<p dir="auto">the following snippet does not work<br>
&lt;bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;<br>
&lt;property name="searchSystemEnvironment" &gt;&lt;value&gt;true&lt;/value&gt;&lt;/property&gt;<br>
&lt;property name="systemPropertiesModeName" &gt;&lt;value&gt;SYSTEM_PROPERTIES_MODE_FALLBACK&lt;/value&gt;&lt;/property&gt;</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="	&lt;property name=&quot;locations&quot;&gt;
		&lt;list&gt;
			&lt;value&gt;classpath:project-${SERVER_MODE}.properties&lt;/value&gt;
			&lt;value&gt;classpath:messages.properties&lt;/value&gt;
		&lt;/list&gt;
	&lt;/property&gt;
&lt;/bean&gt;	"><pre class="notranslate"><code class="notranslate">	&lt;property name="locations"&gt;
		&lt;list&gt;
			&lt;value&gt;classpath:project-${SERVER_MODE}.properties&lt;/value&gt;
			&lt;value&gt;classpath:messages.properties&lt;/value&gt;
		&lt;/list&gt;
	&lt;/property&gt;
&lt;/bean&gt;	
</code></pre></div>
<p dir="auto">if SERVER_MODE is a system env. the solution is to change org.springframework.util.SystemPropertyUtils</p>
<p dir="auto">to try to resolve the placeholder via:<br>
...<br>
String propVal = System.getProperty(placeholder);<br>
if (propVal == null)<br>
propVal = System.getenv(placeholder);<br>
...</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.0 M3</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398064661" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/6542" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/6542/hovercard" href="https://github.com/spring-projects/spring-framework/issues/6542">#6542</a> Resource location placeholders not resolved against system environment variables (<em><strong>"duplicates"</strong></em>)</li>
</ul>