Glassfish requires a few modifications to the andromda files before it will deploy properly.
The ejb-jar.xml must be modified to change instances of
and to and
The format of the jdbc jndi parameter in the main pom.xml must be modified. Here is how:
Modifying the ejb-jar.xml:
Generate a new andromda project. In the mda/src/main/config folder create the following directory structure: custom/ejb3/templates/ejb3/config folder. Create a new ejb-jar.xml.vsl file in this folder. Add the following to that folder:
<?xml version="1.0" encoding="${xmlEncoding}"?>
<ejb-jar
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
version="3.0">
<description><![CDATA[No Description.]]></description>
<display-name>Generated by AndroMDA EJB3 Cartridge</display-name>
<enterprise-beans>
#foreach ($service in $services)
<session>
<description>
<![CDATA[
$service.getDocumentation("", 64, false)
]]>
</description>
<ejb-name>${service.serviceName}</ejb-name>
##
## Only define the remote business interface if the bean is NOT a Seam component
##
#**##if ($service.viewTypeLocal)
<business-local>${service.fullyQualifiedServiceLocalInterfaceName}</business-local>
#**##end
#**##if ($service.viewTypeRemote && !$service.seamComponent)
<business-remote>${service.fullyQualifiedServiceRemoteInterfaceName}</business-remote>
#**##end
<ejb-class>${service.fullyQualifiedServiceName}</ejb-class>
<session-type>${service.type}</session-type>
#**##if ($service.transactionManagementBean)
<transaction-type>Bean</transaction-type>
#**##else
<transaction-type>Container</transaction-type>
#**##end
#**##foreach($envEntry in $service.getEnvironmentEntries(true))
<env-entry>
<env-entry-name>${envEntry.name}</env-entry-name>
#if ($envEntry.type.primitive)
#set ($typeName = ${envEntry.type.wrapperName})
#else
#set ($typeName = ${envEntry.type.fullyQualifiedName})
#end
<env-entry-type>$converter.getJavaLangTypeName($typeName)</env-entry-type>
<env-entry-value>${envEntry.defaultValue.replace('"','')}</env-entry-value>
</env-entry>
#**##end
</session>
#end
#foreach ($manageable in $manageables)
<session>
<description>
<![CDATA[
$manageable.getDocumentation("", 64, false)
]]>
</description>
<ejb-name>${manageable.manageableServiceName}</ejb-name>
<business-remote>${manageable.fullyQualifiedManageableServiceName}</business-remote>
<ejb-class>${manageable.fullyQualifiedManageableServiceBaseName}</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
#end
#foreach ($entity in $entities)
<session>
<description>
<![CDATA[
$entity.getDocumentation("", 64, false)
]]>
</description>
<ejb-name>${entity.daoName}</ejb-name>
<business-local>${entity.fullyQualifiedDaoName}</business-local>
<ejb-class>${entity.fullyQualifiedDaoImplementationName}</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
#end
</enterprise-beans>
#if (${seamEnabled} == 'true')
<interceptors>
<interceptor>
<interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
</interceptor>
</interceptors>
#end
<assembly-descriptor>
#foreach ($interceptor in $interceptors)
##
## Default interceptors
##
#**##if ($interceptor.defaultInterceptor)
#* *##if (!$defaultInterceptorExists)
<interceptor-binding>
<ejb-name>*</ejb-name>
#* *##set ($defaultInterceptorExists = true)
#* *##end
<interceptor-class>${interceptor.fullyQualifiedName}</interceptor-class>
#**##end
#end
#if ($defaultInterceptorExists)
</interceptor-binding>
#end
#foreach ($service in $services)
##
## Service listener - lifecycle callbacks are defined as an interceptor
##
#**##set ($interceptors = $service.interceptorReferences)
#**##if ($collectionUtils.size($interceptors) >= 1 || $service.listenerEnabled)
<interceptor-binding>
<ejb-name>${service.serviceName}</ejb-name>
#* *##if ($service.listenerEnabled)
<interceptor-class>${service.fullyQualifiedServiceListenerName}</interceptor-class>
#* *##end
#* *##foreach ($interceptor in $interceptors)
<interceptor-class>${interceptor.fullyQualifiedName}</interceptor-class>
#* *##end
#* *##if ($service.excludeDefaultInterceptors)
<exclude-default-interceptors/>
#* *##end
</interceptor-binding>
#**##end
#end
##
## Define method level interceptors for session beans
##
#foreach ($service in $services)
#**##foreach ($operation in $service.businessOperations)
#* *##set ($interceptors = $operation.interceptorReferences)
#* *##if ($collectionUtils.size($interceptors) >= 1)
<interceptor-binding>
<ejb-name>${service.serviceName}</ejb-name>
#* *##foreach ($interceptor in $interceptors)
<interceptor-class>${interceptor.fullyQualifiedName}</interceptor-class>
#* *##end
<method>
<method-name>${operation.name}</method-name>
#* *##if (!$operation.arguments.empty)
<method-params>
#* *##foreach ($argument in $operation.arguments)
<method-param>${argument.type.fullyQualifiedName}</method-param>
#* *##end
</method-params>
#* *##end
</method>
#* *##if ($operation.excludeClassInterceptors)
<exclude-class-interceptors/>
#* *##end
#* *##if ($operation.excludeDefaultInterceptors)
<exclude-default-interceptors/>
#* *##end
</interceptor-binding>
#* *##end
#**##end
#end
#foreach ($mdb in $mdbs)
##
## Message-driven bean listener - lifecycle callbacks are defined as an interceptor
##
#**##set ($interceptors = $mdb.interceptorReferences)
#**##if ($collectionUtils.size($interceptors) >= 1 || $mdb.listenerEnabled)
<interceptor-binding>
<ejb-name>${mdb.messageDrivenName}</ejb-name>
#* *##if ($mdb.listenerEnabled)
<interceptor-class>${mdb.fullyQualifiedMessageDrivenListenerName}</interceptor-class>
#* *##end
#* *##foreach ($interceptor in $interceptors)
<interceptor-class>${interceptor.fullyQualifiedName}</interceptor-class>
#* *##end
#* *##if ($mdb.excludeDefaultInterceptors)
<exclude-default-interceptors/>
#* *##end
</interceptor-binding>
#**##end
#end
#if (${seamEnabled} == 'true')
<interceptor-binding>
<ejb-name>*</ejb-name>
<interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
</interceptor-binding>
#end
</assembly-descriptor>
</ejb-jar>
Modify the file: /mda/src/main/config/andromda.xml in the ejb3 section add the following:
<property name="mergeLocation">${conf.dir}/custom/ejb3</property>
That will format the ejb deployment descriptor properly.
2 - modify the main pom.xml
Find and modify the following two parameters as shown below:
<dataSource.name>${application.id}</dataSource.name>
<dataSource>jdbc/${dataSource.name}</dataSource>
Now you should be able to successfully deploy your project to glassfish.
Do not forget to set up the proper jndi jdbc resources within the glassfish admin console. That is outside the scope of this blog.