Announcement Announcement Module
Collapse
No announcement yet.
EJB3 naming && EAR && Maven 2 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • EJB3 naming && EAR && Maven 2

    I have a client aplication in swing that uses spring. It also uses EJB3 services deployed in an EAR in an application server.
    Full application is build using maven 2. My application is called demo. With maven, the EAR is named demo-<version>. For example for the first release of the demo application ear will be demo-1.0.0.ear.
    With ejb3, jndi name for services is <ear>/<serviceName>/remote. Consequently I have an application context define as follow:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:util="http://www.springframework.org/schema/util"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans 
    	                    http://www.springframework.org/schema/beans/spring-beans.xsd 
    	                    http://www.springframework.org/schema/util 
    	                    http://www.springframework.org/schema/util/spring-util.xsd">
    
    	<!-- ============================================================= -->
    	<!-- =====================Naming service definition========== -->
    	<!-- ============================================================= -->
    	<bean id="jndi" class="org.springframework.jndi.JndiTemplate">
    		<!-- JNDI definitions -->
    		<property name="environment">
    			<util:properties id="propsJNDI"
    				location="classpath:/jndi.properties" />
    		</property>
    	</bean>
    
    	<!-- ============================================================= -->
    	<!-- =====================Application service definition========== -->
    	<!-- ============================================================= -->
    	<!-- Interface Service will be used using the logical name Simple. 
    		Service is deployed on the network by a J2EE application server. 
    		Logical name used by the client application is not the jndi name-->
    	<!-- There no defintion for a concrete class, it is J2EE applicaion 
    		server reponsability to deploy services. -->
    	<bean id="ShoppingCart"
    		class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiTemplate" ref="jndi" />
    		<property name="jndiName" value="demo-ear-1.0.0/ShoppingCartBean/remote" />
    	</bean>
    </beans>
    My problem is that the jndiName of the service contains the ear version. When I will upgrade my application I will have to update each jndiName. For example for ear release 2.0.0, jndi name for my service will be demo-ear-2.0.0/ShoppingCartBean/remote.

    Consequently I'd like to externalize a part of the jndiName in order to write something like:
    Code:
    <bean id="ShoppingCart"
    		class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiTemplate" ref="jndi" />
    		<property name="jndiName" value="${demo-ear}/ShoppingCartBean/remote" />
    	</bean>
    In another property file or hardcoded in the Main of the appli I'd like to be able to set the value for the demo-ear property.

    I did not succeed to find a solution. Any suggestion are welcome !

  • #2
    Just a little add.

    I have an ApplicationContext; I try to use PropertyPlaceholderConfigurer but with this solution name of the ear is still in XML. I'd like to externalize it (for example maven could generate a property file with a key a ear complete name). This property file will be read at application startup.
    Code:
    <bean id="ShoppingCart"
    		class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiTemplate" ref="jndi" />
    		<property name="jndiName" value="${demo-ear}/ShoppingCartBean/remote" />
    	</bean>
    	
    	
    	<bean id="oops" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
    		<property name="properties">
    			<props>
                                                       <!-- PROBLEM : NAME OF EAR IS STILL IN XML-->
    				<prop key="demo-ear">demo-ear-1.0-SNAPSHOT</prop>
    			</props>
    		</property>
    	</bean>

    Comment

    Working...
    X