EJB implementation

Hi,
I am calling an EJB from a normal java class by lookup. If I do a plain Lookup with the JNDI name it goes pretty fine and I am able to get the EJBObject instance. but If i try to call with the reference i mean creating reference which we create when we are calling one EJB from the other or when we call and EJB from a web layer it is giving namenotfound exception. Can anybody let me know whether we can call the ejb from a normal java class with a reference when both the ejb and the java class are in the same package.
Below give is the code which demonstrates my problem.
code:
//          Context jndiContext = new InitialContext();          Object obj = jndiContext.lookup("java:comp/env/ejb/Test");          TestHome testHome = (TestHome)PortableRemoteObject.narrow(obj,TestHome.class);          Test test = testHome.create();          test.processTransaction(100);
Cheers,
Naidu Sanapala
Laurel, Maryland, USA.
Naidu Sanapala - JAVA ARCHITECT , Laurel , Maryland , USA
1.SUN Certified Enterprise Architect for J2EE Technology
2.Sun Certified [EJB] Business Component Developer for the J2EE Platform
3.Sun Certified Web Component Developer for the J2EE Platform
4.Sun Certified Java Programmer for the Java 2 Platform - 1.4
5.IBM Certified Solution Developer for XML and Related Technologies
....................................................................................................

Hi Naidu,
It's not a question of whether the calling code and the target ejb are in the same java package. What matters is whether the calling code is part of a J2EE component and where it is executing. Any code running within a J2EE component (servlet, jsp, ejb, Application Client) can declare component dependencies and look them up via java:comp/env. In J2EE 1.4 and earlier this means declaring the dependency in web.xml, ejb-jar.xml or application-client.xml.
If you have code running outside of an Application Server and outside of an Application Client container, it's not a J2EE component and therefore cannot use the J2EE component namespace (java:comp/env). Technically these kinds of applications are not portable. However, most implementations support them by requiring that the code do a direct global lookup of a JNDI name.
--ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • How to avoid restart weblogic after I modify EJB implementation class?

    I am sure I redeploy my application after I modify EJB implementation class. It
    is unacceptable to restart weblogic server if I changed some EJB . Is there any
    way to avoid this?
    Thanks!

    I would open a case with BEA support. I would take a look at it, but I'm going
    on vacation :(
    pat
    "CottonXu" <[email protected]> wrote:
    >
    My WLS version is 7.0 and I use weblogic console to redeploy the entire
    application.
    I am sure that EJBs are not in classpath.
    What should I do ?
    "Pat Bumpus" <[email protected]> wrote:
    Hi,
    I haven't seen this behavior. My EJBs seem to redeploy and pick upthe
    EJB bean
    changes. Make sure that your EJB is not in the system classpath that
    could cause
    this problem.
    What version of WLS?
    How are you deploying the EJB?
    pat
    "CottonXu" <[email protected]> wrote:
    I am sure I redeploy my application after I modify EJB implementation
    class. It
    is unacceptable to restart weblogic server if I changed some EJB .
    Is
    there any
    way to avoid this?
    Thanks!

  • Redeploying an Individual EJB Implementation Class

    Hi all,
    Read from the documentation http://edocs.bea.com/wls/docs81/ejb/deploy.html#1088643 that WLS 8.1 is supporting deploying of an individual EJB implementation class, but sadly no further examples or steps are shown to illustrate this.
    If I have a few entity & session beans inside my EJB JAR, how could I proceed to recompile & regenerate just the needed files for a specific EJB?
    Could someone help me with this?
    Many thanks!

    This will work only in case of exploded applications where you can just
    update the implementation classes. You can use the weblogic.Deployer tool to
    redeploy just the implementation class.
    --Sathish
    <Cheng Wei Lee> wrote in message news:[email protected]..
    Hi all,
    Read from the documentation
    http://edocs.bea.com/wls/docs81/ejb/deploy.html#1088643 that
    WLS 8.1 is supporting deploying of an individual EJB implementation class,
    but sadly no further examples or steps are shown to illustrate this.
    If I have a few entity & session beans inside my EJB JAR, how could I
    proceed to recompile & regenerate just the needed files for a specific
    EJB?
    Could someone help me with this?
    Many thanks!

  • Oracle Reserved Words in EJB Implementations

    Hello Everybody!
    Suppose there is a table in Oracle , say Account which has a column, say comment. comment is a reserved word in Oracle. I would like to know how Oracle reserved words are handled in EJB implementation. For example, suppose there is an enterprise application that accesses such a table using CMP beans, how would we specify the <field-map>
    <field-map>
    <cmp-field>comment</cmp-field>
    <dbms-column>COMMENT</dbms-column>
    </field-map>
    This doesnt work because COMMENT is a reserved word in Oracle. In Oracle,
    if we use comment as a column name, it has to be represented in double quotations.
    for example, this select query doesnt work
    select COMMENT from account;
    these select queries works
    select "COMMENT" from account;
    select A."COMMENT" from account A;
    Regarding the current EJB implementations, the question is whether they support Oracle reserved words in their mappings??
    "COMMENT"s welcome
    Thanks!
    Manu Ramakrishnan

    >
    This doesnt work because COMMENT is a reserved word in
    Oracle. In Oracle,
    if we use comment as a column name, it has to be
    represented in double quotations.
    Did you try it?
    Did you try it with double quotes?
    The specs I looked at do not discuss this(jdbc, ejb, j2ee.) The ejb spec reserves as part of EJB QL some standard ANSI SQL reserved words and specifically suggests that other ANSI SQL reserved words should not be used.
    And if I am reading the EJB QL section correctly identifiers (which would be a table, field names) do not allow quoted identifiers. Or at least they specifically do not allow fields with, for example, a space. This sort of name is specifically allowed for in ANSI SQL and has been since the first version of ANSI SQL. They also do not allow for case sensitive names, which again is allowed in ANSI SQL as part of a quoted identifier.
    That suggests to me that you use reserved words that either you going to be using a non-J2EE feature of a container or it simply won't work in the first place.

  • RE: [iPlanet-JATO] EJB in iMT

    Matt,
    Thanks for your clarifications.That helps a lot.
    We have found in a lot of cases, that your new components can be
    implemented as JATO ModelsI don't understand this.Is it that EJB acts as the Data Model or something
    Thanks,
    Gajendran.
    "Matthew Stevens"
    Subject: RE: [iPlanet-JATO]
    EJB in iMT
    10/30/01 07:34 PM
    Please respond to
    iPlanet-JATO
    Gajendran,
    The iMT for NetDynamics does not current have any translation requirement
    for EJBs. If you have a ND 3.x or ND 4.x application then you have no
    pre-existing EJBs. ND 5.0 provided an EJB 1.0 container for Session Beans
    but the Migration leaves the EJBs untouched. The migration path for ND 5.0
    EJBs to J2EE EJBs is clear - it simply requires a recompiling and packaging
    and tweaking. I have done this at some customer sites and it is very
    straight forward. In many cases, you may find that your choice of an EJB
    implementation does not truely take advantage of the features of the EJB
    container and you EJBs are simply business objects (stateless and
    stateful).
    We have found that migrating stateless and stateful ND 5.0 EJBs to JATO
    Models is very simple and greatly improves the performance in many cases.
    Now that your ND application is migated to J2EE/JATO you can easily add
    EJBs
    to the application; JATO does not prevent this in any way. Some customers
    are even adapting existing or 3rd party EJBs to JATO Models interfaces, but
    this is not necessary. Your EJBs will be packaged separately in JAR file
    and combined with JATO Application WAR file in an EAR file. We recommend
    using a good tool like Forte to generate your EJBs. I personally suggest
    that you carefully plan and analyze your requirements before moving forward
    with the EJBs. Please make sure that you your new components 'need' the
    features of the EJB container/framework. If you need an Entity bean then
    use it. We have found in a lot of cases, that your new components can be
    implemented as JATO Models. It all depends on the dynamics of the
    application and constitution of your data.
    matt
    -----Original Message-----
    From: gajendran.gopinathan@i...
    [mailto:<a href="/group/SunONE-JATO/post?protectID=123166177056078154218098066036192063041102166009043241114211116056004136218164200193244096076095219">gajendran.gopinathan@i...</a>]
    Sent: Tuesday, October 30, 2001 6:40 AM
    Subject: [iPlanet-JATO] EJB in iMT
    We have migrated an application in ND3.0 to J2EE using iMT 1.1.1.
    Is there any provision in iMT which could generate EJBs?
    What is the recommended approach towards this?
    Thanks,
    Gajendran
    For more information about JATO, please visit:
    http://developer.iplanet.com/tech/appserver/framework/index.jsp
    For more information about JATO, please visit:
    http://developer.iplanet.com/tech/appserver/framework/index.jsp
    ------------------------Disclaimer------------------------
    The views of the author may not necessarily reflect those
    of the Company. All liability is excluded to the extent
    permitted by law for any claims arising as a result of the
    use of this medium to transmit information by or to
    IT Solutions (India) Pvt. Ltd.
    We have taken precautions to minimize the risk of
    transmitting software viruses, but we advise you to
    carry out your own virus checks on any attachment to
    this message. We cannot accept liability for any loss or
    damage caused by software viruses.
    ------------------------Disclaimer------------------------

    Matt,
    Thanks for your clarifications.That helps a lot.
    We have found in a lot of cases, that your new components can be
    implemented as JATO ModelsI don't understand this.Is it that EJB acts as the Data Model or something
    Thanks,
    Gajendran.
    "Matthew Stevens"
    Subject: RE: [iPlanet-JATO]
    EJB in iMT
    10/30/01 07:34 PM
    Please respond to
    iPlanet-JATO
    Gajendran,
    The iMT for NetDynamics does not current have any translation requirement
    for EJBs. If you have a ND 3.x or ND 4.x application then you have no
    pre-existing EJBs. ND 5.0 provided an EJB 1.0 container for Session Beans
    but the Migration leaves the EJBs untouched. The migration path for ND 5.0
    EJBs to J2EE EJBs is clear - it simply requires a recompiling and packaging
    and tweaking. I have done this at some customer sites and it is very
    straight forward. In many cases, you may find that your choice of an EJB
    implementation does not truely take advantage of the features of the EJB
    container and you EJBs are simply business objects (stateless and
    stateful).
    We have found that migrating stateless and stateful ND 5.0 EJBs to JATO
    Models is very simple and greatly improves the performance in many cases.
    Now that your ND application is migated to J2EE/JATO you can easily add
    EJBs
    to the application; JATO does not prevent this in any way. Some customers
    are even adapting existing or 3rd party EJBs to JATO Models interfaces, but
    this is not necessary. Your EJBs will be packaged separately in JAR file
    and combined with JATO Application WAR file in an EAR file. We recommend
    using a good tool like Forte to generate your EJBs. I personally suggest
    that you carefully plan and analyze your requirements before moving forward
    with the EJBs. Please make sure that you your new components 'need' the
    features of the EJB container/framework. If you need an Entity bean then
    use it. We have found in a lot of cases, that your new components can be
    implemented as JATO Models. It all depends on the dynamics of the
    application and constitution of your data.
    matt
    -----Original Message-----
    From: gajendran.gopinathan@i...
    [mailto:<a href="/group/SunONE-JATO/post?protectID=123166177056078154218098066036192063041102166009043241114211116056004136218164200193244096076095219">gajendran.gopinathan@i...</a>]
    Sent: Tuesday, October 30, 2001 6:40 AM
    Subject: [iPlanet-JATO] EJB in iMT
    We have migrated an application in ND3.0 to J2EE using iMT 1.1.1.
    Is there any provision in iMT which could generate EJBs?
    What is the recommended approach towards this?
    Thanks,
    Gajendran
    For more information about JATO, please visit:
    http://developer.iplanet.com/tech/appserver/framework/index.jsp
    For more information about JATO, please visit:
    http://developer.iplanet.com/tech/appserver/framework/index.jsp
    ------------------------Disclaimer------------------------
    The views of the author may not necessarily reflect those
    of the Company. All liability is excluded to the extent
    permitted by law for any claims arising as a result of the
    use of this medium to transmit information by or to
    IT Solutions (India) Pvt. Ltd.
    We have taken precautions to minimize the risk of
    transmitting software viruses, but we advise you to
    carry out your own virus checks on any attachment to
    this message. We cannot accept liability for any loss or
    damage caused by software viruses.
    ------------------------Disclaimer------------------------

  • @EJB not working when used in Cactus ServletTestCase

    Hi All,
    I am running my tests using Cactus ServletTestCase servlet and testing my EJB from there. I deploy my EAR application (my test servlet is in WAR, EJB in EAR modul)
    When I run the test, I got NPE as the @EJB is not working and EJB ref is not initialized. Strange thing is, the @EJB is working fine from any other servlet or POJO in WAR.
    Test result:
    <webresult>
    &#8722;
    <exception classname="java.lang.NullPointerException">
    <message>null</message>
    &#8722;
    <stacktrace>
    java.lang.NullPointerException
         at test.fenix.legalsubject.TestLegalSubjectController.testConvert(TestLegalSubjectController.java:56)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at junit.framework.TestCase.runTest(TestCase.java:164)
         at junit.framework.TestCase.runBare(TestCase.java:130)
         at org.apache.cactus.internal.AbstractCactusTestCase.runBareServer(AbstractCactusTestCase.java:155)
         at org.apache.cactus.internal.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:120)
         at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody0(AbstractWebTestController.java:94)
         at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody1$advice(AbstractWebTestController.java:218)
         at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest(AbstractWebTestController.java:1)
         at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody2(ServletTestRedirector.java:102)
         at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody3$advice(ServletTestRedirector.java:218)
         at org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java:1)
         at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody0(ServletTestRedirector.java:73)
         at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody1$advice(ServletTestRedirector.java:218)
         at org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.java:1)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
         at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:290)
         at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
         at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
         at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
         at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
         at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
         at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
         at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
         at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
         at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
         at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380)
         at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
         at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
    </stacktrace>
    </exception>
    </webresult>
    my test class:
    public class TestLegalSubjectController extends ServletTestCase {
         * Class under test
         static final Logger log = Logger
                   .getLogger(TestLegalSubjectController.class);
         * TODO nemuzu to rozchodit
         @EJB
         public LegalSubjectController legalSubject;
    local interface:
    @Local
    public interface LegalSubjectController extends ControllerFilter {
    public LegalSubjectWizardData getByID(Long ID);
    public void createLegalSubject(LegalSubjectWizardData legalSubjectWizardData);
    public LegalSubject findByName(String name);
    EJB implementation
    @Stateless
    public class LegalSubjectControllerBean implements LegalSubjectController, LegalSubjectControllerRemote {
    private static final Logger log = Logger.getLogger(LegalSubjectControllerBean.class);
    I am stucked with this one, dont want to use the EJB2 way with JNDI look up. Any suggestions much appreciated!

    Was anyone ever able to figure out a solution for this issue? I'm having the exact same problem right now and this is the only reference to it I've been able to find online.
    Thanks!
    -Blake

  • Questions on Java Reflection in EJB

    Hi,
    Recently, I use reflection technology on EJB to get/set properties of a bean.
    We need it because we need to encapsulate data in a map to transfer data between
    presentation layer and business back end(i.e. the so-called value data object).
    A bean is packed into a map as following:
    The property name of a bean becomes the key in the map, and its value becomes the
    corresponding value in the map.
    So we have to do two things:
    1)Given a bean, convert it to a map;
    2)Given a data map, assign the value to a bean
    It would be nice if we can implement the two requirements in a base class. So I use
    reflection. And succeed to achieve the goal.
    But there are two problems occured and I can't understand why.
    1)If I use Class.forName() to load the entity bean implementation class(BMP or CMP abstract
    schema) I got a ClassNotFoundException. A workaround is to jar the BMP or CMP bean class
    and place it on the classpath.
    So, I want to know why there is such restriction.
    2)For the classes java.lang.reflect.Method, java.lang.reflect.InvocationTargetException
    I reference to in bean class, the IDE(I use IntelliJ Idea) give me a
    warning: "Use java.lang.reflect.Method are not allowed in EJB". Are the methods really
    dangerous in EJB environment?
    Can anyone explain me these pluzzles?
    Thank you in advance!
    BTW, I develop under weblogic 7.0. Now, my program functions well, I just can't understand
    the above phenomena.
    Regards,
    Justine

    1) You should never directly manipulate the EJB implementation class. That class is for the container. When accessing EJBs (no matter the means), you should use the Home/Remote or Local interfaces - those your client should already have. If what you're doing is actually working for you, I can only say that you're not using EJBs properly and are not getting the actual "bang for the buck" you paid for. And you're damn lucky it hasn't blown bits all over the place...
    2) Yes, it is potentially dangerous to be dorking around with reflection on EJBs. When you're using the Home/Remote or Local interfaces, you're actually using an Object that the vendor supplies to perform the actual remote operations. Using reflection could potentially invoke one of the "hidden" vendor methods with extremely unpredictable results - like deleting your entire table.
    As for using a map for transferring data, I would strongly recommend against it, especially in this case, because you've not only lost the strong typing you get with ValueObjects, but you have to do a lot of extra work on both "sides" (client and EJB) to make sure all your data is present and/or correct.

  • EJB 3.0, BC4J and weblogic managed server

    Hi, I've got a problem using EJB 3.0 with a BC4J Application module in a weblogic managed server.
    My bean is a stateless session bean that use BC4J for database transaction.
    When I call the bean the first time, It returns de values I need, without problem. If I do the same call again, I always get "null". I deployed the same bean on the AdminServer, linking to the same DataSource, It works fine and I never got a null result.
    My application module is created insid my EJB abstract class by :
    _am = (BaseServiceImpl)Configuration.createRootApplicationModule(adfModel, adfConfiguration);*
    Where adfModel and adfConfiguration are configured through annotations in my EJB Implementation.
    In my abstract EJB, I have a methode with a +@PreDestroy+ method like that :
    +@PreDestroy+
    *protected void releaseModele() {*
    *if (_am != null) {*
    Configuration.releaseRootApplicationModule(_am, false);
    _am = null;*
    My Data Source on the server is defined as Supporting Global Transaction, one-phase commit. I activated the BC4J Logs on the server to see what was going on and I see that the JDBC seems to close after the first call :
    *** closing jdbc connection now **** (weblogic.jdbc.wrapper.JTSConnection_oracle_jdbc_driver_T4CConnection@0)
    And that is when I've got the error on the server :
    oracle.jbo.InvalidObjAccessException: JBO-25036: An invalid object operation was invoked on type View Object with name AppModAD
    So, my JDBC connection seems to close somewhere beetween the first and the second call, but only on a managed server... Someone has ever encountered a problem like that?
    Maybe there is something with the configuration of a datasource on a managed server? Or with the lifecycle of an

    The solution was to NOT have glabal transaction checked in the configuration of the data-source and "Failover Transaction State Upon Managed Release" uncked in the configuration of the Business component configuration.

  • Using service Locator pattern to dynamically access remote EJBs

    Hi All,
    Please help to guide me how I can use a service locator to retrieve a remote object (residing on another application but on same domain) .
    I do not want to use Dependency Injection since I want to dynamically discover them ( there are many implementations of same interface (POJO)). Each EJB implementation implements its own remote/local interface that extends this global POJO interface.
    I have two J2ee-Applications on same domain. J2EE-Application 1 has an EJB module (EJB Module 1) that intends to access an EJB Module (EJB Module 2) in J2EE-Application 2. Following observations:
    1. Dependency Injection fails if (include the EJB Module 2 jar in J2EE-Application 1). Reason App Server complains the EJB has been deployed (Deployment fails)
    2. Dependency Injection works if (exclude the EJB Module 2 jar in J2EE-Application 1) and include the Remote Interface in EJB Module 1(J2EE-Application 1).Positive Observation (Deployment success and DI also success)
    3.Using Service Locator to retrieve the remote object if (exclude the EJB Module 2 jar in J2EE-Application 1) and include the Remote Interface in EJB Module 1(J2EE-Application 1). Negative and Positive Observation.
    Positive Observation: Using dependency injection I can still retrieve the Remote Object
    Another Positive: The Service Locator remote lookup to another Bean in same Application but different EJB Module is successful.
    Negative Observation:
    The Service Locator lookup to this same remote object with Successful Dependency Injection fails (An Ejb in a different application).
    Can't retrieve the Remote Object with Service Locator. Message from Server:.
    NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial.
    Thanks in advance

    "I do not want to use Dependency Injection since I want to dynamically discover them ( there are many implementations of same interface (POJO))"
    If you're calling ejbs from other ejbs or servlets, the same could probably be acomplished by using dependency injection (@EJB) in a number of instance variables typed with different remote/local interfaces or even with different beanName attributes (for when more than one bean implements the same managed interface in the same app - not sure how it works outside the same jee app...) , and dinamically selecting one of them; or encapsulating those injected variables into a stateless ejb as your service locator to make them accessible from POJOs too (which, due to concurrent acess, wouldn't work for statefull ejbs references...).
    Anyway, using the jndi lookup service locator pattern seems ok in this case.
    What doesn't seem ok, given the nature of the error for the negative observation - jndi context initialization - is that
    Another Positive: The Service Locator remote lookup to another Bean in same Application but different EJB Module is successful.
    Can you check your code and reconfirm that you're using the same context initialization code for both the positive and negative observations ?

  • A prefix can be included in the EJB JNDI name dynamically?

    In the Stateless annotation, we can specify the mappedName attribute to the EJB JNDI name bind.
    Can we specify a prefix to the mappedName separately?
    For example: We have this:
    @Stateless(mappedName="myEJB")And don't want to do this:
    @Stateless(mappedName="prefix/myEJB")We want to include the prefix in another place in the code dynamically.
    Can we do that??

    jtahlborn wrote:
    eudesf wrote:
    Hello! Thanks for reply!
    As I can't configure programatically, there is any way to configure in an application descriptor, or in another place of the application server?
    The idea is to publish two applications that use the same EJB classes, but in different JNDI namespaces, because we don't want to share the resources. Otherwise, it will result in JNDI name conflicts. The applications works in different contexts and we want to reuse the existing EJB definitions.
    Any suggestion?yes you can do this. ejb 3.0 keeps the features from 2.1, namely all the xml based configuration (although it is now optional). and, the annotations are always overriden by the xml configuration. thus, you can create different deployments with different the same compiled class files. you just need to override the annotation configuration with xml configuration (via ejb-jar.xml or whatever).Yes, we can do that. I've tested here, and it works. But, can we do better?
    The configuration via XML implies maintenance, and it's not good, because we have so many EJBs to maintain.
    And there is another problem... The EJB classes are in JARs, and these JARs are shared across the applications.
    Pretend that you have to maintain two versions of each EJB JAR. One with XML configured and other without. If we change one, the another must be changed too. How can it be productive?
    I have seen some EJB implementations that are more flexible with JNDI naming.
    See:
    - [http://openejb.apache.org/jndi-names.html|http://openejb.apache.org/jndi-names.html]
    - [http://fixunix.com/weblogic/221782-dynamic-jndi-name-weblogic-ejb-jar-xml.html|http://fixunix.com/weblogic/221782-dynamic-jndi-name-weblogic-ejb-jar-xml.html]
    Does it have a better solution in Glassfish?

  • Implementation Business Objects in CAF and developing WDJ application

    Hi Experts,
    I've read some articles about SAP CE CAF from SDN and I'm making some exercises according those guidence. Right now I have a problem and want to get suggestion from you. 
    As you know, from CE 7.1.1, the CAF support importing the Business Object through EJB model. So when develop a WDJ application using caf, we can using these procedures:
    (Implementing business objects in CAF and developing WebDynpro application)
    1) Create business objects or application service.
    2) Generate EJB Implementation class for business objects or app service.
    3) Create a WebDynpro application
    4) Importing the EJB model using the template.
    5) Create the UI for the app.
    My problem is: In the business object or application serivice, if the operation parameter type is integer, after we generate the EJB class, the type will changed to String. After the WDJ UI is created, the application test failed. The integer field could not passed to the BO successfully.
    If all the parameters type are string in the operation, there's no problem.  But when I use Integer or Date, the EJB class will change the type and the WDJ app will failed.
    I've also test the scenario in CE enviroment including 7.3 also failed. So I'm a little confused which step was wrong. I don't know whether you've seen such problem before, if you could give any suggestion, it'll be very appreciated!

    Hi, Winters.
       I got the same program, try to parse into the type which you want in AS operation.
    BR.
    Louis Huang.

  • JBO-25034 Rollback bc4J/ejb

    When I run the jclient application with a local connection it runs without the specified error.
    The error only occurs when I run it connecting to the oc4j/ejb.
    I investigated a bit and have find out when it was occuring :
    I have a JTable :
    private JTable tableUsrrolView = new JTable() {
    //Override to avoid redundant setValueAt, as Combobox binding will
    //set the value on selection rightaway.
    public void editingStopped(javax.swing.event.ChangeEvent e)
    // Take in the new value
    TableCellEditor editor = getCellEditor();
    if (editor instanceof DefaultCellEditor )
    Component cellEditor = ((DefaultCellEditor)editor).getComponent();
    if (cellEditor == jComboBox1)
    removeEditor();
    return;
    else if (cellEditor == jCheckBox1)
    removeEditor();
    return;
    super.editingStopped(e);
    //Swing JTable calls this method to get the editor for a cell.
    //If the editor is the installed combobox, set selected item in the
    //combobox to the value shown in that cell and return the combobox.
    public Component prepareEditor(TableCellEditor editor, int row, int column)
    if (editor instanceof DefaultCellEditor )
    Component cellEditor = ((DefaultCellEditor)editor).getComponent();
    if (cellEditor == jComboBox1)
    this.setRowSelectionInterval(row, row);
    jComboBox1.setSelectedItem(getValueAt(row, column));
    return jComboBox1;
    return super.prepareEditor(editor, row, column);
    //and in the jbInit I do the following :
    // (if I don't execute the second line then I don't get the error JBO-27019)
    tableUsrrolView.setModel(JUTableBinding.createAttributeListBinding(panelBinding, tableUsrrolView, "UsrrolView1", null, "UsrrolView1Iter", new String[] {"Appabbr", "Rolnam", "Roldsc", "Prcmrk"}));
    jComboBox1.setModel(JUComboBoxBinding.createLovBinding(panelBinding, jComboBox1, "UsrrolView1", null, "UsrrolView1Iter", new String[] {"Appabbr", "Rolnam"}, "ApprolView", new String[] {"Appabbr", "Rolnam"}, new String[] {"AppabbrRolnam", "Rolnam", "Roldsc", "Rolpwd", "Dftmrk"}, null, null));
    tableUsrrolView.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(jComboBox1));
    Is there maybe a workaround to this problem?
    I have tried allready the sync(Re: Problem in Failover of Physical standby database to primary but it didn't help me.

    Could you elaborate on this please. I was able to insert a new row in a JTable with combobox and the combobox was appropriately populated and allowed me to pick a relevant row.
    sorry my mistake, i used the workaround for bug 2394583 as explained in Re: problem: Objects become invalid so easily This code was still in the program and that was causing the problem. So I removed the code : panelBinding.findIterBinding("UsrrolView1Iter").rangeRefreshed(null); And now it works again. (the bug is also fixed:)
    Good. Atleast one issue resolved.
    (Shouldn't it also popup in the bc4j/ejb implementation? This should occur when you traverse out of the row in bc4j/ejb mode. Let us know the steps to reproduce this.
    Just take the example JTableCombo, deploy it as an ejb.
    run against the ejb.
    create a record
    only populate the lov
    click on another row.
    -> you are able to get the focus on that row(and change it).
    -> there is another strange behaviour now and that is when i change the lov of the existing row, the returning values are put in the new row...)
    So also in this example the client-server implementation works fine you get:(oracle.jbo.AttrValException) JBO-27014: Attribute DepartmentId in Mypackage1Module.DepartmentsView is required
    And the focus gets back to the record you created. Lets take this afresh. Now you have a ComboBox in a JTable.
    Bc4j/AM is deployed as ejb.
    You create a new row in the table, you drop the combobox down and select some (which I do not think is relevant here) and click on another row.
    ->That allows you to change focus to another row without any exception - the expected exception is AttrValException for a mandatory field.
    DId I miss something here?
    I tried this and was unable to reproduce this. When I focused on to another row without filling in the mandatory field, I did see the AttrValException. Also the focus went back to the new row.
    I've deployed my BC4J as EJB Session bean into OC4J/Embedded

  • EAR Structure for JSF project with EJBs

    Hi All,
    I have a JSF project which makes use of EJBs through EJB injection. The project basically consists of 3 components, which are independently archived (as JARs/WARs) and then added to an EAR. The components interact as follow:
    EJB JAR: contains the EJB code.
    Library JAR: contains the bean injection and common methods.
    JSF WAR: contains the JSF pages as well as a request (page) bean which inherits from a class in the library JAR (one containing a bean injection).
    The way I understand it, everything should work fine if I archive those components independently and then add them to an EAR (with the JSF WAR and EJB implementation JAR in the root, and the EJB interface JAR and the Library JAR in a /lib folder). If I do this, however, the bean injection fails and the bean proxy class is just null.
    I managed to get around this by adding the Library JAR to the JSF WAR's lib directory, in which case the bean injection works fine, but if I do it this way it means I'll have to add the Library JAR to all WAR components I have, which seems like needless duplication. Am I doing something wrong when creating the EAR or is this just the way it is? To make myself a bit more clear I include the EAR structures below:
    Not Working
    |_ EJB-impl.jar
    |_ JSF.war
    |_ lib
          |_ EJB-intf.jar
          |_ Library.jar
    Working
    |_ EJB-impl.jar
    |_ JSF.war
          |_ lib
                 |_ Library.jar
    |_ lib
          |_ EJB-intf.jarThank you,
    Ristretto

    Hi All,
    I have a JSF project which makes use of EJBs through EJB injection. The project basically consists of 3 components, which are independently archived (as JARs/WARs) and then added to an EAR. The components interact as follow:
    EJB JAR: contains the EJB code.
    Library JAR: contains the bean injection and common methods.
    JSF WAR: contains the JSF pages as well as a request (page) bean which inherits from a class in the library JAR (one containing a bean injection).
    The way I understand it, everything should work fine if I archive those components independently and then add them to an EAR (with the JSF WAR and EJB implementation JAR in the root, and the EJB interface JAR and the Library JAR in a /lib folder). If I do this, however, the bean injection fails and the bean proxy class is just null.
    I managed to get around this by adding the Library JAR to the JSF WAR's lib directory, in which case the bean injection works fine, but if I do it this way it means I'll have to add the Library JAR to all WAR components I have, which seems like needless duplication. Am I doing something wrong when creating the EAR or is this just the way it is? To make myself a bit more clear I include the EAR structures below:
    Not Working
    |_ EJB-impl.jar
    |_ JSF.war
    |_ lib
          |_ EJB-intf.jar
          |_ Library.jar
    Working
    |_ EJB-impl.jar
    |_ JSF.war
          |_ lib
                 |_ Library.jar
    |_ lib
          |_ EJB-intf.jarThank you,
    Ristretto

  • Referencing EJB from WAR frile

    Dear All,
    I have an deployed ejb, and want to reference this in a servlet within a WAR file.
    How do I do this without also placing the ejb
    classes within the WAR ! I realise that I could jar it all up into an EAR file
    but would rather keep the components seperate..
    Any help would be greatly appreciated
    Kind regards
    Tony

    The ideal way to reference an ejb from a war file is,
    1. Include the home, local, remote interfaces, Primary Key and
    Exception classes (if any) in a <ejb-name>-ejb-client.jar.
    2. Include the ejb implementation classes in <ejb-name>-ejb.jar and
    reference the <ejb-name>-ejb-client.jar in its manifest file.
    3. In war web.xml define an <ejb-ref> for each ejb that you need to
    reference
    4. Reference the ejb in your code using the ejb-ref name
    4. Include the <ejb-name>-ejb-client.jar in the war file.
    5. Include the war, <ejb-name>-ejb-client.jar, <ejb-name>-ejb.jar in
    an ear file and deploy.
    Dinesh Bhat
    "Arne Christian H rseth" <[email protected]> wrote in message news:<[email protected]>...
    What is an "expanded EAR file format"?
    Could someone please give a link to more information?
    Arne
    Robert Patrick <[email protected]> wrote:
    You can deploy in an "expanded EAR file format" which will allow you
    to
    work with the individual components but still have all the conveniences
    of an EAR.
    Tony May wrote:
    Dear All,
    I have an deployed ejb, and want to reference this in a servlet within
    a WAR file.
    How do I do this without also placing the ejb
    classes within the WAR ! I realise that I could jar it all up intoan EAR file
    but would rather keep the components seperate..
    Any help would be greatly appreciated
    Kind regards
    Tony

  • EJB Client JAR project produces empty JAR

    I've built an EJB module in WorkSpace Studio using the "WebLogic EJB Project" type, which is part of an EAR. I created a couple stateless session beans within this project, and then created an EJB Client JAR project using the "EJB Client JAR-->Create EJB Client Jar" menu item on the EJB project's hidden menu.
    According to the documentation, exporting an EAR file from the EAR project will cause the client JAR to be generated. I exported the EAR file from the EAR project, and sure enough, it included the client JAR (in /APP-INF/lib/). I extracted the client JAR from the EAR and opened it up to make sure it contained all of the client-side classes. I discovered that the client JAR was empty, the only contents being the MANIFEST.MF file. The interface classes were instead contained in the EJB JAR itself.
    How can I get the EJB client code to actually be included in the EJB client JAR?
    Thanks,
    Eric

    Well I have tried this with 6.1 and first
    1. One would expect the jar name to be the name in the ejb-jar.xml -
    ejb-client-jar section
    2. It outputs the file XXXEJB_Compiled.jar but it is same size as base jar
    this is 6.1 sp3
    whats up?
    Matthew Shinn wrote:
    Hi Sanjay,
    There is a bug in the documentation. The client-jar name should never be part of the
    ejbc command line. Step 3 below should be something like:
    java weblogic.ejbc xxxEJB.jar xxxEJB_Compiled.jar
    If you have an ejb-client-jar entry in your ejb-jar.xml, the client jar should be placed
    in the directory from which you ran ejbc. Make sure that the classes that you want to be
    put in the client-jar are not loaded from the classpath. This is very important or your
    client-jar won't be created correctly. The client-jar will only contain classes loaded
    from the input jar to ejbc. A bug for the incorrect documentation has already been filed
    and should be fixed soon.
    - Matt
    Sanjay Dwivedi wrote:
    Hi,
    I am trying to use the
    <ejb-client-jar> sub-element of the Sun's <ejb-jar> (EB 2.0 DTD) element of the
    ejb-jar.xml to generate the ejb-client.jar. I followed the step as documented
    by WebLogic but the files in EJB jars and ejb-client jars are identical. Here
    is what I am doing:
    1. Build the xxxEJB.jar for my EJB by running the WebLogic.ejbc on the standard
    EJB jar file.
    2. My ejb-jar.xml file has following line:
    <ejb-jar>
    <ejb-client-jar>xxxEJBClient.jar</ejb-client-jar>
    </ejb-jar>
    3. Next I used the following command to generate the ejb-client.jar file
    java weblogic.ejbc xxxEJB.jar xxxEJBClient.jar
    My xxxEJBClient.jar files consists of exactly same files (with same sizes) as
    the xxxEJB.jar file. Only difference is that the xxxEJB.jar file includes generated
    java source files for the bean implementation class and home/remote classes.
    In my opinion the xxxEJBClient.jar should not contain the EJB implementation classes.
    Any experience using the ejb-client-jar for generating the ejb-client.jar?
    Thanks,
    Sanjay.
    [att1.html]

Maybe you are looking for

  • PO split  in  sourcing cockpit   ?      :-(

    Hello my helpful friends.je.je I have quick question for the SRM gurus: In the sourcing cockpit, I selected 20 items (per example) and the application splits those items among 2 purchase orders. What is the reason of this behavior ?  I know that ebp

  • STO PROBLEM with MM DELIVERY

    Hi All, my scenario : Create STO with document type UB. Transfer goods by 351 w,r,t PO create excise invoice through J1IS w,r,t material doc. make goods receipt w.r.t. PO create part 1 at MIGO capture excise invoice w.r.t to PO while capturing i am g

  • Memory Leakage in AIR application

    Hi all,     I have a performance issue with air application. After launching the application if we keep the application idle means also the memory is creeping up.Why is it so? . How to solve this. Thanks & Regards, Jayagopal.

  • Cannot Start Tomcat 1.1.18

    HI I have install tomcat 1.1.18(light) edition. when I try start the tomcat, the window just pop up and disappear. The tomcat could not be start. After editing the startup.bat to view the error, below is the error. I am currently using JDK1.4. Does a

  • Import schema

    hello frnds, I have one tricky situtation kindly help me... i have 1 export backup of 1 schema suppose abc of 2 days ago and i have archive files ... I have used the above export dmp file and I have imported that schema to another database with same