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

36 questions
6
votes
2 answers

Modify configuration properties of ejb-jar.xml during deployment in GlassFish 4.0

I have an ejb-jar.xml that contains configuration information for one of my MDB. In there is a configuration of: addressList
Softey
  • 1,249
  • 3
  • 15
  • 40
6
votes
1 answer

Finding out what EJB view was used

Assume I have an EJB defining two views: Local business, Remote business. Both interfaces share the same method signatures, so it's like: public interface MyBusinessCommon { void myMethod(Object o); } @Local public interface MyBusinessLocal…
Piotr Nowicki
  • 16,436
  • 8
  • 54
  • 79
3
votes
2 answers

CDI observer not yet initialized when the event is fired

I have two SLSBs: BeanF, BeanO in two ejb-jars: ModF, ModO. BeanF fires an event and BeanO observes it. The first fire(-) operation ends with the exception (Wildfly 8.2): ERROR [org.jboss.as.ejb3.invocation] JBAS014134: EJB Invocation…
Piotr Nowicki
  • 16,436
  • 8
  • 54
  • 79
2
votes
1 answer

Common configuration in ejb jar xml

There is an ejb-jar xml file in our project which defines essentially the same ejb configuration over and over again for a number of different brands. They all share the same underlying code, the same external references etc., so could in fact all…
Ellis
  • 669
  • 1
  • 11
  • 21
2
votes
1 answer

Reg ex for activation-config-property-value

Can I give a regex pattern for activation-config-property-value in ejb-jar.xml? instead of something like…
Mahi G
  • 361
  • 1
  • 5
  • 13
2
votes
3 answers

Is it possible to place custom values (properties) in ejb-jar.xml?

1) We are using OpenEJB (both embedded and standalone) with a few deployed EJBs. We would like to specify some simple static business rules and values (example: icon_size=200). Normally, we would put them in a regular properties file (example:…
Luis Soeiro
  • 4,162
  • 5
  • 33
  • 45
2
votes
1 answer

Message Driven Bean and deployment descriptor

I have simple Message Driven Bean @Named @MessageDriven(mappedName = "jms/myQueue") public class TestMDB implements MessageListener { @Override public void onMessage(Message msg) { //... } } How can I achieve the same using only…
Joel
  • 443
  • 1
  • 7
  • 19
2
votes
0 answers

EJB - Dynamic data source binding

We are trying to implement Model-2 SaaS to our application. (Please refer IBM Link for what is Model-2.) Model-2 is having separate database schema per customer with one EAR (Application). Schema and data source will be dynamic based on login…
user38994
  • 21
  • 3
2
votes
0 answers

Error while publishing to Weblogic Server 11gR1

I am receiving the following error. What does this mean and how to fix it? Unable to deploy EJB : xxxEJB from xx.JAR Error deployin gthe EJB 'xxxEJB, the JNDI name 'xxxEJB' is already in use. You must set a different JNDI name in…
Mike
  • 645
  • 2
  • 10
  • 20
1
vote
2 answers

ejb reference in deployment descriptor (without annotations )

I try to inject dependency in EJB 3.0 using only deployment descriptor. When I deploy my app to Glassfish (v3.1) I get this exception: java.lang.RuntimeException: Warning : Unable to determine local business vs. remote business designation for EJB…
1
vote
1 answer

Is it possible to use ejb annotation and CDI in a legacy project where all the existing EJB are configured in ejb-jar.xml

There is a legacy code base with the oldest EJB, where all the existing EJBS are configured in ejb-jar.xml
Rui
  • 2,967
  • 4
  • 27
  • 54
1
vote
1 answer

What is the ejb-jar.xml equivalent of @Postconstruct?

I have an MDB with a method annotated as @Postconstruct. It was being executed OK. Today I needed to create an ejb-jar.xml file to configure an at build time (as I can't figure out how to configure an…
Synesso
  • 34,066
  • 32
  • 124
  • 194
1
vote
1 answer

CHKJ2800E: interface com.sbc.ept.imagine.service.adsl.ejb.AdslLocal, or one of its supertypes, cannot be reflected. Check the classpath

Currently I'm working for JAVA application. I just checked out project from SVN in RAD_9.1.1. When I added relevant jars to my project, I got stuck up with below class path error. Do anyone has a solution for this problem? Nearly 300+ errors has…
Vicky
  • 11
  • 1
  • 4
1
vote
1 answer

resource-ref at application scope in EJB 2.1 Project

Is it possible to define resource references that are applicable to all EJBs in an application? Currently I have an ejb-jar.xml that looks something like this:
Mike Deck
  • 17,069
  • 15
  • 62
  • 89
1
vote
1 answer

Missing values in ejb-jar.xml

When trying to deploy a mavenized entreprise application (including both war and jar projects) in glassfish 4.0, (using netbeans 7.3.1),i got the similar problem as in this question saying that the jar is invalid as it contains zero ejb (which is…
Bardelman
  • 1,934
  • 6
  • 31
  • 60
1
2 3