• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

EJB's in two different Application Servers

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am new to EJB's.I am trying to call a method in an Entity bean which is deployed in JBoss server, from a session bean deployed in WebLogic server, both in same Machine. I did the following code for instantiating context and home, getting error for new InitialContext(prop);
I had added jnp-client.jar, jboss-client.jar, log4j.jar, jboss-j2ee.jar these files with my WebLogic .ear file which is having the client, session bean.

The exception is that it could not find the 'org.jnp.interfaces.NamingContextFactory' class.
-----------------------------------------------------------------------------------------------------------------------------------------
Properties prop = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
prop.put(Context.PROVIDER_URL, "localhost:1099");
prop.put(Context.URL_PKG_PREFIXES, "org.jboss.naming rg.jnp.interfaces");
Context context = new InitialContext(prop);
JBPersonHome home = (JBPersonHome)context.lookup("ejb/tutorial/com/JBPerson");
JBPerson bean = home.create(_LoginName, _Password, _FirstName, _LastName);
...........................

------------------------------------------------------------------------------------------------------------------------------------------
JBPersonHome is the home interface, JBPerson is the Entity Bean which are deployed in the Jboss.

If somebody can help me , how to make these appservers communicate between each other, i will be much grateful.
 
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, apparently the NamingContextWhatever class isn't part of your classpath. Fix that and you should be good to go.
 
Dinesh Shenoy
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Nathaniel,

That problem of ClassDefNotFound is solved, we added
jnp-client.jar;
log4j.jar;
jboss-j2ee.jar;
jboss-client.jar;
jbossall-client.jar;

all these in the classpath of WebLogic.Then the required imports are done in the bean class.(for eg. import org.apache.log4j.Category;import org.apache.log4j.LogManager;
import org.apache.log4j.xml.DOMConfigurator; etc).This solved our class def not found.

But now we are getting the following exception,
--------- -------------- --------------- -----------------
java.security.AccessControlException: access denied (java.io.FilePermission C:\bea\user_projects\domains\mydomain\myserver\.wlnotdelete\EJBCompilerCache\cl0p924
w3fjo\com\tutorial\interfaces\JBPersonHome.class read)
at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:270).........
--------- -------------- --------------- -----------------

As i assume that Weblogic is searching for the Home Interface in the above shown directory ie. C:\bea\user_projects\domains\mydomain\...... ,and actually it is not there.How will weblogic can access that particular HomeInterface of Entity bean deployed in JBoss.

We checked for lookup of JNDI by Weblogic(ie lookup for JBoss Entity bean), and its able to find it.I am not sure about this exception and how to solve this,

any help ???

Thanks
Dinesh
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
WebLogic also needs to have a copy of the Home and Remote Interfaces of the EJB(s) that you are trying to access in JBoss.
 
Dinesh Shenoy
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where to put the interface classes of entity bean(JBoss), whether into the
ejb-jar files of session bean(Weblogic) or in the classpath of Weblogic
 
Dinesh Shenoy
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where to put the interface classes of entity bean(JBoss), whether into the
ejb-jar files of session bean(Weblogic) or in the classpath of Weblogic ,
also whether we need to specify in the Deployment Descriptor of Weblogic.
 
Dinesh Shenoy
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As i posted early, i am trying to get the ejb's working in two different application servers(ie SessionBean in WebLogic accessing Entity Bean in JBoss).I hope this can be acheivable since ejb's support distributed technology.

For this i created a .ear file for JBoss that contains EntityBean.

I got these directory structure for JBoss MyJB.ear
package sab.tutorial.ejb
->JBPersonEntityBean (The Bean Class)
->JBPerson_PK (The Primary Key)
package sab.tutorial.interfaces
->JBPerson (Remote)
->JBPersonHome (Home)
META-INF
->application.xml
->ejb-jar.xml
->jboss.xml
->jbosscmp-jdbc.xml

I used eclipse and xDoclet for the code and package generation and the configuration of Database(MySQL) is done(which is aleady tested and working)




Then for WebLogic MyWL.ear i have following directory structure
package com.tutorial.ejb
->RegisterSessionBean (The Bean Class which calls the entity bean in JBoss)
package com.tutorial.interfaces
->Register (Remote)
->RegisterHome (Home)
package com.tutorial.web
->RegisterServlet (Client that initializes the sessionbean and calls its method)
META-INF
->application.xml
->ejb-jar.xml
->weblogic-cmp-rdbms-jar.xml
->weblogic-ejb-jar.xml
WEB-INF
->web.xml
->weblogic.xml

index.html that calls the servlet.

I have given the JNDI name for entity bean in JBoss as below in the jboss.xml
-----------------------------
.....
<entity>
<ejb-name>JBPerson</ejb-name>
<jndi-name>sab/tutorial/com/JBPerson</jndi-name>

</entity>
........
--------------------------------

and in the sessionbean of WebLogic in the implementation method i have the following code to access the JBoss entity bean

---------------------------------------------------------------
.............................
Properties prop = new Properties();
Context context=null;
Thread.currentThread().setContextClassLoader(org.jnp.interfaces.NamingContextFactory.class.getClassLoader());

prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
prop.put(Context.PROVIDER_URL, "localhost:1099");

prop.put(Context.URL_PKG_PREFIXES, "org.jboss.naming rg.jnp.interfaces");
context = new InitialContext(prop);
JBPersonHome home = (JBPersonHome)context.lookup("sab/tutorial/com/JBPerson");
JBPerson bean = home.create(_LoginName, _Password, _FirstName, _LastName);
.........................
---------------------------------------------------------------

Also i had updated the policy files of weblogic.




I deployed the MyJB.ear in JBoss and MyWL.ear in WebLogic.
But while trying to call the sessionbean method it is giving following exception.
---------------------------------------------------------------
access denied (java.io.FilePermission C:\bea\user_projects\domains\mydomain\myserver\.wlnotdelete\EJBCompilerCache\cl0p924w3fjo\com\tutorial\interfaces\JBPersonHome.class read) java.security.AccessControlException: access denied (java.io.FilePermission C:\bea\user_projects\domains\mydomain\myserver\.wlnotdelete\EJBCompilerCache\cl0p924w3fjo\com\tutorial\interfaces\JBPersonHome.class read) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:270) at java.security.AccessController.checkPermission(AccessController.java:401) at java.lang.SecurityManager.checkPermission(SecurityManager.java:542) at java.lang.SecurityManager.checkRead(SecurityManager.java:887) at java.io.File.exists(File.java:677) at weblogic.utils.classloaders.ClasspathClassFinder.getSourcesInternal(ClasspathClassFinder.java:291) at weblogic.utils.classloaders.ClasspathClassFinder.getSource(ClasspathClassFinder.java:246) at.................................
-----------------------------------------------------------------------

Even then my JBoss entity bean home is in the package sab.tutorial.interfaces ,its looking in some directory ie shown in the above exception (C:\bea\user_projects\domains\mydomain\myserver\.wlnotdelete\...) which i couldn't find.

Chris told that i should have the EntityBean remote and home interfaces with in the .ear file of weblogic.How can i put this, should i put these two class files in a jar file and jar it with the .ear file or how can i do this, if some one have any idea please help.

Thanks
Dinesh
reply
    Bookmark Topic Watch Topic
  • New Topic