Topic
  • 7 replies
  • Latest Post - ‏2013-09-26T10:13:16Z by javapapo
javapapo
javapapo
6 Posts

Pinned topic Websphere 8.5.5 does not resolve / bind to java:module java:global or java:app

‏2013-07-04T10:46:04Z |

Hi I have posted the very same question @StackOverflow. It seems that using custom (simple) JNDI code I can not locate EJB references that according to the server are properly deployed. My lookup code works only using the ejblocal Websphere name space but when I try to use the EJB 3.1 portable JNDI features I fail


InitialContext c = new InitialContext();
//works - but it is Websphere specific
c.lookup("ejblocal:com.MyService"); 

//DOES NOT WORK - 
c.lookup("java:global/myAppEar/myModuleJar/MyServiceImpl!com.MyService");  
//DOES NOT WORK
c.lookup("java:module/MyServiceImpl!com.MyService"); 
//DOES NOT WORK
c.lookup("java:module/MyServiceImpl"); 


MyService  (plain java interface)

@Local(MyService.class)
MyServiceImpl implements MyService

in the server logs I can see that the server is reporting that is binding the ejbs either on its ejblocal space or in java:global . I could find a related bug on Websphere 8.0 but I suppose according to their documentation, it is resolved in version 8.5.5.

 

My application is packaged as an EAR with different ejb-modules, that are properly defined in the application.xml. As already elaborated the server during app start, reports that is binding my session beans

[4/7/2013 9:19:59:099 EEST] 00000036 AbstractEJBRu I   CNTR0167I: The server is binding the comXXXXX.CyberReceiptService interface of the CyberReceiptServiceImpl enterprise bean in the xxxx-main.jar module of the xxxxxxEAR application.  The binding location is: java:global/xxxxxEAR/xxxx-main/CyberReceiptServiceImpl!com.xxxxx.CyberReceiptService

 

Do i need to specify something during the initial context object creating, do I need to go through some specific websphere configuration or is it a bug?

 

Thanks

  • bkail
    bkail
    23 Posts

    Re: Websphere 8.5.5 does not resolve / bind to java:module java:global or java:app

    ‏2013-07-04T16:51:51Z  

    The java:global lookup looks like the module name is wrong: the CNTR0167I says "xxxx-main", but the lookup string says "myModuleJar".  Does the lookup string match the CNTR0167I string exactly?

    What code is attempting to perform the java:module lookup?  If it's a servlet, then java:module lookup won't work unless the EJB is included in the WAR itself, and based on the CNTR0167I, the EJB is in an EJB .jar file rather than a .war.

  • javapapo
    javapapo
    6 Posts

    Re: Websphere 8.5.5 does not resolve / bind to java:module java:global or java:app

    ‏2013-07-04T16:57:55Z  
    • bkail
    • ‏2013-07-04T16:51:51Z

    The java:global lookup looks like the module name is wrong: the CNTR0167I says "xxxx-main", but the lookup string says "myModuleJar".  Does the lookup string match the CNTR0167I string exactly?

    What code is attempting to perform the java:module lookup?  If it's a servlet, then java:module lookup won't work unless the EJB is included in the WAR itself, and based on the CNTR0167I, the EJB is in an EJB .jar file rather than a .war.

    Hello many thanks for the reply.

     

    1. Actually the lookup names are correct I just, removed the actual code names from the post, sorry for thatm
    2. Ok maybe that is the source of the problem, I am actually trying to execute this code from a Java POJO, eventually a simple ServiceLocator. The class is like an old school static factory/lookup engine. I am packaging it within an ejb-jar  module. Eventually most of the EJBs trying to locate, reside in the same ejb-jar. I am having lots of legacy code that do not have context yet, so i need to programmatically look up for ejb references within the different modules of my ear.

    Thanks again.

  • bkail
    bkail
    23 Posts

    Re: Websphere 8.5.5 does not resolve / bind to java:module java:global or java:app

    ‏2013-07-04T17:01:52Z  
    • javapapo
    • ‏2013-07-04T16:57:55Z

    Hello many thanks for the reply.

     

    1. Actually the lookup names are correct I just, removed the actual code names from the post, sorry for thatm
    2. Ok maybe that is the source of the problem, I am actually trying to execute this code from a Java POJO, eventually a simple ServiceLocator. The class is like an old school static factory/lookup engine. I am packaging it within an ejb-jar  module. Eventually most of the EJBs trying to locate, reside in the same ejb-jar. I am having lots of legacy code that do not have context yet, so i need to programmatically look up for ejb references within the different modules of my ear.

    Thanks again.

    Can you attach the full exception message and stack trace?  Those might give a clue to the cause of the problem.  Have you tried printing the values of java:app/AppName and java:module/ModuleName?  Those might also give a clue to the context of your calling code.

    For lookups within the context of the same application as the EJB (but not necessarily within that EJB module), java:app is the best choice, but if java:global lookups aren't working, there is a more fundamental problem.

  • javapapo
    javapapo
    6 Posts

    Re: Websphere 8.5.5 does not resolve / bind to java:module java:global or java:app

    ‏2013-07-04T17:08:55Z  
    • bkail
    • ‏2013-07-04T17:01:52Z

    Can you attach the full exception message and stack trace?  Those might give a clue to the cause of the problem.  Have you tried printing the values of java:app/AppName and java:module/ModuleName?  Those might also give a clue to the context of your calling code.

    For lookups within the context of the same application as the EJB (but not necessarily within that EJB module), java:app is the best choice, but if java:global lookups aren't working, there is a more fundamental problem.

    Hi, thanks again!

    I am actually getting a NamingException when i try to look up using either java:global. or java:module. The weird thing is that the server during startup reports that is binding on java:global.

     

    1. I am wondering if

    InitialContext x  = new InitialContext() ;

    (no config here) is not as I am expecting, loaded with server state that is not related with my app.

    When i performed an small experiment

    InitialContext x  = new InitialContext() ;

    x.list("");

    I got a list of starting binding points but none was java:xxxx, so I got a

    com

    jdbc

    env

    ejb

    .....

    So I wondering if my initialContext is not the right one, up until now I have not managed to find out why, reading through the WAS documentation.  What I am really trying to do is, eventually replicate the BeanLocator Pattern as defined from Adam Bien here http://www.adam-bien.com/roller/abien/entry/ejb_3_1_beanlocator_when  simple enough.

     

    Thanks

     

  • bkail
    bkail
    23 Posts

    Re: Websphere 8.5.5 does not resolve / bind to java:module java:global or java:app

    ‏2013-07-04T17:41:35Z  
    • javapapo
    • ‏2013-07-04T17:08:55Z

    Hi, thanks again!

    I am actually getting a NamingException when i try to look up using either java:global. or java:module. The weird thing is that the server during startup reports that is binding on java:global.

     

    1. I am wondering if

    InitialContext x  = new InitialContext() ;

    (no config here) is not as I am expecting, loaded with server state that is not related with my app.

    When i performed an small experiment

    InitialContext x  = new InitialContext() ;

    x.list("");

    I got a list of starting binding points but none was java:xxxx, so I got a

    com

    jdbc

    env

    ejb

    .....

    So I wondering if my initialContext is not the right one, up until now I have not managed to find out why, reading through the WAS documentation.  What I am really trying to do is, eventually replicate the BeanLocator Pattern as defined from Adam Bien here http://www.adam-bien.com/roller/abien/entry/ejb_3_1_beanlocator_when  simple enough.

     

    Thanks

     

    Can you include the full message and stack trace of that NamingException?

    new InitialContext().list("") will list the default JNDI namespace.  The "java:" prefix indicates a separate JNDI namespace, so none of those entries will be shown.  You could try new InitialContext().list("java:"), but I've never tested it, so I don't know if it works.

  • javapapo
    javapapo
    6 Posts

    Re: Websphere 8.5.5 does not resolve / bind to java:module java:global or java:app

    ‏2013-07-04T17:43:07Z  
    • bkail
    • ‏2013-07-04T17:41:35Z

    Can you include the full message and stack trace of that NamingException?

    new InitialContext().list("") will list the default JNDI namespace.  The "java:" prefix indicates a separate JNDI namespace, so none of those entries will be shown.  You could try new InitialContext().list("java:"), but I've never tested it, so I don't know if it works.

    Will do tomorrow, since I am not @ the office.Many thanks. :)

  • javapapo
    javapapo
    6 Posts

    Re: Websphere 8.5.5 does not resolve / bind to java:module java:global or java:app

    ‏2013-09-26T10:13:16Z  
    • bkail
    • ‏2013-07-04T17:41:35Z

    Can you include the full message and stack trace of that NamingException?

    new InitialContext().list("") will list the default JNDI namespace.  The "java:" prefix indicates a separate JNDI namespace, so none of those entries will be shown.  You could try new InitialContext().list("java:"), but I've never tested it, so I don't know if it works.

    still confused https://www.ibm.com/developerworks/community/forums/html/topic?id=c80f4fda-8c7d-44f2-b0cd-a9a8229c8b58 :)