Default ejb JNDI name in websphere ear
Hi,
I am using ejb2.0-2.1 in websphere 6.0 WAS.
I have a local entity ejb.
I wish to define a service locator for this as a singleton class that caches the entity bean's home after doing a JNDI lookup.
I am interested in two things.
1) Since my service locator is a simple singleton class I want it to lookup the local ejb homes using the JNDI names supplied in the websphere specific deployment descriptors correspondiing to ejb-jar.xml. (No point in even thinking of any ejb-local-ref) My service locator is defined inside the same ejb jar.
2) Ideally I would like to not specify any explicit JNDI names in any websphere specific DD for the local ejb homes. I would like to use a JNDI name based on the ejb-name itself.
I have been able to do 2) using JBoss.
Thanks.
Raster
Hi Ravi,
Can you please post the error message and stack trace? Also what version of WLS are you
using? The more relevant information you can give me, the more likely I'll be able to
help you.
- Matt
ravichandran wrote:
Hi Matthew,
Thank u for very quick response, the error is class cast exception and these objects
are serialized and kept in ear. ur solution will be highly appreciated.
regards
ravi
Matthew Shinn <[email protected]> wrote:
Hi,
What error are you getting (please include full error message & stack trace)?
Also,
is the object you are returning Serializable?
- Matt
ravi wrote:
Hello Daniel
I also have the same problem, do u have any solutions, please let me know,I was
struggling for more than ten days.
regards
ravi
[email protected] (Daniel) wrote:
Hi, there:
Our team is trying to write a session bean as a factory to serve
other beans. Even the JSP (or other clients) can find the correct
session bean residing on different ear file, the factory can't return
properly when the returning parameter is a java object (it works fine
if we only return int/string/etc). Is there a work-around to make
these work?
Thanks,
-Daniel
Similar Messages
-
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? -
Hello all!
I created this SLSB:
@Local
public interface CatalogServiceLocal {
public float getCatalogVersion();
@Stateless(name="CatalogService")
public class CatalogService implements CatalogServiceLocal {
I'm using JSF and I want to access my SLSB from a Managed Bean but the server always complains it didn't find the given name:
this.catalogService = (CatalogServiceLocal) ctx.lookup(JNDI_NAME);
I tried a lot of different names (CatalogService, ejb.CatalogService...). How can I know the correct name for the lookup. I searched for it in the admin console but I didn't find it either.
Thank you very much!
sitaroHi Sitaro,
Please refer to the following links... you will get information about how to lookup Local EJB3...
http://jaysensharma.wordpress.com/ejbs_weblogic/
http://jaysensharma.wordpress.com/2009/08/16/weblogic-10-3-ejb3-local-lookup-sample/
Here you will get the information of Customizing The JNDI name and to look them up.
Thanks
Jay SenSharma
http://jaysensharma.wordpress.com/ (WebLogic Wonders Are Here) -
You do not specify JNDI name at console but in deployment descriptors.
"Ronak Parekh" <[email protected]> wrote in message
news:[email protected]..
what is the jndi name for the EJB? Where do you specify the EJB jndi namein
the console?/
Ronak -
Hi all !
I have one EJB application which needs to be run in two different containers (GlassFish
and Weblogic)
One issue I have faced is the JNDI binding. When I deploy my EJB, the jndiBinding of @RemoteBinding
is not used:
@Stateless
@RemoteBinding(jndiBinding="UserManagerEJB/remote")
public class UserManagerBean implements UserManagerEJB{
rather the EJB is bound at JAR_NAME_jarUserManagerBean_UserManagerEJB
is it possible to bind the EJB at "UserManagerEJB/remote" so that it's portable between the two App. servers?
thanks
FrankI could not find RemoteBinding in the following doc :-
Link :[http://download.oracle.com/docs/cd/E12840_01/wls/docs103/ejb30/annotations.html]
I wonder whether this would work. I am not sure whether this is implemented. -
Refering to JNDI name in other EAR file
Hi, there:
Our team is trying to write a session bean as a factory to serve
other beans. Even the JSP (or other clients) can find the correct
session bean residing on different ear file, the factory can't return
properly when the returning parameter is a java object (it works fine
if we only return int/string/etc). Is there a work-around to make
these work?
Thanks,
-DanielHi Ravi,
Can you please post the error message and stack trace? Also what version of WLS are you
using? The more relevant information you can give me, the more likely I'll be able to
help you.
- Matt
ravichandran wrote:
Hi Matthew,
Thank u for very quick response, the error is class cast exception and these objects
are serialized and kept in ear. ur solution will be highly appreciated.
regards
ravi
Matthew Shinn <[email protected]> wrote:
Hi,
What error are you getting (please include full error message & stack trace)?
Also,
is the object you are returning Serializable?
- Matt
ravi wrote:
Hello Daniel
I also have the same problem, do u have any solutions, please let me know,I was
struggling for more than ten days.
regards
ravi
[email protected] (Daniel) wrote:
Hi, there:
Our team is trying to write a session bean as a factory to serve
other beans. Even the JSP (or other clients) can find the correct
session bean residing on different ear file, the factory can't return
properly when the returning parameter is a java object (it works fine
if we only return int/string/etc). Is there a work-around to make
these work?
Thanks,
-Daniel -
Dynamic jndi-name in weblogic-ejb-jar.xml
Is there a way to create dynamic (i.e. runtime) jndi-names for EJBs instead of
(or in addition to) "hard coding" them in the weblogic-ejb-jar.xml file? What
I'm trying to do is have one WebLogic instance (JVM) host multiple environments
(our Beta and Training environments) and I simply want to deploy the same .ear
file twice but have each environment (application - .ear) reference a different
database schema (jdbc connection pool). I have everything working just fine for
this scenario except when I define jndi-names for our ejbs. The problem is that
I am really deploying the same ejbs (jndi-names and actually code base) in each
applicatoin instance and I get an exception when the WebLogic is trying to deploy
the second application (.ear) because the jndi-names in it have already been deployed
by the first application instance. I recieve a jndi error stating that the name
is already deployed.
Or is there a better path to go down for what I am trying to do to have one WebLogic
instance support our beta and training environments? Usually (but not always)
our code base is the for same for both of these environments, I simply need to
have each environment use a different database schema.
ThanksA little birdie tells me that BEA does this very thing. Looking at the
descriptors for WebLogic Portal I see:
<weblogic-enterprise-bean>
<ejb-name>LoaderEJB</ejb-name>
<enable-call-by-reference>True</enable-call-by-reference>
<jndi-name>${APPNAME}.BEA_content.LoaderHome</jndi-name>
</weblogic-enterprise-bean>
Yes, the ${APPNAME} token really is expanded into the J2EE application
name at deployment time!
Sincerely,
Daniel Selman
Bryan Dixon wrote:
Rewriting our build process isn't really much of an option for me. Our current
build process is too complex and time consuming right now to convert to Ant (we
eventually will do this but not for a while). So are there any other ideas that
aren't build related?
Thanks
"Eric Ma" <[email protected]> wrote:
You don't need run-time dynamism in JDNI names and it can't be done anyways.
You
need token substitution in XML configuration files when building the
app. If
you are using Ant for building, then it is a breeze. If not, first convert
your
build process to use Ant.
Also, a single WLS instance hosting multiple environments sounds really
INTRIGUING
to me.
Eric Ma
"Bryan Dixon" <[email protected]> wrote:
Is there a way to create dynamic (i.e. runtime) jndi-names for EJBsinstead
of
(or in addition to) "hard coding" them in the weblogic-ejb-jar.xml file?
What
I'm trying to do is have one WebLogic instance (JVM) host multiple environments
(our Beta and Training environments) and I simply want to deploy the
same .ear
file twice but have each environment (application - .ear) referencea
different
database schema (jdbc connection pool). I have everything working just
fine for
this scenario except when I define jndi-names for our ejbs. The problem
is that
I am really deploying the same ejbs (jndi-names and actually code base)
in each
applicatoin instance and I get an exception when the WebLogic is trying
to deploy
the second application (.ear) because the jndi-names in it have already
been deployed
by the first application instance. I recieve a jndi error stating that
the name
is already deployed.
Or is there a better path to go down for what I am trying to do to have
one WebLogic
instance support our beta and training environments? Usually (but not
always)
our code base is the for same for both of these environments, I simply
need to
have each environment use a different database schema.
Thanks -
Hi,
I know 'ejb-name' should be the name used in ejb-jar.xml. what should be JNDI-name?
can I assign it to "xyz" or there is some strict rule? Is there any relation betn
'ejb-name' and 'JNDI-name'
Thanks a lot.
VishalVishal,
ejb-name - name of the ejb
jndi-name- name by which remote components identify a particular bean.
it's name is unique. for naming policies
http://java.sun.com/products/jndi/tutorial/beyond/misc/policy.html
/Venki..
vishal patel wrote:
Hi,
I know 'ejb-name' should be the name used in ejb-jar.xml. what should be JNDI-name?
can I assign it to "xyz" or there is some strict rule? Is there any relation betn
'ejb-name' and 'JNDI-name'
Thanks a lot.
Vishal -
Multiple JNDI names for EJB?
If I'm deploying a webapp that references an EJB, do I have to use the same JNDI
name that is configured in the EJB descriptor?
Why can't I reference the EJB using a seperate name (as in some J2EE examples)?
Thanks,
Darrendarren <[email protected]> wrote:
If I use a new JNDI name, rather than the one defined in weblogic-ejb-jar.xml,
it does not show up in the JNDI tree.
Does the JNDI name referenced in weblogic.xml need to be the same as that defined
in weblogic-ejb-jar.xml? No. ejb-ref mechanism allows you to map an actual ejb jndi name to one used by your
application - so, in theory, system administrator can change jndi names without
touching your application code. You do not see it in the global JNDI tree because
this mapping exists only in the context of your application.
<[email protected]> wrote:
That's what ejb-ref in web.xml is for - you can create an ejb-ref in
web.xml
and map it to an actual jndi name in weblogic.xml ejb-reference-description.
Darren <[email protected]> wrote:
If I'm deploying a webapp that references an EJB, do I have to usethe same JNDI
name that is configured in the EJB descriptor?
Why can't I reference the EJB using a seperate name (as in some J2EEexamples)?
Thanks,
Darren--
Dimitri
Dimitri -
Dear all,
when I use Stateless Session bean with mappedName properties, it JNDI name become like mappName+#+packagename+classname.
I don't want "#" notation between them.
if it is not possible, how can i know default JNDI name without using mappedName property?
With Regards,
Wai PhyoMake use of the weblogic-ejb-jar.xml file to control the EJB JNDI name. The following example works in WebLogic 11g and replaces the default #<package><class> with the specified values.
Regards
Neil
<weblogic-enterprise-bean>
<ejb-name>DepartmentEJB</ejb-name>
<stateless-session-descriptor>
<business-interface-jndi-name-map>
<business-remote>com.sopragroup.uk.whitepaper.hr.jee.ejb.department.DepartmentRemote</business-remote>
<jndi-name>ejb/HR/DepartmentEJB</jndi-name>
</business-interface-jndi-name-map>
</stateless-session-descriptor>
<enable-call-by-reference>true</enable-call-by-reference>
<jndi-name>ejb/HR/DepartmentEJB</jndi-name>
<local-jndi-name>ejb/HR/DepartmentEJBLocal</local-jndi-name>
</weblogic-enterprise-bean> -
Hi,
If my AS Java's port is 50000, then the ejb port is 50004. Is it possible to change the default EJB JNDI lookup port to eg, 55555?
Thanks.
Any help will be highly appreciated.
- juliushi,
in addition to above context
this may be help full to u
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/a2/f9d7fed2adc340ab462ae159d19509/content.htm
bvr -
WLS10.3.1 : How to overload the jndi name of a stateless EJB
Hi,
I am trying to overload the jndi name of a stateless bean defined in an application by using a weblogic-ejb-jar.xml descriptor file.
This does not work.
The ear contains a jar that have a weblogic-ejb-jar.xml file in its META-INF directory. The file is :
<?xml version="1.0" encoding="UTF-8"?>
<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>HelloWorldBean</ejb-name>
<enable-call-by-reference>true</enable-call-by-reference>
<jndi-name>TOTO</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
This is the code of my bean :
package test;
import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
@Stateless( name = "HelloWorldBean", mappedName="HWBean")
@Local( IHelloWorldLocal.class)
@Remote( IHelloWorldRemote.class)
public class HelloWorldBean implements IHelloWorldLocal, IHelloWorldRemote
public void sayHello(String name) {
System.out.println( "Hello " + name + "!!!!");
The bean implements the following interfaces :
package test;
public interface IHelloWorldRemote extends IHelloWorld {
package test;
public interface IHelloWorldLocal extends IHelloWorld {
package test;
public interface IHelloWorld {
public void sayHello( String name);
When i browse the JNDI tree, i see the bean registered with the mapped name attribute (HWBean#test.IHelloWorldRemote) but i don't see any bean registered with the name provided by the weblogic-ejb-jar.xml (TOTO)
My standalone client can't perform a lookup using the JNDI name 'TOTO' but reaches the bean when using 'HWBean#test.IHelloWorldRemote'
It seem's that the overload of the Jndi name using the weblogic-ejb-jar file descriptor doesn't work.
Can you help me to solve the problem.
Thanks.Thank you, my sample works fine with the following weblogic-ejb-jar.xml :
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-ejb-jar xmlns="http://www.bea.com/ns/weblogic/10.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/10.0 http://www.bea.com/ns/weblogic/10.0/weblogic-ejb-jar.xsd">
<weblogic-enterprise-bean>
<ejb-name>HelloWorldBean</ejb-name>
<enable-call-by-reference>true</enable-call-by-reference>
<stateless-session-descriptor>
<business-interface-jndi-name-map>
<business-remote>test.IHelloWorldRemote</business-remote>
<jndi-name>TOTO</jndi-name>
</business-interface-jndi-name-map>
</stateless-session-descriptor>
</weblogic-enterprise-bean>
</weblogic-ejb-jar> -
EJB Refs ( coded name and JNDI name )
Hi
I am just starting to develop EJBs . I can't get to work the EJB refs as expected . In a session bean I have a lookup for an Entity bean . Both beans are in separate JAR files , but in the same ear .
The lookup from session bean to entity bean only works when
the coded name in EJB ref is defined exactly the same as JNDI name for enity bean , also the name in lookup method must be the same in session bean .
To my surprise , the JNDI name for the target EJB , defined in EJB ref for session bean , does not mater at all . Even if I change it to a non existant name , the bean lookup works .
Theoritacally I understand that EJB ref is there to provide a mapping between the name of bean mentioned in code to the actual JNDI name of another bean , at the time of deployment .
The above is happening in J2EE 1.4 envoirment .
Please let me know , what am I doing here that is wrong .
( All examples and tutorials , usually give coded name same as JNDI name ) .
Thanks
TarunHi Tarun,
The ejb-ref-name lives in a different namespace than the global JNDI names. Any names of ejb-refs, ejb-local-refs, resource-refs, etc. are scoped within a particular component's private namespace. All environment references are accessed via the java:comp/env namespace at runtime. So, if your ejb-ref-name(a.k.a "coded name") is ejb/foo in the deployment descriptor, you would access it from the code as follows :
initialContext.lookup("java:comp/env/ejb/foo");
This way, neither the standard deployment descriptor nor the code has any dependency on the global JNDI name. That's a good thing since the decision about which target EJB should be linked to is often not made until deployment time rather than development time. Furthermore, it means if you want to change the linking you can always do it without recompiling your code.
As for the global JNDI names, the first thing to note is that they are completely vendor-specific. That's why they don't appear in the standard deployment descriptor. In the J2EE SDK, each EJB that exposes a Remote view is assigned a global JNDI name in sun-ejb-jar.xml. This JNDI name is assigned from the global namespace of the application server. There's nothing stopping it from also being "ejb/foo", but it refers to a different thing than the "ejb/foo" above.
Now we have an ejb-ref called ejb/foo and an ejb whose JNDI name is ejb/foo, but we haven't linked the two. When it comes to linking, you have two choices:
1. If the target ejb is in the same .ear as the client component, you can use the ejb-link mechanism. This allows you to specify the target ejb by referring to its ejb-name. Since ejb-name is only guaranteed to be unique within an ejb-jar, the syntax allows for you to give the uri of the containing ejb-jar, followed by #, followed by ejb-name.
2. Alternatively, you can specify the global JNDI name of the target ejb using sun-ejb-jar.xml Note that this will work whether the target ejb is in the same .ear or not. However, it's the only option if the target ejb is in a different .ear. In this case, you would create an ejb-ref entry for the client component within the sun-ejb-jar.xml. e.g. :
<ejb>
<ejb-name>MyClientBean</ejb-name>
<ejb-ref>
<ejb-ref-name>ejb/foo</ejb-ref-name>
<jndi-name>ejb/foo</jndi-name>
</ejb-ref>
</ejb>
Again, it's just a coincidence that both names happen to be ejb/foo. They refer to different things.
When you do a global lookup from your code, initialContext.lookup('ejb/foo"), it will work in some environments because you're simply bypassing the level of indirection provided by your component environment and going straight to the global namespace. This is non-portable and not a good idea, since you've now tightly coupled the name of the target ejb to your client component. That means if it changes you need to recompile your code. Hope this helps.
--ken -
[EJB:011055]Error deploying the EJB with error that JNDI name already inuse
Hi,
I have written a trivial application consisting of 4 stateless beans and 1 MDB. The ear is developed from some code generator tool and works fine if I directly deploy on weblogic server 812.
But in order to learn Weblogic Workshop I created new Application and EJB project. Then I imported the EJB jar and provided other source files.
From Weblogic Workshop I could generate the ear successfully. But while trying to deploy the ear I get the following exception :
<16/03/2005 10:02:38 PM GMT+05:30> <Error> <Deployer> <BEA-149201> <Failed to complete the deployment task with ID 1 for the application hsbc.
weblogic.management.ApplicationException:
Exception:weblogic.management.ApplicationException: prepare failed for MCAppBEAN.jar
Module: MCAppBEAN.jar Error: Exception preparing module: EJBModule(MCAppBEAN.jar,status=NEW)
Unable to deploy EJB: StatelessBean from MCAppBEAN.jar:
<b>[EJB:011055]Error deploying the EJB 'StatelessBean(Application: hsbc, EJBComponent: MCAppBEAN.jar)', the JNDI name 'StatelessBeanHSBC' is already in use. You mu
st set a different JNDI name in the weblogic-ejb-jar.xml deployment descriptor for this EJB before it can be deployed.</b> at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.createContainer(SlaveDeployer.java:2556)
at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.prepare(SlaveDeployer.java:2474)
at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(SlaveDeployer.java:798)
at weblogic.management.deploy.slave.SlaveDeployer.prepareDelta(SlaveDeployer.java:507)
at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDeployer.java:465)
at weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHandler.java:25)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
--------------- nested within: ------------------
<b>Can someone tell where have I made the mistake?</b>
thanks in advance.Try to undeploy and un target the applcation via WLS console and they try to deploy it again. Or just try to redeploy it.
-
JNDI name in ejb-jar.xml
Hi all,
I am deploying about 80 beans to WebSphere using the console. I was wondering if it was possible to set the jndi name of my beans in the standard ejb-jar.xml file within my jarfile.
I tried to add the trags <jndi-name> or <jndiname> to my ejb-jar.xml but it is ignored and I still have to input all the jndi names by myself.
Seems like the jndi-name resided in the vendor-specific ejb-jar.xml.
Max.Perhaps the <jndi-name> in weblogic-ejb-jar.xml:
<?xml version="1.0" ?>
<!DOCTYPE weblogic-ejb-jar (View Source for full doctype...)>
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>CurrencyConverterBean</ejb-name>
<stateless-session-descriptor />
<jndi-name>conv</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
Maybe you are looking for
-
How to create a liveworkstation details in sccm 2007
HI how to create query to find the live work station details for last 30 days?
-
Adding a Date/Time stamp to videos already created
We have someone using Elemets 8 They need to add in the date/time stamp to video's that are already created. The camcorder we have does record this information but doesn't allow that information to be put onto the screen its a Canon HD HF200 We were
-
How i retrieve the default setting for my browser ?
when i download any file from firefox browser there a small box that ask you if you want to from your browser to do the same action for files like the file you are downloaded automatically, i did that and i wont to retrieve the old sitting i tried to
-
A problem with Notes...
I'm sorry if I posted this in the wrong place, but wasn't sure where to go. I'm having problems with notes on my Mac running 10.8.4. I've done searches, but cannot find my problem. I have set up an iCloud account. I can see my notes in iCloud, but if
-
White screen flashing question mark
My internet froze for a long time so i turned my mac pro off but when i turned the laptop back on i got a white screen with a flashing box with a question mark on it. computer won't start up, how do i fix this?