Weblogic 10.3 POJO to EJB 3.0 call using JNDI

Hi all,
We are upgrading our applications from OAS to WL 10.3 and I am running into EJB lookup issues. Here is what I currently have in terms of setup.
One EAR file being deployed and there are two main jar files in it that communicate with each other. The first jar file contains POJOs and the second is an EJB jar file. One of the classes in the POJO jar file is doing a lookup for an EJB that can be found in the EJB jar file.
EAR file
---> POJO jar
---> EJB jar file
The EJB itself is declared as follows
@Stateless
public class MyBean implements MyBeanService
I added ejb-jar.xml and weblogic-ejb-jar.xml DDs to my ejb jar file and the bean reference shows up in the Weblogic console under the application after the deployment.
ejb-jar.xml
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" version="3.0">
<enterprise-beans>
          <session>
               <ejb-name>MyBean</ejb-name>
               <business-local>package.MyBeanService</business-local>
               <ejb-class>package.MyBean</ejb-class>
               <session-type>Stateless</session-type>
          </session>
     </enterprise-beans>
</ejb-jar>
weblogic-ejb-jar.xml
<weblogic-ejb-jar xmlns="http://www.bea.com/ns/weblogic/90"
xmlns:j2ee="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bea.com/ns/weblogic/90
http://www.bea.com/ns/weblogic/90/weblogic-ejb-jar.xsd">
     <weblogic-enterprise-bean>
          <ejb-name>MyBean</ejb-name>
          <jndi-name>ejb/MyBeanService</jndi-name>
     </weblogic-enterprise-bean>
</weblogic-ejb-jar>
My POJO call to JNDI is
InitialContext initialContext = new InitialContext();
Object found = initialContext.lookup("ejb/MyBeanService"); //---------------------FAILS ON THE LOOKUP ON THIS LINE
System.out.println(found.getClass());
Error
javax.naming.NameNotFoundException: Unable to resolve 'ejb.MyBeanService'. Resolved 'ejb'; remaining name 'MyBeanService'
Am I not using the right lookup name? Must I prefix the call with the name of my ejb jar name?
Thanks
S.

Hi,
I made the changes as requested and it looks as follows.
<weblogic-ejb-jar xmlns="http://www.bea.com/ns/weblogic/90"
xmlns:j2ee="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bea.com/ns/weblogic/90
http://www.bea.com/ns/weblogic/90/weblogic-ejb-jar.xsd">
     <weblogic-enterprise-bean>
          <ejb-name>MyBean</ejb-name>
          <stateless-session-descriptor>
                    <business-local>package.MyBeanService</business-local>
                    <jndi-name>ejb/MyBeanService</jndi-name>
               </business-interface-jndi-name-map>
          </stateless-session-descriptor>
     </weblogic-enterprise-bean>
</weblogic-ejb-jar>
I don't think <business-remote> works in <business-interface-jndi-name-map>.
VALIDATION PROBLEMS WERE FOUND problem: cvc-complex-type.2.4a: Expected element 'business-remote@http://xmlns.oracle.com/weblogic/weblogic-ejb-jar' instead of 'business-local@http://xmlns.oracle.com/weblogic/weblogic-ejb-jar' here in element business-interface-jndi-name-map@http://xmlns.oracle.com/weblogic/weblogic-ejb-jar:<null> problem: cvc-complex-type.2.4a: Expected element 'business-remote@http://xmlns.oracle.com/weblogic/weblogic-ejb-jar' instead of 'jndi-name@http://xmlns.oracle.com/weblogic/weblogic-ejb-jar' here in element business-interface-jndi-name-map@http://xmlns.oracle.com/weblogic/weblogic-ejb-jar:<null> problem: cvc-complex-type.2.4c: Expected element 'business-remote@http://xmlns.oracle.com/weblogic/weblogic-ejb-jar' before the end of the content in element business-interface-jndi-name-map@http://xmlns.oracle.com/weblogic/weblogic-ejb-jar:<null>
Anyhow if I use the <business-remote> I still get the following error when I call
Object found = initialContext.lookup("ejb/MyBeanService"); ----> ERROR
javax.naming.NameNotFoundException: Unable to resolve 'ejb.MyBeanService'. Resolved 'ejb'; remaining name 'MyBeanService'
Thanking you in advance.
S.

Similar Messages

  • POJOs or EJBs for worker classes spawned from Application Module?

    Hello,
    I'm running JDev 11.1.2.3.0.
    I need to create a couple of worker classes that will be instantiated from my Application Module. The first will invoke PL/SQL via createCallableStatement. The second sends a message to a jabber server.
    In the Java EE world, I'd do this with stateless EJBs and use the @PreConstruct and @PostDestroy annotations to control the lifecycle.
    What is the recommended approach with ADF when using Classes to make these calls from an Application Module? Should one use POJOs and rely on WebLogic to handle garbage collection, or should/can one use EJB 3.0 stateless session beans?
    Many thanks.
    Edited by: user576183 on May 11, 2013 9:24 AM

    Stateless session beans is the recommended approach with ADF BC too.
    http://docs.oracle.com/cd/E14571_01/web.1111/b31974/bcextservices.htm
    http://technology.amis.nl/2013/01/20/adf-interaction-with-business-service-an-ongoing-discussion/

  • WEbLogic 8.1 SP4 vs EJB 2.1

    Hello!
    Does WebLogic 8.1 SP4 support EJB 2.1?
    I have gone thru the documentation, but nowhere it is written that it supports.
    Reg,
    Chetan Parekh

    No WLS 8.1 sp4 does not support EJB 2.1
    - Ramkumar

  • Does BEAs WebLogic Server 8.x  support EJB 2.1?

    Does BEAs WebLogic Server 8.x support EJB 2.1? When it is Support?

    I know weblogic 8.1 is EJB 2.0
    "John Naranjo" <[email protected]> wrote:
    >
    Does BEAs WebLogic Server 8.x support EJB 2.1? When it is Support?

  • EJB 3.0 local interface JNDI

    Hello
    I found some information that will probably help a lot of people having trouble with local interface not referenced in JNDI.
    You need to delacre each local interface in the web.xml.
         <ejb-local-ref>
              <ejb-ref-name>MappedNameInYourEJB</ejb-ref-name>
              <ejb-ref-type>Session</ejb-ref-type>
    <local> yourLocalInterface
              </local>
         </ejb-local-ref>
    The weird thing about this is you don't need to do it when you use remote interface!! I would have thought Weblogic was smart enough to put your EJB in the JNDI when you declare @local on your interface!!
    Am I wrong with something here?
    When I read the EJB spec, it says you don't need to declare your EJB anywhere when you use annotation....
    If someone have an explanation I would be very happy to read about it!!!!
    Tanx

    Hi,
    In our current impl, we don't bind local business interface impl onto global jndi, this is because adding global JNDI binding for local EJB means every local business interface object must be bound into global JNDI, which will give rise to strange errors when accessing remotely or in different application context.
    On the other hand, you needn't add each local interface in the web.xml, you can use annotation through EJB link, which is the suggested way to use EJB local reference, for example:
    @Stateful(name="AccountManagementBean")
    public class AccountManagementBean
    @EJB(
    name="PersonBeanRef",
    beanName="PersonBean"
    Person person;
    @Stateless(name="PersonBean")
    public class PersonBean implements Person {
    In this example, AccountManagementBean has a local reference of PersonBean, the key is you should use beanName in @EJB, whose value is the ejb name of referenced EJB.

  • EJB-RMI server hang using IIOP

    I have a java program that makes an EJB call using IIOP to an EJB hosted on a WebLogic server. The code is known to work in several environments, however when I deploy this to my production environment it hangs and appears to "lose" the reply from Weblogic.
    Essentially, then the program makes an attempt to obtain the initial context, it sends a request to the Weblogic server, but then hangs.
    Snooping the network shows that the request has reached weblogic and that weblogic has sent a sensible reply (which the client acknowledges).
    From trussing the process I can see the program send the request (268 bytes of data written to a socket that matches with what I see in snoop), but the program then seems to be looping in ioctl and pollsys, I never see it read any data.
    The last few lines of the stack trace show the process in an Object.wait (see code snippets).
    The last call my code makes is to construct a javax/naming/InitialContext (see "context = new InitialContext(props);" in Code snippet)
    Doing a "CTRL+\" does not show any deadlocked threads in the JVM.
    Code Snippets:
    The method in the code that it crashes in is:
    * Helper method to obtain an initial context
    private static void obtainInitialContext(boolean reload)
    throws IOException
    if (context == null || reload)
    logger.info("Creating a new initial context as it either doesn't exist or needs reloading");
    final String PROVIDER_URL_KEY = "props.orange.ProviderUrlKey";
    final String CONTEXT_FACTORY_KEY = "props.orange.ContextFactoryKey";
    try
    String providerURL = ConfigurationManager.getConfigValue(PROVIDER_URL_KEY);
    String contextFactory = ConfigurationManager.getConfigValue(CONTEXT_FACTORY_KEY);
    if (providerURL == null)
    logger.error("Could not find the property: " + PROVIDER_URL_KEY);
    throw new IOException("Could not find the property: " + PROVIDER_URL_KEY);
    if (contextFactory == null)
    logger.error("Could not find the property: " + CONTEXT_FACTORY_KEY);
    throw new IOException("Could not find the property: " + CONTEXT_FACTORY_KEY);
    Hashtable props = new Hashtable();
    props.put(Context.PROVIDER_URL, providerURL);
    props.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory);
    context = new InitialContext(props);
    catch (Exception e)
    logger.error("Unable to obtain initial context: ", e);
    throw new IOException("Unable to obtain initial context: " + e);
    Stack trace:
    ff2c1bbc lwp_cond_wait (3a8a0, 3a888, 0, 0)
    feab4f98 __1cNObjectMonitorEwait6MxipnGThread__v_ (241d98, 94c8, 8c00, fefc4000, 39c08, 241db8) + 59c
    feab61a8 __1cSObjectSynchronizerEwait6FnGHandle_xpnGThread__v_ (ffbfa758, 8784, 0, 39c08, 8400, fefc4000) + e8
    feab5e58 JVM_MonitorWait (0, 3a204, 39c08, ff018ffc, 0, 1) + 31c
    f900c280 * java/lang/Object.wait(J)V+0
    f900c224 * java/lang/Object.wait(J)V+0
    f9005764 * java/lang/Object.wait()V+2 (line 474)
    f9005764 * com/sun/corba/se/impl/transport/CorbaResponseWaitingRoomImpl.waitForResponse(Lcom/sun/corba/se/pept/protocol/MessageMediator;)Lcom/sun/corba/se/pept/encoding/InputObject;+238 (line 140)

    prabha kancharla <> writes:
    What versions of each are you using?
    andy
    I have a java program that makes an EJB call using IIOP to an EJB hosted on a WebLogic server. The code is known to work in several environments, however when I deploy this to my production environment it hangs and appears to "lose" the reply from Weblogic.
    Essentially, then the program makes an attempt to obtain the initial context, it sends a request to the Weblogic server, but then hangs.
    Snooping the network shows that the request has reached weblogic and that weblogic has sent a sensible reply (which the client acknowledges).
    From trussing the process I can see the program send the request (268 bytes of data written to a socket that matches with what I see in snoop), but the program then seems to be looping in ioctl and pollsys, I never see it read any data.
    The last few lines of the stack trace show the process in an Object.wait (see code snippets).
    The last call my code makes is to construct a javax/naming/InitialContext (see "context = new InitialContext(props);" in Code snippet)
    Doing a "CTRL+\" does not show any deadlocked threads in the JVM.
    Code Snippets:
    The method in the code that it crashes in is:
    * Helper method to obtain an initial context
    private static void obtainInitialContext(boolean reload)
    throws IOException
    if (context == null || reload)
    logger.info("Creating a new initial context as it either doesn't exist or needs reloading");
    final String PROVIDER_URL_KEY = "props.orange.ProviderUrlKey";
    final String CONTEXT_FACTORY_KEY = "props.orange.ContextFactoryKey";
    try
    String providerURL = ConfigurationManager.getConfigValue(PROVIDER_URL_KEY);
    String contextFactory = ConfigurationManager.getConfigValue(CONTEXT_FACTORY_KEY);
    if (providerURL == null)
    logger.error("Could not find the property: " + PROVIDER_URL_KEY);
    throw new IOException("Could not find the property: " + PROVIDER_URL_KEY);
    if (contextFactory == null)
    logger.error("Could not find the property: " + CONTEXT_FACTORY_KEY);
    throw new IOException("Could not find the property: " + CONTEXT_FACTORY_KEY);
    Hashtable props = new Hashtable();
    props.put(Context.PROVIDER_URL, providerURL);
    props.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory);
    context = new InitialContext(props);
    catch (Exception e)
    logger.error("Unable to obtain initial context: ", e);
    throw new IOException("Unable to obtain initial context: " + e);
    Stack trace:
    ff2c1bbc lwp_cond_wait (3a8a0, 3a888, 0, 0)
    feab4f98 __1cNObjectMonitorEwait6MxipnGThread__v_ (241d98, 94c8, 8c00, fefc4000, 39c08, 241db8) + 59c
    feab61a8 __1cSObjectSynchronizerEwait6FnGHandle_xpnGThread__v_ (ffbfa758, 8784, 0, 39c08, 8400, fefc4000) + e8
    feab5e58 JVM_MonitorWait (0, 3a204, 39c08, ff018ffc, 0, 1) + 31c
    f900c280 * java/lang/Object.wait(J)V+0
    f900c224 * java/lang/Object.wait(J)V+0
    f9005764 * java/lang/Object.wait()V+2 (line 474)
    f9005764 * com/sun/corba/se/impl/transport/CorbaResponseWaitingRoomImpl.waitForResponse(Lcom/sun/corba/se/pept/protocol/MessageMediator;)Lcom/sun/corba/se/pept/encoding/InputObject;+238 (line 140)

  • Unable to bind EJB Home Interface to the JNDI name

    Why do I get this error?? What is the jndi-name in weblogic-ejb-jar.xml
    Unable to deploy EJB: OrganizationEJB from sempire_bc.jar:
    Unable to bind EJB Home Interface to the JNDI name:
    com.sempire.builder.business
    _component.Organization. The error was:
    javax.naming.NameAlreadyBoundException: Organization is already bound;
    remaining
    name 'com.sempire.builder.business_component'
    <<no stack trace available>>

    Slava,
    In case I change the name of the jndi name to a unique name. I still get the same
    problem. I checked for multiple occurences, but there aren't any.
    My web.xml file is:
    <ejb-local-ref>
    <description>
    Reference EJB resources in Weblogic Resources
    </description>
    <ejb-ref-name>GangsterEJB</ejb-ref-name>
    <ejb-ref-type>Entity</ejb-ref-type>
    <local-home>com.sempire.builder.business_component.GangsterHome</local-home>
    <local>com.sempire.builder.business_component.Gangster</local>
    </ejb-local-ref>
    My weblogic-ejb-jar.xml file is:
    <weblogic-enterprise-bean>
    <ejb-name>GangsterEJB</ejb-name>
    <entity-descriptor>
    <persistence>
    <persistence-type>
    <type-identifier>WebLogic_CMP_RDBMS</type-identifier>
    <type-version>6.0</type-version>
    <type-storage>META-INF/weblogic-cmp-rdbms-jar.xml</type-storage>
    </persistence-type>
    <persistence-use>
    <type-identifier>WebLogic_CMP_RDBMS</type-identifier>
    <type-version>6.0</type-version>
    </persistence-use>
    </persistence>
    </entity-descriptor>
    <reference-descriptor>
    <resource-description>
    <res-ref-name>jdbc/GangsterDB</res-ref-name>
    <jndi-name>oraclePool</jndi-name>
    </resource-description>
    </reference-descriptor>
    <local-jndi-name>Gangster_test</local-jndi-name>
    </weblogic-enterprise-bean>
    I do not get the problem.
    Thank you
    Ronak Parekh
    "Slava Imeshev" <[email protected]> wrote:
    Hi Ronak,
    This exception means that you already have a bean
    with the same JNDI name. Search your weblogic-ejb-jar.xml files
    for multiple occurrences of the name and fix the problem.
    Regards,
    Slava Imeshev
    "Ronak Parekh" <[email protected]> wrote in message
    news:[email protected]...
    Why do I get this error?? What is the jndi-name in weblogic-ejb-jar.xml
    Unable to deploy EJB: OrganizationEJB from sempire_bc.jar:
    Unable to bind EJB Home Interface to the JNDI name:
    com.sempire.builder.business
    _component.Organization. The error was:
    javax.naming.NameAlreadyBoundException: Organization is already bound;
    remaining
    name 'com.sempire.builder.business_component'
    <<no stack trace available>>

  • Using jndi.properties with weblogic 6.1

    Apologies if this is a basic question - I am new to Weblogic.
    I have successfully got a test EJB working with Weblogic 6.1 using a properties object to set up my JNDI InitialContext.
    In the weblogic examples I've downloaded it says you can also use a jndi.properties file to do this. I have set up a jndi.properties file, which is in the classpath for my class calling the EJB. But when I do my jndi .lookup("ejbname") I get the error:
    javax.naming.CommunicationException: Can't find SerialContextProvider
    The weblogic documentation at:
    http://e-docs.bea.com/wls/docs61///rmi_iiop/API_rmi_iiop.html
    refers to using jndi.properties and says to look at:
    http://edocs.bea.com/wls/docs61/jndi/jndi.html
    But at this page there is no mention of the jndi.properties method.
    I'd be grateful for any suggestions - in particular whether it is possible to use this method of configuring the JNDI setup.
    I'm running wlserver6.1 on a Windows 2000 PC, using JDK 1.3.1
    My jndi.properties file looks as follows:
    java.naming.property.names=java.naming.factory.initial,java.naming.provider.url
    java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
    java.naming.provider.url=t3://localhost:7001

    It is not WebLogic-specific. See
    http://java.sun.com/j2se/1.3/docs/api/javax/naming/InitialContext.html
    Alison Tunley <[email protected]> wrote:
    Apologies if this is a basic question - I am new to Weblogic.
    I have successfully got a test EJB working with Weblogic 6.1 using a properties object to set up my JNDI InitialContext.
    In the weblogic examples I've downloaded it says you can also use a jndi.properties file to do this. I have set up a jndi.properties file, which is in the classpath for my class calling the EJB. But when I do my jndi .lookup("ejbname") I get the error:
    javax.naming.CommunicationException: Can't find SerialContextProvider
    The weblogic documentation at:
    http://e-docs.bea.com/wls/docs61///rmi_iiop/API_rmi_iiop.html
    refers to using jndi.properties and says to look at:
    http://edocs.bea.com/wls/docs61/jndi/jndi.html
    But at this page there is no mention of the jndi.properties method.
    I'd be grateful for any suggestions - in particular whether it is possible to use this method of configuring the JNDI setup.
    I'm running wlserver6.1 on a Windows 2000 PC, using JDK 1.3.1
    My jndi.properties file looks as follows:
    java.naming.property.names=java.naming.factory.initial,java.naming.provider.url
    java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
    java.naming.provider.url=t3://localhost:7001--
    Dimitri

  • How can I access to an EJB from a JSP, using a taglib?

    I'm trying to access to an EJB from a JSP using a taglib,
              and I get the example in
              http://java.sun.com/j2ee/j2sdkee/techdocs/guides/ejb/html/Advanced5.html.
              But I colund't run this example because in the weblogic Log appears many
              errors when I run the JSP.
              Can you help me?
              

    Backing files is an option. If you need to do it from the controller, you
    could use the Forward object. The forward object constructor can take a URL
    object as a parameter. This should do the trick.
    Regards,
    Kunal
    "Panji Aryaputra" <[email protected]> wrote in message
    news:[email protected]..
    Hi, you have to use backing file to get what you want. In my case, I am
    using a page backing file. Perhaps a portlet backing file can do thatalso.
    Cmiiw, the redirect header makes the page redirected only if the httpheader
    has not been sent to client. In your case, the header has been sent (i.e.
    the portal header.jsp has been displayed, etc). So the header need to be
    sent before anything else sent to client browser. This is where thebacking
    file comes handy.
    hth
    panji.a
    "A Hagen" <[email protected]> wrote in message
    news:[email protected]..
    I'm using Bea Workshop 8.1 and trying to perform a redirect from inside
    a
    portlet
    using HTTPServletResponse.sendRedirect(String url)... but nothing
    happens
    I tryed the same trick with a simple JSP, and that's ok, but portal
    pages
    obviously
    catch the redirect somehow.
    Please could you tell the correct way of redirecting the whole browser
    to
    another
    page from inside portlets?
    Thanks!!!

  • How to use jndi datasource on Weblogic instead of adding a DB data source

    Hi All,
    version: 11.1.1.4
    I am trying to figure out how in my ADF applications I can use an existing jndi datasource out on our weblogic servers instead of having to bury the Database db source in my adf applications. Like SOA I would like to reference the DB directly during design so I can pull in entities and build view objects, but when I deploy I want it to reference the jndi datasource out on the weblogic server.
    Is this possible? If so I am not sure how to configure it like I would a DB adapter in SOA.
    As always appreciate the info.
    Thanks,
    S

    If you use ADF in the model layer (application modules) you can configure them to use JNDI Datasources. Just right click on the application module and select 'Configurations...'. In the next dialog you see all the configurations currently available (one named xxxxxlocal and one named xxxxxshared at least). Select the local and hit the edit button. This open the DB connect dialog where you can change the connection from JDBC URL to JDBC Datasource (JNDI). Save your work and when you now start the app it will use the JNDI name.
    Timo

  • Weblogic 10.3.0 issues with remote object calls.

    All:
    I was wondering if anyone has experienced any issues with Weblogic 10.3.0 dropping initial remote object calls over AMF Secure Channel. Here are the issues we are experiencing.
    1.     FLEX applications fail consistently on the first remote object call made across the AMF Secure Channel. Resulting in the request not returning from the application server; which has had varying affects on the different applications including missing data, application freeze and general degrading of the user experience.
    2.     FLEX applications require a browser/application refresh once the application has been inactive for a certain period of time. In our experiences the behavior occurs after 30 minutes of inactivity.
    I've deployed this same code to Weblogic 10.3.3 and the behaviors go away. Are there any patches to 10.3.0 that might take care of this issue that we are not aware of?
    Thanks for you help,
    Mike

    Hello,
    I found the problem. But I needed change the target of all my datasources until discover that one of my datasource didn´t answer and no errors was trigged.
    My server was waiting this datasource, and not get started.

  • PI 7.11 JMS adapter using JNDI weblogic server issue

    Hi SAP experts,
    I have a scenario to integrate to a application using JMS adapters. we use SAP PI 7.11 version.
    We have deployed JMS drivers successfully and We face issue here to connect to weblogic server
    We are using JMS adapter using JNDI to connect to weblogic server version 10.3.
    Can anyone help with the exact format to be used in JMS properties table and additional parameters table in JMS communication channel. Your quick help will be appreciated.
    A channel error occurred. The detailed error (if any) : com.sap.aii.adapter.jms.api.connector.ConnectorException: Error looking up destination: AccrualDetailsQueue for profile:  ConnectionProfile of channel: CC_SND_JMS on node: 3010950 having object id: 673696a9fe8c39fdab32213f0930afb3: javax.naming.NameNotFoundException: Unable to resolve 'AccrualDetailsQueue'. Resolved ''<br> at com.sap.aii.adapter.jms.core.connector.JndiConnectorImpl.createDestination(JndiConnectorImpl.java:168)<br

    Hi Padmini,
    Refer to the following link:
    http://help.sap.com/saphelp_nw04/helpdata/en/24/4cad3baabd4737bab64d0201bc0c6c/content.htm
    It was very helpful to me, for configuring the additional parameters in the communication Channel JMS.
    I leave you some screenshots of the settings that I did.
    I seize the opportunity to ask you, where do I can get the drivers (.Jar) for Weblogic?
    Regards.
    Rodrigo.

  • EJB called via JNDI in a Repository Service :: ClassCastException

    Hi SDN,
    I've got a problem in calling an EJB from a Repository Service...
    Here the steps I've follow:
      -  An EJB has been created with some Business Methods in it; it has been packaged in an EAR and deployed;
      -  This EJB is looked up succesfully via JNDI in a WDJ application and also in an Abstract Portal Component; I use the following guides:
    [Accessing EJB Apps using JNDI|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/0736159e-0301-0010- 9ea4-c63d83d0797b?QuickLink=index&overridelayout=true]
    [Referencing an EJB in an Abstract Portal Component|http://wiki.sdn.sap.com/wiki/display/HOME/ConnectingEJBUsing ExternalJars]
      -  A Repository Service has been created and registered on "CREATE_CHILD_TEMPLATE" ResourceEvent; I can see from logs that this service works correctly;
       -  I've copied in the PAR lib and private/lib folders two jars (ejb20.jar and the JAR created building the EJB) and they are added to the build path;
      -  If I try to look up the EJB via JNDI in the received service method, I get a ClassCastException...
    Here some code:
    try {
         //I use System.err to see log in the Default Trace
         System.err.println("Initialize EJB");
         //TestJNDIHome class seems to be visible at runtime, following instruction does not throw any exception
         System.err.println("ToString TestJNDIHome: " + TestJNDIHome.class.toString());
         //EJB and PAR are on the same J2EE engine, so no InitialContext parameters, I'm right?
         InitialContext context = new InitialContext();
         Object jndiobj = context.lookup("altevie.com/testear/TestJNDIBean");
         System.err.println("Classe oggetto recuperato da lookup: " + jndiobj.getClass());
         TestJNDIHome home = (TestJNDIHome) javax.rmi.PortableRemoteObject.narrow(jndiobj, TestJNDIHome.class);
         testJNDI = home.create();
    } catch (NamingException ex) {
         System.err.println("NamingException :: " + ex.getLocalizedMessage());
    } catch (RemoteException ex) {
         System.err.println("RemoteException :: " + ex.getLocalizedMessage());
    } catch (CreateException ex) {
         System.err.println("CreateException :: " + ex.getLocalizedMessage());          
    Here the portalapp.xml (in the same PAR there are two objects, the Repository Service and an Abstract Portal Component, but I've got the same problem also removing the Abstract Portal Component...):
    <application>
      <application-config>
        <property name="com.sap.engine.interfaces.cross.ObjectReferenceImpl" value="SAPJ2EE::altevie.com/testEAR"/>
        <property name="SharingReference" value="usermanagement, knowledgemanagement, landscape, htmlb, exportalJCOclient, exportal"/>
        <property name="PrivateSharingReference" value="SAPJ2EE::altevie.com/testEAR"/>
      </application-config>
      <components>
        <component name="TestJSP">
          <component-config>
            <property name="ClassName" value="com.comer.eps.epcomp.TestJSP"/>
          </component-config>
          <component-profile/>
        </component>
      </components>
      <services>
        <service name="RFServiceWrapper">
          <service-config>
            <property name="className" value="com.sap.netweaver.rf.wrapper.RFServiceWrapper"/>
            <property name="startup" value="true"/>
          </service-config>
        </service>
      </services>
    </application>
    javax.rmi.PortableRemoteObject.narrow method call throws a ClassCastException...
    From the previous println I can see the lookup method returns a com.sap.engine.interfaces.cross.ObjectReferenceImpl object, I do not know if it is correct...
    I've tried to lookup the Local (localejbs/altevie.com/testear/TestJNDIBean) and Remote (altevie.com/testear/TestJNDIBean) JNDI Bean name, but I get the same error...
    I'm sure the JNDI name is correct (it works with WDJ and Abstract Portal Component... I've also tested via LOOKUP command using telnet to connect to J2EE AS and I've checked JNDI Registry and EJB Container services in Visual Admin)...
    Here the stack trace of the error:
    java.lang.ClassCastException: com.comer.eps.ejb.AccessiEJBHome
         at com.sap.engine.services.cross.PortableRemoteObjectContainer.narrow(PortableRemoteObjectContainer.java:179)
         at com.sap.engine.system.PortableRemoteObjectProxy.narrow(PortableRemoteObjectProxy.java:24)
         at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
         at com.comer.eps.repsrv.onsave.RipubblicaByDE.initializeEJB(RipubblicaByDE.java:145)
    Can you help me? Why JNDI lookup works in an Abstract Portal Application and doesn't in a Repository Service (same code...)?
    Thank you so much and best regards,
    Manuel
    Text Formatted: Manuel Xiccato on Sep 27, 2011 12:29 PM

    Hi SDN,
    I've got a problem in calling an EJB from a Repository Service...
    Here the steps I've follow:
      -  An EJB has been created with some Business Methods in it; it has been packaged in an EAR and deployed;
      -  This EJB is looked up succesfully via JNDI in a WDJ application and also in an Abstract Portal Component; I use the following guides:
    [Accessing EJB Apps using JNDI|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/0736159e-0301-0010- 9ea4-c63d83d0797b?QuickLink=index&overridelayout=true]
    [Referencing an EJB in an Abstract Portal Component|http://wiki.sdn.sap.com/wiki/display/HOME/ConnectingEJBUsing ExternalJars]
      -  A Repository Service has been created and registered on "CREATE_CHILD_TEMPLATE" ResourceEvent; I can see from logs that this service works correctly;
       -  I've copied in the PAR lib and private/lib folders two jars (ejb20.jar and the JAR created building the EJB) and they are added to the build path;
      -  If I try to look up the EJB via JNDI in the received service method, I get a ClassCastException...
    Here some code:
    try {
         //I use System.err to see log in the Default Trace
         System.err.println("Initialize EJB");
         //TestJNDIHome class seems to be visible at runtime, following instruction does not throw any exception
         System.err.println("ToString TestJNDIHome: " + TestJNDIHome.class.toString());
         //EJB and PAR are on the same J2EE engine, so no InitialContext parameters, I'm right?
         InitialContext context = new InitialContext();
         Object jndiobj = context.lookup("altevie.com/testear/TestJNDIBean");
         System.err.println("Classe oggetto recuperato da lookup: " + jndiobj.getClass());
         TestJNDIHome home = (TestJNDIHome) javax.rmi.PortableRemoteObject.narrow(jndiobj, TestJNDIHome.class);
         testJNDI = home.create();
    } catch (NamingException ex) {
         System.err.println("NamingException :: " + ex.getLocalizedMessage());
    } catch (RemoteException ex) {
         System.err.println("RemoteException :: " + ex.getLocalizedMessage());
    } catch (CreateException ex) {
         System.err.println("CreateException :: " + ex.getLocalizedMessage());          
    Here the portalapp.xml (in the same PAR there are two objects, the Repository Service and an Abstract Portal Component, but I've got the same problem also removing the Abstract Portal Component...):
    <application>
      <application-config>
        <property name="com.sap.engine.interfaces.cross.ObjectReferenceImpl" value="SAPJ2EE::altevie.com/testEAR"/>
        <property name="SharingReference" value="usermanagement, knowledgemanagement, landscape, htmlb, exportalJCOclient, exportal"/>
        <property name="PrivateSharingReference" value="SAPJ2EE::altevie.com/testEAR"/>
      </application-config>
      <components>
        <component name="TestJSP">
          <component-config>
            <property name="ClassName" value="com.comer.eps.epcomp.TestJSP"/>
          </component-config>
          <component-profile/>
        </component>
      </components>
      <services>
        <service name="RFServiceWrapper">
          <service-config>
            <property name="className" value="com.sap.netweaver.rf.wrapper.RFServiceWrapper"/>
            <property name="startup" value="true"/>
          </service-config>
        </service>
      </services>
    </application>
    javax.rmi.PortableRemoteObject.narrow method call throws a ClassCastException...
    From the previous println I can see the lookup method returns a com.sap.engine.interfaces.cross.ObjectReferenceImpl object, I do not know if it is correct...
    I've tried to lookup the Local (localejbs/altevie.com/testear/TestJNDIBean) and Remote (altevie.com/testear/TestJNDIBean) JNDI Bean name, but I get the same error...
    I'm sure the JNDI name is correct (it works with WDJ and Abstract Portal Component... I've also tested via LOOKUP command using telnet to connect to J2EE AS and I've checked JNDI Registry and EJB Container services in Visual Admin)...
    Here the stack trace of the error:
    java.lang.ClassCastException: com.comer.eps.ejb.AccessiEJBHome
         at com.sap.engine.services.cross.PortableRemoteObjectContainer.narrow(PortableRemoteObjectContainer.java:179)
         at com.sap.engine.system.PortableRemoteObjectProxy.narrow(PortableRemoteObjectProxy.java:24)
         at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
         at com.comer.eps.repsrv.onsave.RipubblicaByDE.initializeEJB(RipubblicaByDE.java:145)
    Can you help me? Why JNDI lookup works in an Abstract Portal Application and doesn't in a Repository Service (same code...)?
    Thank you so much and best regards,
    Manuel
    Text Formatted: Manuel Xiccato on Sep 27, 2011 12:29 PM

  • Do i have to use JNDI with EJBS?

    Hi
    I want to use JNDI to lookup a system which i will send messages to using JMS. I would like to have some java classes on Tomcat to do the job. But...whenever i hear about JNDI it is always in relation to EJBs. Can i only use JNDI with EJBS?
    If i can use JNDI is there anything important i need to know about.
    Thanks in advance!
    San H.

    You can definitely use JNDI outside of EJB's - in particular, it's a great interface for dealing with LDAP servers, even securely, and can also be used for DNS interfacing, COS, RMI registries, etc.
    While JNDI was chosen as the method by which J2EE components can locate other components in a distributed environment, it's by no means limited to that task :) It's a wonderful API, and in terms of things you need to know, most everything is covered fairly well at the JNDI tutorial in the various trails that are mapped out there.
    http://java.sun.com/products/jndi/tutorial/
    Good luck!
    James
    James Manning | Principal Engineer
    Porivo Technologies, Inc.
    919.806.0566 | [email protected]
    http://www.porivo.com/
    Measuring end-to-end Web performance.
    Register for a FREE Performance appraisal:
    http://www.porivo.com/peerReview/eval.html

  • Weblogic Server 9.2 by default allows anonymous modification to JNDI tree

    We found out that Weblogic Server 9.2 by default allows anonymous modification to JNDI tree.
    This is definitely a big security hole. But Oracle support said this is Work By Design conforming to JNDI Specification.
    So we thought this might be overlooked by lots of Weblogic Administrators and would like to share this finding.
    We were told that the solution is to create a policy for jndi.
    We are still checking if there are other resources that are open to anonymous access.
    Hope this will help.
    thanks!

    Yes the only way to secure the JNDI is applying the policies..
    But the catch is, even if your code is executing within the container, it has to pass the credentials..
    Dont knw wether its a good behavior or bad, but that is how it works :)

Maybe you are looking for