Local references and EJBs in separate jars

Hi
I have trouble in getting local references when the EJBs are built in separate jar files. I am using the <ejb-link> in the <local-ejb-ref>. But I could not get reference to the EJB's local reference.
Please let me know if there is any documentation that tells about getting local references and having the EJBs in separate jar files.
Thanks

Greetings,
Hi
I have trouble in getting local references when the
EJBs are built in separate jar files. I am using theThere are a number of reasons why this may be happening and without more specific information it is difficult to say which you are encountering... In any case, the fact that your beans are in separate jars is not, by itself, the issue. It is worth noting, however, that Local references may only be used when both components (referencer and referencee) are co-located within the same VM instance and perhaps this little fact may shed some light on your problem??
<ejb-link> in the <local-ejb-ref>. But I could not get<ejb-link> should point to the actual JNDI binding name, sans root nomenclature (java:comp/env/), but with full sub-context (ejb/myapp/.../MyLocalBean), of the referenced bean.
reference to the EJB's local reference.Perhaps it goes without saying (but just to be sure :)... of course, your referenced bean must actually have Local interfaces associated with it.
Please let me know if there is any documentation
that tells about getting local references and having
the EJBs in separate jar files.Both the J2EE tutorial and the EJB 2.0 spec. have the relevant information. :) However, I've already listed the requirements above: supplied local interfaces, co-located components, and correct link reference.
I hope this helps.
ThanksRegards,
Tony "Vee Schade" Cook

Similar Messages

  • Problem deploying related EJBs in separate JARs

    I have 2 entity EJBs, User and Address, in separate JAR files. The User bean
    has business methods to get and set its related address as follows:
    void setAddressPK(AddressPK newAddress) throws java.rmi.RemoteException;
    AddressPK getAddressPK() java.rmi.RemoteException;
    When I try and load User.jar in the EJB Deployment tool it complains that it
    can't find the AddressPK class. However, I can get round this by explicitly
    adding Address.jar to the classpath.
    When I actually deploy and use the User bean I do NOT need Address.jar on
    the classpath, although I do get warnings during deployment.
    So my question is how do I package and deploy related EJBs. I don't want to
    have to have all my EJBs in the same JAR, nor do I want to have the same
    classes in more than one JAR. Is what I'm doing correct - am I supposed to
    have Address.jar on the classpath? And what about an utility classes that
    are shared between EJBs - where do I put those?
    Thanks in advance,
    Steve.

    I resolved the problem be making sure that my deployment
    jars don't appear in my servlet classpath....
    Jason
    Jeff Wang <[email protected]> wrote in message news:[email protected]...
    In general, if two beans are related (i.e. you can not compile one
    without the other being on the classpath) and they are both deployed
    they should be in the same jar file. If you do not deploy one of them,
    then the undeployed bean can be in the weblogic.class.path with no
    problem.
    I suspect that you are getting a ClassCastException because you have the
    deployment jars in your weblogic.class.path (or java classpath.) Remove
    them, and see if the error is resolved.
    Jeff Wang
    WLCS 2.0 Software Engineer
    Jason Rosenberg wrote:
    Does the same apply for beans of different types? In other words, do
    I need to have an entity bean and a session bean which wraps the entity
    bean in the same jar file?
    I am having a problem accessing a session bean from a JSP servlet. I get
    the dreaded ClassCastException. I don't get this problem, however, if
    I access the session bean directly from a stand-alone java client. It's
    only when I access the session bean via JSP....
    Any ideas?
    Jason
    Jeff Wang <[email protected]> wrote in message news:[email protected]...
    What you should have in the .jar files are:
    the home (say it is called <bean>home.class)
    the remote (say it is called <bean>.class)
    the impl (say it is called <bean>impl.class)
    These are the only ones that should be in the .jar file. (not even the
    PK should be there, for an entity bean.) All the support classes should
    be in weblogic.class.path If you have cross jar dependencies,
    unfortunately, you will have to specify the jar in the
    weblogic.class.path... However, this is not a good idea, as you will
    have 2 class files in memory. At the very least, you will not be able
    to do hot deploy. Depending on your code, you'll have a "class cast
    exception <bean> can not be casted to an object of <bean>" (Something
    like that, I don't have the exact error in front of me.) In your
    example it is probably better to put User and Address in the same jar.
    Jeff Wang
    WLCS 2.0 Software Engineer
    Steve Ward wrote:
    I have 2 entity EJBs, User and Address, in separate JAR files. The User bean
    has business methods to get and set its related address as follows:
    void setAddressPK(AddressPK newAddress) throws java.rmi.RemoteException;
    AddressPK getAddressPK() java.rmi.RemoteException;
    When I try and load User.jar in the EJB Deployment tool it complains that it
    can't find the AddressPK class. However, I can get round this by explicitly
    adding Address.jar to the classpath.
    When I actually deploy and use the User bean I do NOT need Address.jar on
    the classpath, although I do get warnings during deployment.
    So my question is how do I package and deploy related EJBs. I don't want to
    have to have all my EJBs in the same JAR, nor do I want to have the same
    classes in more than one JAR. Is what I'm doing correct - am I supposed to
    have Address.jar on the classpath? And what about an utility classes that
    are shared between EJBs - where do I put those?
    Thanks in advance,
    Steve.

  • What is the difference between ejb reference and ejb handle?

    Hi:
    I am newbie for J2EE.
    I want to know what is the difference between ejb reference and ejb handle
    from the client view and from the container view?
    Very Thanks!
    Stive

    Hi John,,
    1) Ejb Object Handle are nothing but a long lived proxy for the
    ejb object, using this handle user can disconnect from the Ejb Server/Container
    at any time
    and after some time using the same handle he can able to resume the conversational
    state
    with the server / container where he was been disconnected From.
    And there are currently two Handles , HomeHandle and Handle for EjbHomeObject
    and EjbObject
    Respectively. Both these handles have Persistent reference to the EJB Object
    2) Ejb Reference is used to lookup a bean from other Enterprise Bean
    Ejb reference is a nickname for the JNDI Location that you want to lookup a bean.
    your code will looks up a Home object via using this nickname
    and the deployer will bind the
    nickname to the JNDI location of its choice
    EJb Reference are declared in the deployment descriptor
    Regards
    Karthikeyan Gangadharan
    SIP Technologies, Chennai
    E-mail-ID : [email protected]
    "John Stive" <[email protected]> wrote:
    >
    Hi:
    I am newbie for J2EE.
    I want to know what is the difference between ejb reference and ejb
    handle
    from the client view and from the container view?
    Very Thanks!
    Stive

  • Two EJB's, separate JARS?

    Hi,
    I have a MDB, consuming messages from a Q, a Java Bean and a Stateless Session Bean.
    The MDB has a message sent to it, consumes the message, calls the Bean and the bean then passes the Remote interface of the EJB back to the MDB.
    I have packaged and deployed this like so:
    first jar: MDB and Java Bean;
    second jar: Session EJB.
    I call the session ejb from the Bean like so:
    Context ctx = getInitialContext();
    Object objRef = ctx.lookup("java:comp/env/IntellectSessionRemote");I get this error, caught from the NamingException thrown in the above code:
    Javax.Naming.NameNotFound Exception: Unable to resolve comp/env/IntellectSessionRemote/ Resolved: comp/env Unresolved: IntellectSessionRemote ; remaining name ' ' in ejb
    Any ideas/help??/
    I am deploying on Weblogic 6.1, in development mode.
    Cheers
    T

    Hi again,
    I am confused still about a couple of things:
    1) Should I be deploying the EJB's in seperate JAR's?
    2) It is my Bean class, not MDB, that is doing the
    Object objRef = ctx.lookup("java:comp/env/ejb/IntellectSessionRemote");lookup, therefore why do i put the reference to the jndi name of the Session EJB in the deplotment descriptor of the MDB?
    I tried putting the ejb-ref tag in the ejb-jar.xml file and now get the following error when the server starts:
    In ejb-jar.xml the EJB 'consumer' contains an invalid eb-link in ejb-ref 'ejb/IntellectSession'. No ejb with ejb-name 'IntellectSession' could be found.Any ideas on this one????
    Cheers
    T

  • Servlet accessing an ejb in separate jar

    Don't know if this is possible??
    I have deployed interest.jar ejb...client is working..
    I'm trying to access ejb/interest through the interestservlet.war.
    The problem I'm having is setting up the web.xml & jboss-web.xml
    to reference the deployeed interest ejb on the jboss server. The
    servlet works fine if it's in the same interest.ear package.
    The reason for this is to deployee ejb.jar once and change the servlet look for each different install.

    actually, it's pretty easy. It took me a while because I couldn't find documentation on web.xml configuration. Everything is moving along fine.

  • Weblogic 12c JSF2 and EJB3.1 using CDI injection , in separate jar files

    I am trying to inject a stateless EJB and  managed Bean of JSF2 into a CDI managed controller.
    That means using @inject replace @EJB of EJB and @Named of CDI replace @ManageBean in JSF2 ,  EJB3.1 and JSF2 in separate jar files.
    At result,My  test  gets the following Exception in  weblogic 12c。
    If EJB in separate files and Managed Bean of JSF in WEB-INF/classes not separte file, then no problem.
    weblogic.management.DeploymentException:
         at weblogic.application.internal.BaseDeployment.throwAppException(BaseDeployment.java:123)
         at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:239)
         at weblogic.application.internal.SingleModuleDeployment.prepare(SingleModuleDeployment.java:48)
         at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158)
         at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
         at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207)
         at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:96)
         at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:229)
         at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747)
         at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216)
         at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250)
         at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
         at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
    Caused By: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [ISaleInfoService] with qualifiers [@Default] at injection point [[field] @Inject private com.hylandtec.hystone.showcase.web.SaleInfoBean.saleInfoService]
         at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:258)
         at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:105)
         at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:125)
         at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:324)
         at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:309)
         at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:361)
         at com.oracle.injection.provider.weld.WeldInjectionContainer.start(WeldInjectionContainer.java:105)
         at com.oracle.injection.integration.CDIAppDeploymentExtension.prepare(CDIAppDeploymentExtension.java:60)
         at weblogic.application.internal.flow.AppDeploymentExtensionFlow.prepare(AppDeploymentExtensionFlow.java:23)
         at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:706)
         at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:35)
         at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:237)
         at weblogic.application.internal.SingleModuleDeployment.prepare(SingleModuleDeployment.java:48)
         at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158)
         at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
         at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207)
         at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:96)
         at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:229)
         at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747)
         at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216)
         at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250)
         at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
         at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
    Edited by: user8823518 on 2012-3-12 上午12:49

    This is a Weblogic 12.1.1 bug (a patch is available), explained here:
    http://docs.oracle.com/cd/E24329_01/doc.1211/e26593/issues.htm#BCFGBBBE
    extract:
    If a WAR file has two embedded bean deployment archive JARs (that is, JARs that contain META-INF/beans.xml), an UnsatisfiedDependencyException occurs if a class in one JAR contains an @Inject that is of a type that is defined in the other JAR.
    Workaround
    +Download and install patch 13563205. Enter this value in the Patch Number Search field on the Patches & Updates tab of My Oracle Support.+

  • Need to delete local references in unknown calling context

    Hi,
    I was looking for the need to delete local references and came across this documentation,
    What does unknown caller context mean? and how does it cause local references to remain allocated in reference table although the native function returns?
    http://java.sun.com/docs/books/jni/html/refs.html
    5.2.1 Freeing Local References
    You want to write a utility function that is called from unknown contexts. The MyNewString example shown in Section 4.3 illustrates the use of Delete-LocalRef to delete promptly local references in a utility function. Otherwise there will be two local references that remains allocated after each call to the MyNewString function.

    how does it cause local references to remain allocated in reference table although the native function returns?Because it doesn't return to the JVM where it gets deallocated, it returns to the unknown caller context, i.e. some other piece of native code in your JNI layer. So the references remain until the unknown caller context returns to the JVM.

  • How will be the weblogic-ejb-jar and ejb-jar xml for EJB Local Interface?

    Hi,
    I have one ear application which is using Stateless Session Beans. I don't have any Bean to Bean communication . At present, the client is invoking remote methods thro Home/Remote interfaces. My doubt is , shall I implement EJBLocal home/ local interface to obtain this same functionality cos, in this app, both client and EJb bean have been deployed in same JVM. Can Local interfaces only be applicable to Bean - Bean relation ship?If LocalHome/Local interfaces can be implemented in my scenario, then may I know how will be the ejb-jar.xml and weblogic-ejb-jar.xml?
    thanks and regards,
    Venkat.

    Local interfaces are for communication between ejbs and their clients when both are in the same JVM. The clients can be normal clients, jsps, servlets, and other ejbs. If the client is not in the same JVM you cannot use local interfaces even though your client is another ejb.
    Advantage of using local interface is it reduces the network overhead.
    For more information you can download Mastering Enterprise Java Beans Third Edition by Ed Roman. You can go through 45
    You can download pdf version from.
    http://www.theserverside.com/books/wiley/masteringEJB/index.tss.
    Let me know the URL of the ejb doc that you referred.
    Thanks..

  • How to deploy 2 EJB's in separate jars

    Hi,
    I have successfully deployed 2 session ejb's in the same jar file, i.e. with one ejb-jar.xml and one weblog-ejb-jar.xml. And get get the ejb's to communicate with each other.
    Now I want to be able to compile and deploy the 2 ejb's in separate jar files as part of an ear file.
    My method so far is this:
    I have split the ejb-jar.xml file into two, for each ejb, and also the weblogic-ejb-jar.xml file into two for each ejb.
    I then compiled the ejb source files and packaged each ejb up with its respective deployment descriptors into two separate .jar files.
    I then want to run weblogics ejbc on each .jar file in turn so that the resultant .jar files (with newly created stubs/skels) can be packaged into an .ear to be easily deployed into weblogic.
    I try and run the ejbc command on the first of the .jar files and i get the error:
    ERROR: Error from ejbc:
    In ejb-jar.xml, the EJB 'SessClient' contains an invalid ejb-link in ejb
    -ref 'ejb/SessLogHome'. No EJB with ejb-name 'IntellectStateless.jar#SessLog' co
    uld be found.
    ERROR: ejbc found errors
    My ejb-jar.xml file for this ejb is:
    <ejb-jar>
      <enterprise-beans>
        <session>
          <ejb-name>SessClient</ejb-name>
          <home>intellectsession.sessiontwo.SessClientEntHome</home>
          <remote>intellectsession.sessiontwo.SessClientEnt</remote>
          <ejb-class>intellectsession.sessiontwo.SessClientEntBean</ejb-class>
          <session-type>Stateless</session-type>
          <transaction-type>Container</transaction-type>
          <ejb-ref>
            <ejb-ref-name>ejb/SessLogHome</ejb-ref-name>
            <ejb-ref-type>Session</ejb-ref-type>
            <home>intellectsession.stateless.SessLogHome</home>
            <remote>intellectsession.stateless.SessLog</remote>
            <ejb-link>IntellectStateless.jar#SessLog</ejb-link>
          </ejb-ref>
        </session>
      </enterprise-beans>
      <assembly-descriptor>
        <container-transaction>
          <method>
         <ejb-name>SessClient</ejb-name>
         <method-name>*</method-name>
          </method>
          <trans-attribute>Required</trans-attribute>
        </container-transaction>
      </assembly-descriptor>
    </ejb-jar>and both of my .jar files are in the same directory when I run the ejbc command.
    I'm sure this can be done but I just think i'm not doing it in the right order maybe??
    Anyway pointers will be gr8ly appreciated.
    Cheers
    T

    Okay here is the solution to how to achieve the problem I encountered above:
    I am compiling my ejb.jar files using the weblogic.ejbc compiler, obviously I am deploying on weblogic here.
    This section:
    <ejb-ref>
      <ejb-ref-name>ejb/SessLogHome</ejb-ref-name>
      <ejb-ref-type>Session</ejb-ref-type>
    <home>intellectsession.stateless.SessLogHome</home>
      <remote>intellectsession.stateless.SessLog</remote>
      <ejb-link>IntellectStateless.jar#SessLog</ejb-link>
    </ejb-ref>must have JUST the <ejb-link/> tag removed from the ejb-jar.xml file. And then the weblogic-ejb-jar.xml file MUST look like this:
    <weblogic-ejb-jar>
        <weblogic-enterprise-bean>
            <ejb-name>SessClient</ejb-name>
            <reference-descriptor>
              <ejb-reference-description>
                <ejb-ref-name>ejb/SessLogHome</ejb-ref-name>
                <jndi-name>SessLog</jndi-name>
              </ejb-reference-description>
            </reference-descriptor>
            <jndi-name>SessClient</jndi-name>
        </weblogic-enterprise-bean>
    </weblogic-ejb-jar>Note the <refererence-descriptor> tag as the important part.
    After these changes, the 2 ejb.jar files can be compiled using the weblogic.ejbc tool, thus supplying the stubs/skels, and then the resultant two ejb.jar files can be added to the EAR file and deployed to weblogic.
    Result: 2 ejb's in separate jars, in one EAR file, talking to each other.
    T

  • Weblogic-cmp-jar.xml and EJB 1.1

    I am working on migrating a number of components from JBoss to WebLogic 10. Some of these components are using EJB 1.1. I want to do the migration without having to updated to EJB 2.0 or EJB 3.0.
    I have looked at the documentation for WebLogic 10 and understand that you need to use weblogic-cmp-jar.xml when using EJB 1.1. The problem is that I can not find an example of the weblogic-cmp-jar.xml. The documentation doesn't appear to fully document what the xml needs to look like.
    Would someone be able to provide me with a simple example of the weblogic-cmp-jar.xml for use with EJB 1.1?
    Thanks

    You can reference the edoc at:
    http://e-docs.bea.com/wls/docs100/ejb/DDreference-cmp-jar.html
    http://e-docs.bea.com/wls/docs100/ejb/ejb11.html

  • Ejb-link is still required when using local references?

    Hi!
    In BEA's link (http://e-docs.bea.com/wls/docs81/ejb/DDreference-ejb-jar.html#1114738) there is the following comment for weblogic-ejb-jar.xml element 'jndi-name':
    "Assigning a JNDI name to a bean is not recommended. Global JNDI names generate heavy multicast traffic during clustered server startup. See Using EJB Links for the better practice."
    Since we're using local references (local-jndi-name) to access our ejbs instead of remote references, is this still recommendation still pertinent?
    Thanks
    Christianne

    It is enough if you add the ejb-ref & ejb-link in the session bean. The
    session will look up relative to java:comp/env
    The following doc shows an example of accessing an ejb from a web app using
    ejb-link.
    http://e-docs.bea.com/wls/docs81/webapp/components.html#146848
    --Sathish
    <Christianne Carvalho> wrote in message news:[email protected]..
    I'm not getting very well how the ejb-link is used. In my case I have
    entity beans that are referenced in session beans.
    In my entity beans I have the following XDoclet tag.
    * @ejb.bean
    * name="ProductDescription"
    * display-name="ProductDescription"
    * jndi-name="ejb/ProductDescription"
    * local-jndi-name="ejb/ProductDescriptionLocal"
    * view-type="local"
    * type="CMP"
    In my session bean I'm currently getting the reference for the entity bean
    using the following code:
    productDescriptionLocalHome=(ProductDescriptionLocalHome)
    lookupLocalHome(ProductDescriptionLocalHome.JNDI_NAME);
    If I add the following XDoclet tag to my session bean, in ejb-jar.xml a
    <ejb-link> is created inside <ejb-local_ref> tag.
    * @ejb.ejb-ref ejb-name="ProductDescription" view-type="local"
    Considering the info above:
    1) In the entity bean, is there any extra tag to define the ejb-link or is
    the ejb-link only defined in the session bean?
    2) Re session bean, only adding the @ejb-ref xdoclet tag is enough for
    using the ejb-link or do I also have to change my lookup? If I do, what do
    I have to search for in the lookup?
    Thanks!

  • XDoclet  and ejb-jar.xml - No Entity tags?

    build.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <project name="XDoclet" default="ejbdoclet">
         <property file="build.properties"/>
         <target name="init">
              <property name="dir" value="G:\JAVA Tools"/>
              <property name="lib.dir" value="lib"/>
    <!-- library/jar path -->
              <property name="xdoclet.jar.path" value="${dir}\XDoclet\lib\xdoclet.jar"/>
              <property name="log4j.jar.path" value="${dir}\XDoclet\samples\lib\log4j.jar"/>
              <property name="ant.jar.path" value="${dir}\ANT\lib\ant.jar"/>
              <property name="src.dir" value="src"/>
              <property name="generated.src.dir" value="XDoclet/gen-src-code"/>
              <property name="web.dir" value="${src.dir}/web"/>
         <property name="generated.java.dir" value="${generated.src.dir}/java"/>
              <property name="config.dir" value="config"/>
              <property name="build.dir" value="XDoclet/build"/>
              <property name="dist.dir" value="XDoclet/dist"/>
              <property name="build.compiler" value="modern"/>
              <path id="project.class.path">
                   <fileset dir="${lib.dir}">
                        <include name="**/*.jar"/>
                   </fileset>
                   <!-- append the external classpath lastly -->
                   <pathelement path="${java.class.path};${log4j.jar.path}"/>
              </path>
         </target>
         <!-- Prepare -->
         <target name="prepare" depends="init">
              <mkdir dir="${build.dir}"/>
              <mkdir dir="${build.dir}/ejb"/>
              <mkdir dir="${build.dir}/ejb/META-INF"/>
              <mkdir dir="${build.dir}/web"/>
              <mkdir dir="${build.dir}/web/WEB-INF"/>
              <mkdir dir="${build.dir}/web/WEB-INF/tlds"/>
              <mkdir dir="${build.dir}/web/WEB-INF/classes"/>
              <mkdir dir="${build.dir}/j2ee"/>
              <mkdir dir="${build.dir}/j2ee/META-INF"/>
              <mkdir dir="${build.dir}/jmx"/>
              <mkdir dir="${dist.dir}"/>
              <mkdir dir="${generated.src.dir}"/>
              <mkdir dir="${generated.java.dir}"/>
              <echo message="XDoclet Path = ${xdoclet.jar.path}"/>
              <echo message="Log4J Path = ${log4j.jar.path}"/>
              <echo message="Ant Path = ${ant.jar.path}"/>
              <echo message="ClassPath = ${java.class.path}"/>
              <property name="cp" refid="project.class.path"/>
              <echo message="CLASSPATH/REF ID:${cp}"/>
              <echo message="base dir = ${basedir}/${src.dir}"/>
         </target>
         <target name="delete" >
         <echo message = "Deleting directories"/>
              <delete dir="${build.dir}"/>
              <delete dir="${build.dir}/ejb"/>
              <delete dir="${build.dir}/ejb/META-INF"/>
              <delete dir="${build.dir}/web"/>
              <delete dir="${build.dir}/web/WEB-INF"/>
              <delete dir="${build.dir}/web/WEB-INF/tlds"/>
              <delete dir="${build.dir}/web/WEB-INF/classes"/>
              <delete dir="${build.dir}/j2ee"/>
              <delete dir="${build.dir}/j2ee/META-INF"/>
              <delete dir="${build.dir}/jmx"/>
              <delete dir="${dist.dir}"/>
              <delete dir="${generated.src.dir}"/>
              <delete dir="${generated.java.dir}"/>
         </target>
         <!-- Run EJBDoclet -->
         <target name="ejbdoclet" depends="prepare">
              <taskdef name="ejbdoclet"
                   classname="xdoclet.ejb.EjbDocletTask"
                   classpath="${java.class.path};${log4j.jar.path};${ant.jar.path};${xdoclet.jar.path} "/>
              <ejbdoclet sourcepath="${src.dir}"
    destdir="${generated.java.dir}"
                   classpathref="project.class.path"
                   excludedtags="@version,@author"
                   ejbspec="2.0"
                   >
                   <fileset dir="${src.dir}">
                        <include name="**/*EJB.java"/>
                   </fileset>
                   <dataobject/>
    <!-- <localinterface/>
    <localhomeinterface/> -->
                   <remoteinterface/>
                   <homeinterface/>
                   <entitypk/>
    <!--               <entitycmp/> -->
                   <deploymentdescriptor destdir="${build.dir}/ejb/META-INF" validatexml="true"/>
                   <jboss version="2.4" xmlencoding="UTF-8" validatexml="true" typemapping="Hypersonic
                   SQL" datasource="java:/DefaultDS" destdir="${build.dir}/ejb/META-INF"/>
                   <!--
                   <weblogic xmlencoding="UTF-8" destdir="${build.dir}/ejb/META-INF" validatexml="true"/>
         <webSphere destdir="${build.dir}/ejb/META-INF" />
         <orion/>
                   <apachesoap destdir="${build.dir}/web"/>
         -->
                   <!--
    Have struts form objects generated based on entity beans'
    data objects. Will require struts.jar to compile.
    <strutsform />
    -->
              </ejbdoclet>
         </target>
    </project>
    My Session Bean:
    package com.uniserv.comn.controller.ejb.session.terminalfacade;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2003</p>
    * <p>Company: </p>
    * @author unascribed
    * @version 1.0
    import javax.ejb.*;
    import java.util.*;
    import com.uniserv.comn.util.*;
    import com.uniserv.comn.model.*;
    import com.uniserv.comn.controller.ejb.entity.tenderconfig.*;
    public class TerminalSessionFacadeEJB implements SessionBean {
    private SessionContext ctx = null;
    private ServiceLocator serviceLocator = null;
    public TerminalSessionFacadeEJB() throws ServiceLocatorException {
    try {
    serviceLocator = ServiceLocator.getInstance();
    } catch (Exception e) {
    System.out.println("TerminalSessionFacade Exception : " + e.getMessage());
    * Adds an tenderConfig record
    * @param tenderConfigVO TenderConfig's Value Object
    * @return boolean true if successful, false if not
    public boolean addTenderConfig(TenderConfigVO tenderConfigVO) {
              System.out.println("TerminalSessionFacadeEJB.addTenderConfig - START");
    boolean blnRet = false;
    try {
    LocalTenderConfigHome home = (LocalTenderConfigHome)
    serviceLocator.getLocalHome(ServiceLocator.Services.TENDERCONFIG);
    LocalTenderConfig local = null;
    try {
    TenderConfigPK pk
    = new TenderConfigPK(tenderConfigVO.getTndrID(), tenderConfigVO.getTndrCfgName());
    local = home.findByPrimaryKey(pk);
    } catch (Exception e) {
    System.out.println(e.getMessage());
    } finally {
    if (local == null) {
    home.create(tenderConfigVO);
    blnRet = true;
    } else {
    blnRet = false;
    } catch (Exception e) {
    System.out.println("Error in TerminalSessionFacadeEJB.addTenderConfig "
    + "method (Exception) : "
    + e.getMessage());
    } finally {
    System.out.println("Returned value : " + blnRet);
              System.out.println("TerminalSessionFacadeEJB.addTenderConfig - END");
    return blnRet;
    public void setSessionContext(SessionContext parm1) throws javax.ejb.EJBException, java.rmi.RemoteException {
    this.ctx = parm1;
    public void ejbRemove() throws javax.ejb.EJBException, java.rmi.RemoteException
    public void ejbActivate() throws javax.ejb.EJBException, java.rmi.RemoteException
    public void ejbPassivate() throws javax.ejb.EJBException, java.rmi.RemoteException
    public void ejbCreate() throws javax.ejb.EJBException
    My Entity Bean:
    package com.uniserv.comn.controller.ejb.entity.tenderconfig;
    * @ejb.bean
    * type="CMP"
    * cmp-version="2.x"
    * name="TenderConfigEJB"
    * schema="TenderConfig"
    * view-type="local"
    import javax.ejb.*;
    import com.uniserv.comn.model.*;
    public abstract class TenderConfigEJB implements EntityBean{
    private EntityContext ctx = null;
    * @ejb.pk
    public abstract int getTndrID();
    public abstract void setTndrID(int iTndrID);
    * @ejb.pk
    public abstract String getTndrCfgName();
    public abstract void setTndrCfgName(String strTndrCfgName);
    public abstract int getTndrType();
    public abstract void setTndrType(int iTndrType);
    public abstract String getTndrCfgValue();
    public abstract void setTndrCfgValue(String strTndrCfgValue);
    public abstract String getTndrCfgDataType();
    public abstract void setTndrCfgDataType(String strTndrCfgDataType);
    public abstract String getTndrCfgDesc();
    public abstract void setTndrCfgDesc(String strTndrCfgDesc);
    public TenderConfigVO getTenderConfigVO() {
    TenderConfigVO tenderConfigVO = new TenderConfigVO();
    tenderConfigVO.setTndrID(this.getTndrID());
    tenderConfigVO.setTndrCfgName(this.getTndrCfgName());
    tenderConfigVO.setTndrType(this.getTndrType());
    tenderConfigVO.setTndrCfgValue(this.getTndrCfgValue());
    tenderConfigVO.setTndrCfgDataType(this.getTndrCfgDataType());
    tenderConfigVO.setTndrCfgDesc(this.getTndrCfgDesc());
    return tenderConfigVO;
    public void setTenderConfigVO(TenderConfigVO tenderConfigVO) {
    this.setTndrID(tenderConfigVO.getTndrID());
    this.setTndrCfgName(tenderConfigVO.getTndrCfgName());
    this.setTndrType(tenderConfigVO.getTndrType());
    this.setTndrCfgValue(tenderConfigVO.getTndrCfgValue());
    this.setTndrCfgDataType(tenderConfigVO.getTndrCfgDataType());
    this.setTndrCfgDesc(tenderConfigVO.getTndrCfgDesc());
    * Constructor
    public TenderConfigEJB() {
    * ejbCreate callback method
    * @return int
    public TenderConfigPK ejbCreate(TenderConfigVO tenderConfigVO)
    throws CreateException {
    this.setTenderConfigVO(tenderConfigVO);
    return null;
    * ejbPostCreate
    * @param TerminalConfigTypeVO
    public void ejbPostCreate(TenderConfigVO tenderConfigVO) {
    * setEntityContext callback method
    public void setEntityContext(EntityContext ctx) {
    this.ctx = ctx;
    * unsetEntityContext callback method
    public void unsetEntityContext() {
    this.ctx = null;
    * ejbActivate callback method
    public void ejbActivate() {
    * ejbPassivate callback method
    public void ejbPassivate() {
    * ejbLoad callback method
    public void ejbLoad() {
    * ejbRemove callback method
    public void ejbRemove() {
    * ejbStore callback method
    public void ejbStore() {
    But the generated ejb-jar.xml only contains
    <?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>
         <description>No Description.</description>
         <display-name>Generated by XDoclet</display-name>
         <enterprise-beans>
              <!-- Session Beans -->
              <session>
                   <description><![CDATA[No Description.]]></description>
                   <ejb-name>com.uniserv.comn.controller.ejb.session.terminalfacade.TerminalSessionFacade</ejb-name>
                   <home>com.uniserv.comn.controller.ejb.session.terminalfacade.TerminalSessionFacadeHome</home>
                   <remote>com.uniserv.comn.controller.ejb.session.terminalfacade.TerminalSessionFacade</remote>
                   <ejb-class>com.uniserv.comn.controller.ejb.session.terminalfacade.TerminalSessionFacadeEJB</ejb-class>
                   <session-type>Stateless</session-type>
                   <transaction-type>Container</transaction-type>
              </session>
              <!--
    To add session beans that you have deployment descriptor info for, add
    a file to your merge directory called session-beans.xml that contains
    the <session></session> markup for those beans.
    -->
              <!-- Entity Beans -->
              <!--
    To add entity beans that you have deployment descriptor info for, add
    a file to your merge directory called entity-beans.xml that contains
    the <entity></entity> markup for those beans.
    -->
              <!-- Message Driven Beans -->
              <!--
    To add message driven beans that you have deployment descriptor info for, add
    a file to your merge directory called message-driven-beans.xml that contains
    the <message-driven></message-driven> markup for those beans.
    -->
         </enterprise-beans>
         <!-- Relationships -->
         <!-- Assembly Descriptor -->
         <assembly-descriptor>
              <!-- finder permissions -->
              <!-- transactions -->
              <!-- finder transactions -->
         </assembly-descriptor>
    </ejb-jar>
    this ejb-jar.xml only contains entries for session beans? where did the entries for entity beans went?Ive written XDoclet tags for the Entity Bean as what ive posted above....help!!!

    you comment the generation of CMP entity beans out :
    build.xml:
    replace
    <!-- <entitycmp/> -->
    with
    <entitycmp/>i've already removed the comments of the tag <entitycmp> and yet the resulting ejb-jar.xml contains no <entity> tags....i'm just wondering how can i include the generation of entity tags (not only session tags) in the resulting ejb-jar.xml
    <ejb-jar>
    <description>No Description.</description>
         <display-name>Generated by XDoclet</display-name>
         <enterprise-beans>
              <!-- Session Beans -->
              <session>
                   <description><![CDATA[No Description.]]></description>
                   <ejb-name>com.uniserv.comn.controller.ejb.session.terminalfacade.TerminalSessionFacade</ejb-name>
                   <home>com.uniserv.comn.controller.ejb.session.terminalfacade.TerminalSessionFacadeHome</home>
                   <remote>com.uniserv.comn.controller.ejb.session.terminalfacade.TerminalSessionFacade</remote>
                   <ejb-class>com.uniserv.comn.controller.ejb.session.terminalfacade.TerminalSessionFacadeEJB</ejb-class>
                   <session-type>Stateless</session-type>
                   <transaction-type>Container</transaction-type>
              </session>
              <!--
    To add session beans that you have deployment descriptor info for, add
    a file to your merge directory called session-beans.xml that contains
    the <session></session> markup for those beans.
    -->
              <!-- Entity Beans -->
              <!--
    To add entity beans that you have deployment descriptor info for, add
    a file to your merge directory called entity-beans.xml that contains
    the <entity></entity> markup for those beans.
    -->
              <!-- Message Driven Beans -->
              <!--
    To add message driven beans that you have deployment descriptor info for, add
    a file to your merge directory called message-driven-beans.xml that contains
    the <message-driven></message-driven> markup for those beans.
    -->
         </enterprise-beans>
         <!-- Relationships -->
         <!-- Assembly Descriptor -->
         <assembly-descriptor>
              <!-- finder permissions -->
              <!-- transactions -->
              <!-- finder transactions -->
         </assembly-descriptor>
    </ejb-jar>

  • Using JMX to read ejb manifest jar and ejb-jar.xml in ejb jar inside ear

    Hello,
    I have an ear deployed on weblogic console. I need to check contents of manifest file and ejb-jar.xml of a jar that is present in the deployed ear.
    Currently I am using below code to access jar inside ear deployed :
    Hashtable env = new Hashtable(5);
    env.put(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    env.put(Context.PROVIDER_URL,
    url);
    env.put(Context.SECURITY_PRINCIPAL, user);
    env.put(Context.SECURITY_CREDENTIALS, password);
    Context ctx = new InitialContext(env);
    mBeanHome = (MBeanHome)ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);
    String type = "EJBComponentRuntime";
    Set beans = mBeanHome.getMBeansByType(type);
    try{
    for(Iterator it=beans.iterator();it.hasNext();)
    EJBComponentRuntimeMBean rt = (EJBComponentRuntimeMBean)it.next();
    if(rt.getParent().getName().equals("xxx")){
    System.out.println(rt.getName());
    l.add(rt.getName());
    Here xxx is the ear. Now I need to get inside the jar (represented) by variable rt and access its manifest file,ejb-jar.xml
    Does anyone have an idea how to do this?
    regards
    Sameer

    Isn't it possible to put them there manually? :)

  • ClassCastException by using Local Interface of EJB in other, but local EAR

    Hi,
    I get a ClassCastException if I try to cast the EJSWrapper-Class returned from local EJB Lookup to the interface it implements.
    The environment I use is WSADIE 5.1.1 with integrated Testenvironment.
    I have defined two EARs. One with a Web-Application and one wich contains the EJB to call from the WebApp. Both run in the same appserver instance wich means both run in the same JVM and i should be able to use Local Interface of the EJB.
    The EJB should use Libraries from the Server Environment while the WebApp uses newer Libs than the Server Environment offers(eg axis-rpc,wsdl4j,saaj). The Classloader-Policy of the EAR with the WebApp is set to PARENT_LAST while the Classloader-Policy of the EAR with the EJB is set to PARENT_FIRST.
    I do a Lookup by using an EJB-Local-Reference. The returned object is an EJSLocalStatelessHome-Object, wich implements my LocalEJBInterface. But if i try to cast to Object to this interface a ClassCastException occurs.
    The Classes of the EJB are packaged as follows:
    EJBName.jar contains the EJB-Impl class, the Serverside Implementations for RMI/IIOP interaction an EJSWrapper classes. This jar is packaged with the EJB-EAR.
    EJBClient.jar contains the Local- and Remote-Interface classes and the Stub-classes for EJBHome and EJB-Implementation. This jar is packaged wich both EARs, because of the interfaces, wich are needed in both projects.
    The Classloader of the EAR with the WebApp has no access the jar with the EJB-Impl, the generated Ties- and EJSWrapperclasses because it is located in only the EJB-EAR. But the interface-class is contained in the WebApp-EAR as described above.
    The exact Exception is as follows:
    java.lang.ClassCastException: com/ibm/wsrf/EJSLocalStatelessBPEAdapterHome_c2546ef5 incompatible with com/ibm/wsrf/BPEAdapterLocalHome
    java.lang.Throwable.<init>(Throwable.java)
    java.lang.Throwable.<init>(Throwable.java)
    java.lang.ClassCastException.<init>(ClassCastException.java:53)
    org.tempuri.ResourceDiscoveryService.DiscoverySoapHttpBindingImpl.getResourceEPR(DiscoverySoapHttpBindingImpl.java)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java)
    ... The EJSLocalStatelessBPEAdapterHome_c2546ef5 implements the BPEAdapterLocalHome interface.
    Please, can anyone give me a hint how to solve this problem?
    Thanks in advance, Michael

    Problem solved!
    The different EAR contained each an own copy of the jar with the local and remote interfaces of the EJB. The Problem is caused by the separate classloaders of the EARs in an application server. Each EAR Classloader loads his own version of the interface classes. Is the same class loaded by different classloaders, the JVM handles this classes as different classes. An example if you create an instance of a class in one classloader and try to reference the created instance by the same class from another classloader, the association will fail, because of different classloaders in the same JVM.
    The solution in an application server where you have deployed two projects and want to use local interfaces is, store the interfaces(and only the interfaces) in an directory, where it is found by the parent classloader of the EAR classloaders. Remove the Jar with the interface from the EARs. The EAR Classloaders will then search in the their parent classloader for the interfaces. The interfaces will be loaded by the parent classloader and will recognized as compatible by the JVM.
    Greetings, hope this helps help others!
    Michael

  • How to get .class files (and others) out of JAR in code?

    Hi all,
    I am packaging up several classes in a jar file. In my code I want to be able to "read" any number of jar files, and in each case pull out all the .class files to create instances of them. I don't want to unzip/unjar the files to the disk system. I basically want to create instances of the classes in the jar files in memory as if they had been loaded off the disk by themselves. Here is the sticky issue. I have a class in each jar that is "instantiated" by my plugin engine. There are other classes in the JAR file that "support" this class that is created. For instance, the class that is instantiated then has references and calls to new SomeClase() in it, and those classes are in the JAR file. So, is there some way to either "pull out" the class(es) of a JAR file without actually unjarring them to the local system and be able to create instances of them? Or, perhaps there is a way to make the classpath of the running app "see into" all the JAR files (and any sub-dirs/packages in that jar file) as if it was part of its class path? Again, these are always loaded via the Class.forName() call and newInstance(), and can not be programitcally added to the initial running application.
    Thanks.

    Not sure if this is what you are asking, but...
    You have jars that reference each other (sounds pretty tightly coupled to me, maybe they shouldn't be in separate jars, but I digress) and each has a manifest file in META-INF, right?
    To reference another jar's contents, simply add it to the Class-Path variable in your manifest. Then you can reference the classes as if they were all unjarred and slapped in the same directories.
    More Info:
    http://java.sun.com/docs/books/tutorial/jar/basics/manifest.html#special-purpose
    Tarabyte :)

Maybe you are looking for