Questions tagged [ejb-jar.xml]

how ejb-jar.xml look like is described here. According to version of the EJB need to have use dtd path. EJB 1 http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd EJB 2.0 "http://java.sun.com/dtd/ejb-jar_2_0.dtd" EJB 3.0 need xsd as updated Configuraions http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"

Access the full DTD at http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd which is very nicely written. All of the tags (elements) are fully described in alphabetical order. Example usage is provided. A minimal ejb-jar.xml file looks like this:

  <!-- A minimal session EJB deployment -->
  <session>
     <ejb-name>PostingEJB</ejb-name>
     <home>ejbs.PostingHome</home>
     <remote>ejbs.Posting</remote>
     <ejb-class>ejbs.PostingBean</ejb-class>
     <!-- or Stateless -->
     <session-type>Stateful</session-type>
     <transaction-type>Container</transaction-type>
  </session>

  <!-- A minimal CMP entity EJB deployment -->
  <entity>
     <ejb-name>Bid</ejb-name>
     <home>ejbe.BidHome</home>
     <remote>ejbe.Bid</remote>
     <ejb-class>ejbe.BidBean</ejb-class>
     <persistence-type>Container</persistence-type>
     <prim-key-class>ejbe.BidPK</prim-key-class>
     <reentrant>False</reentrant>
     <cmp-field><field-name>bid</field-name></cmp-field>
     <cmp-field><field-name>bidder</field-name></cmp-field>
     <cmp-field><field-name>bidDate</field-name></cmp-field>
     <cmp-field><field-name>id</field-name></cmp-field>
  </entity>

  <!-- A minimal BMP entity EJB deployment -->
  <entity>
     <ejb-name>BidBMP</ejb-name>
     <home>com.bea.EJBE.solutions.BidBMPHome</home>
     <remote>com.bea.EJBE.solutions.BidBMP</remote>
     <ejb-class>com.bea.EJBE.solutions.BidBMPBean</ejb-class>
     <persistence-type>Bean</persistence-type>
     <prim-key-class>pkg.BidBMPPK</prim-key-class>
     <reentrant>False</reentrant>
  </entity>

Sample for EJB 2

<?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
 <ejb-jar>
   <display-name>EJBModule_Ejemplo</display-name>
   <enterprise-beans>
     <entity>
       <ejb-name>Track</ejb-name>
       <local-home>is346.TrackHome</local-home>
       <local>is346.Track</local>
       <ejb-class>is346.TrackBean</ejb-class>
       <persistence-type>Container</persistence-type>
       <prim-key-class>java.lang.Integer</prim-key-class>
       <reentrant>False</reentrant>
       <cmp-version>2.x</cmp-version>
       <abstract-schema-name>Track</abstract-schema-name>
       <cmp-field>
         <field-name>id</field-name>
       </cmp-field>
       <cmp-field>
         <field-name>title</field-name>
       </cmp-field>
       <cmp-field>
         <field-name>duration</field-name>
       </cmp-field>
       <primkey-field>id</primkey-field>
     </entity>
     <entity>
       <ejb-name>Artist</ejb-name>
       <local-home>is346.ArtistHome</local-home>
       <local>is346.Artist</local>
       <ejb-class>is346.ArtistBean</ejb-class>
       <persistence-type>Container</persistence-type>
       <prim-key-class>java.lang.Integer</prim-key-class>
       <reentrant>False</reentrant>
       <cmp-version>2.x</cmp-version>
       <abstract-schema-name>Artist</abstract-schema-name>
       <cmp-field>
         <field-name>id</field-name>
       </cmp-field>
       <cmp-field>
         <field-name>name</field-name>
       </cmp-field>
       <primkey-field>id</primkey-field>
     </entity>
     <session>
       <ejb-name>TrackSessionFacade</ejb-name>
       <home>is346.TrackSessionFacadeHome</home>
       <remote>is346.TrackSessionFacade</remote>
       <ejb-class>is346.TrackSessionFacadeBean</ejb-class>
       <session-type>Stateless</session-type>
       <transaction-type>Container</transaction-type>
       <ejb-local-ref>
         <ejb-ref-name>ejb/track</ejb-ref-name>
         <ejb-ref-type>Entity</ejb-ref-type>
         <local-home>is346.TrackHome</local-home>
         <local>is346.Track</local>
         <ejb-link>Track</ejb-link>
       </ejb-local-ref>
     </session>
     <session>
       <ejb-name>ArtistSessionFacade</ejb-name>
       <home>is346.ArtistSessionFacadeHome</home>
       <remote>is346.ArtistSessionFacade</remote>
       <ejb-class>is346.ArtistSessionFacadeBean</ejb-class>
       <session-type>Stateless</session-type>
       <transaction-type>Container</transaction-type>
       <ejb-local-ref>
         <ejb-ref-name>ejb/artist</ejb-ref-name>
         <ejb-ref-type>Entity</ejb-ref-type>
         <local-home>is346.ArtistHome</local-home>
         <local>is346.Artist</local>
         <ejb-link>Artist</ejb-link>
       </ejb-local-ref>
     </session>
   </enterprise-beans>
   <relationships>
     <ejb-relation>
       <ejb-relation-name>track-artist</ejb-relation-name>
       <ejb-relationship-role>
         <description>track</description>
         <ejb-relationship-role-name>TrackRelationshipRole</ejb-relationship-role-name>
         <multiplicity>Many</multiplicity>
         <relationship-role-source>
           <description>track</description>
           <ejb-name>Track</ejb-name>
         </relationship-role-source>
         <cmr-field>
           <description>artist</description>
           <cmr-field-name>artist</cmr-field-name>
           <cmr-field-type>java.util.Collection</cmr-field-type>
         </cmr-field>
       </ejb-relationship-role>
       <ejb-relationship-role>
         <description>artist</description>
         <ejb-relationship-role-name>ArtistRelationshipRole</ejb-relationship-role-name>
         <multiplicity>Many</multiplicity>
         <relationship-role-source>
           <description>artist</description>
           <ejb-name>Artist</ejb-name>
         </relationship-role-source>
       </ejb-relationship-role>
     </ejb-relation>
   </relationships>
   <assembly-descriptor>
     <container-transaction>
       <method>
         <ejb-name>Track</ejb-name>
         <method-name>*</method-name>
       </method>
       <trans-attribute>Required</trans-attribute>
     </container-transaction>
     <container-transaction>
       <method>
         <ejb-name>Artist</ejb-name>
         <method-name>*</method-name>
       </method>
       <trans-attribute>Required</trans-attribute>
     </container-transaction>
     <container-transaction>
       <method>
         <ejb-name>TrackSessionFacade</ejb-name>
         <method-name>*</method-name>
       </method>
       <trans-attribute>Required</trans-attribute>
     </container-transaction>
     <container-transaction>
       <method>
         <ejb-name>ArtistSessionFacade</ejb-name>
         <method-name>*</method-name>
       </method>
       <trans-attribute>Required</trans-attribute>
     </container-transaction>
   </assembly-descriptor>
 </ejb-jar>

Sample for EJB 3.0

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
  <enterprise-beans>
    <session>
      <ejb-name>TestBean</ejb-name>
      <ejb-ref>
        <ejb-ref-name>ejb/fooremote</ejb-ref-name>
        <ejb-ref-type>Session</ejb-ref-type>
        <remote>test.FooRemoteIF</remote>
      </ejb-ref>
      <env-entry>
        <description>admin email</description>
        <env-entry-name>adminEmail</env-entry-name>
        <env-entry-value>admin@example.x</env-entry-value>
      </env-entry>
    </session>
  </enterprise-beans>

  <interceptors>
    <interceptor>
      <interceptor-class>test.Interceptor1</interceptor-class>
    </interceptor>
  </interceptors>

  <assembly-descriptor>
    <interceptor-binding>
      <ejb-name>*</ejb-name>
      <interceptor-class>test.Interceptor1</interceptor-class>
    </interceptor-binding>
  </assembly-descriptor>
</ejb-jar>

Also Some Client implementation are providing own configuration for the same. e.g. Weblogic need to have weblogic-ejb-jar.xml Deployment Descriptor Reference. For more help for web logic can see : http://docs.oracle.com/cd/E13222_01/wls/docs81/ejb/DDreference-ejb-jar.html

37 questions
1
vote
2 answers

env-entry in ejb-jar.xml not being injected with @Resource when deployed inside WAR file

I have a maven web application that has a dependency on an EJB project. ${project.groupId} soar-ejb 1.0 jar
flchannel
  • 33
  • 1
  • 10
1
vote
1 answer

using and in same ejb-jar.xml

I'm trying to add a message driven bean to my existing Java EE application. I'm in the process of modifying my deployment descriptor ejb-jar.xml. My ejb-jar.xml looks like this.
1
vote
1 answer

TomEE Plus seems not find the "ejb-jar.xml" in application war

My main aim is to migrate an EJB 2.x application written for WebSphere to a web application deployable for Tomcat server. But I want to this as nearly one-to-one migration. So I set up a TomEE (apache-tomee-plus-1.0.0) and keep the configuration of…
Reeny
  • 13
  • 1
  • 3
0
votes
2 answers

@Singleton bean to read values from ejb-jar.xml

I have a ConfigParameter SLSB that reads configuration values from the ejb-jar.xml file. This class has only private fields and for each field a corresponding getter method. In my application I have a lot of other EJBs that use an instance of…
hage
  • 5,966
  • 3
  • 32
  • 42
0
votes
1 answer

After wildfly18->26 java8->17 ear->war upgrade wildfly doesn't use ejb-jar.xml's MDB settings

My wildfly26.1.3 doesn't start. Failed with this exception: Exception: 15:26:45,329 ERROR [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0215: Failed to resume activity…
László Tóth
  • 483
  • 5
  • 15
0
votes
1 answer

Inject a String into a Message Driven Bean

I want to configure the behaviour of one of my mdbs with string. i created a setMessageType method and want to inject the identifier string into the mdb by configuration in the ejb-jar (deployment descriptor). I know how do declare a bean in the…
0
votes
0 answers

Apply ejb-jar descriptor to abstract class

I've got weblogic server with a service I need to behave in 2 different ways depending on instalation. My plan was to deploy normally in the first case setting a String variable as @Resource with an ejb-jar descriptor in the class that needs two…
0
votes
1 answer

ejb transaction rollback of application exceptions does not work

my team is having problems due to transactions that do not rollback after application exceptions. I created a configuration so that all exceptions that were subclasses of Exception would generate rollback, but the configuration did not work. Does…
0
votes
1 answer

Configuring EJB security on Weblogic

I'm trying to understand how the EJB security works on a WebLogic server. I have an EJB with following configuration in ejb-jar.xml BeanA ....
J. J
  • 23
  • 4
0
votes
1 answer

Websphere 7 and EJB 2.1 - JNDI name not specified

Environment - WAS 7.0 and EJB 2.1 I have a EAR with EJB jar file. It has some remote EJB's (EJB 2.1) that I want to convert to local EJB. Hence i had to modify ejb-jar.xml as per my understanding. My modified ejb-jar xml file is as follows:
ashishhsihsa
  • 103
  • 1
  • 1
  • 6
0
votes
0 answers

JavaEE: multi-module Maven project with Glassfish/Payara: ejb-jar.xml security roles not seen by EJB module

I am migrating a large JavaEE web app to a multi-module Maven form. The roles declared for a specific EJB in the ejb-jar.xml are not being seen by that EJB when I run the multi-module web app. The ejb-jar.xml is identical to the one I had in the…
0
votes
1 answer

Websphere 85 ejb 3 deploy issue

I am trying to deploy a bean that is ejb 3 on websphere 8. Bean implementation is in src/main/java and ejb-jar.xml is in src/main/resources/META-INF. This is packaged in a jar and the jar is included in ear that also has other ejb jar with ejb 2. So…
Vaidehi Patel
  • 75
  • 1
  • 1
  • 8
0
votes
1 answer

Message driven bean error - java.lang.Object is not an interface

I was getting an odd exception when I was trying to create yet another Message Driven Bean. I have used standard configuration as we already had on the project, but I could not start the EAR. The exception I was getting - java.lang.Object is not an…
Javo
  • 435
  • 1
  • 5
  • 16
0
votes
1 answer

How to specify an MDB destination name in ejb-jar.xml for JBoss

I am trying to configure an EJB 2.1 MDB in ejb-jar.xml. My problem is there is no clear way to specify the destination (Queue name) the MDB suppose to listen to. I have exhausted the web without finding any useful information. So in my ejb-jar.xml I…
DhafirNz
  • 627
  • 3
  • 9
  • 20
0
votes
1 answer