JNDI unbind ...
I have a EJB Session Stateless deployed in all node of a Weblogic cluster
5.1. As long as all weblogic nodes are up, the EJB Session Stateless is
bound to all JNDI nodes (I see it in WLS console) but when one node is down
(CTRL+C or unplug network connection), all JNDI nodes are updated to remove
the EJB Session Stateless.
The EJB is no more available on any node of my cluster.
What's wrong with my configuration ?
Is there special conditions that allow weblogic to unbind an EJB from a
cluster wide JNDI like dependence between clusterable and non clusterable
EJB ?
Thank's.
Farid Bellameche.
Are you only deploying your EJBs in one server and depending on JNDI tree
replication? Since we are deploying our EJBs in both of our servers, I
don't think this is a problem for us when one server goes down.
From the docs
(http://www.weblogic.com/docs51/classdocs/API_jndi.html#cluster):
"While stubs are replicated across servers, the actual service is provided
by a server object hosted on only one of the servers. If that server goes
down, the service offered by the server object is no longer available. For
this reason, if the host server -- the server that initially bound the
object to it's JNDI tree -- fails, the binding for the object will be
removed from all other servers in the cluster. "
Hope this helps
Jim
"Farid Bellameche" <[email protected]> wrote in message
news:[email protected]...
> I have a EJB Session Stateless deployed in all node of a Weblogic cluster
> 5.1. As long as all weblogic nodes are up, the EJB Session Stateless is
> bound to all JNDI nodes (I see it in WLS console) but when one node is
down
> (CTRL+C or unplug network connection), all JNDI nodes are updated to
remove
> the EJB Session Stateless.
>
> The EJB is no more available on any node of my cluster.
>
> What's wrong with my configuration ?
>
> Is there special conditions that allow weblogic to unbind an EJB from a
> cluster wide JNDI like dependence between clusterable and non clusterable
> EJB ?
>
> Thank's.
>
> Farid Bellameche.
>
>
Similar Messages
-
Hi All,
I am trying out a simple program using JNDI which works fine when I run it as a standalone program, but when I run the same inside Embedded Websphere (eWAS), I get a NamingContextPackage not found exception.
Here is my Standalone program:
public class TestLDAP {
final static String ldapServerName = "myHost:389";
final static String rootdn = "cn=Manager,dc=abc,dc=com";
final static String rootpass = "secret";
final static String rootContext = "dc=abc,dc=com";
public static void main( String[] args ) throws Exception {
Properties env = new Properties();
env.put( Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory" );
env.put( Context.PROVIDER_URL, "ldap://" + ldapServerName + "/" + rootContext );
env.put( Context.SECURITY_PRINCIPAL, rootdn );
env.put( Context.SECURITY_CREDENTIALS, rootpass );
try {
// obtain initial directory context using the environment
DirContext ctx = new InitialDirContext(env);
OracleDataSource ods = new OracleDataSource();
ods.setDriverType ( "thin" ); // type of driver
ods.setServerName ( "myHost" ); // database server name
ods.setNetworkProtocol("tcp"); // tcp is the default anyway
ods.setDatabaseName("ORCL"); // Oracle SID
ods.setPortNumber(1521); // listener port number
ods.setUser("scott");
ods.setPassword("tiger");
//ctx.unbind("cn=myRandomInt");
bindObjectInLDAP("cn=myRandomInt", ods, ctx);
getObjectFromLDAP("cn=myRandomInt", ctx);
} catch ( NameAlreadyBoundException nabe ) {
System.err.println( "value has already been bound!" );
} catch ( Exception e ) {
System.err.println( e );
private static void bindObjectInLDAP(String name, Object obj, DirContext ctx) throws Exception{
System.out.println("Adding " + obj + " to directory..." );
ctx.bind(name, obj);
private static void getObjectFromLDAP(String name, DirContext ctx) throws Exception {
DataSource dsUsingJNDI = (DataSource) ctx.lookup(name);
System.out.println("Retreived: " + dsUsingJNDI);
Connection connection = dsUsingJNDI.getConnection();
System.out.println( "SUCCESS!" + connection);
try {
if( connection != null )
connection.close();
} catch (SQLException ignore ) {}
}Inside websphere, when I run the same code, I can create the Inital Context, but it fails at the part where I do:
DataSource dsUsingJNDI = (DataSource) ctx.lookup(name);
Here is the Exception I get:
Could not lookup:
javax.naming.NameNotFoundException: Context: ImpactCell/nodes/ImpactNode/servers/server1, name: cn=myRandomInt: First component in name cn=myRandomInt not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]
at com.ibm.ws.naming.jndicos.CNContextImpl.processNotFoundException(CNContextImpl.java:4730)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1907)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1862)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1552)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1354)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:172)
at javax.naming.InitialContext.lookup(InitialContext.java:363)
Caused by: org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
Is this because of a missing jar or probably websphere doesn't like "com.sun.jndi.ldap.LdapCtxFactory" or something else?
Any clues on what could be causing this?
Thanks in advance!I'm having the same problem:
Jun 6, 2006 8:16:36 PM com.ibm.ws.naming.util.Helpers
WARNING: jndiGetObjInstNoop
java.lang.ClassCastException: javax.naming.Reference
at com.test.jms.Sender.main(Sender.java:33)
Adding <WAS_HOME>/lib/dynacache.jar into the classpath solved the problem.
My environment is: WAS 6.0.0.1, WebSphere MQ 6.0, JMS Client Java Application running in RAD 6.0 -
We want to run 2 instances of WLS on one machine and 2 on other machine.
Is there any way to setup a common jndi tree. so components on all 4 instances can access the same jndi URL.
any help will be greatly appreciated.
ThanksHi ,
You would have to set them up on a cluster and the JNDI tree by default is replicable .
But it seems like there is a bug in the JNDI Implementation and if any objects
unbind or rebind , they dont get reflected on the replicated JNDI tree.
Cheers,
Naggi
Baraut wrote:
We want to run 2 instances of WLS on one machine and 2 on other machine.
Is there any way to setup a common jndi tree. so components on all 4 instances can access the same jndi URL.
any help will be greatly appreciated.
Thanks -
Is there a way to force the JNDI replication?
It is on by default, unless you specifically disabled it:
http://e-docs.bea.com/wls/docs61/javadocs/weblogic/jndi/WLContext.html
REPLICATE_BINDINGS
public static final java.lang.String REPLICATE_BINDINGS
Cluster-specific: Specifies whether tree modifications are replicated
and is only applicable when connecting to WebLogic Servers that are running
in a cluster. By default, any modification to the naming tree is replicated
across the cluster, which ensures that any server can act as a naming server
for the entire cluster. Setting this property to false changes this behavior
and should be done with extreme caution: a false setting means that modifications
to the tree caused by bind, unbind, createSubcontext, and destroySubcontext
will not be replicated.
Understand the implications of this property before changing its default (true).
Pothiraj <[email protected]> wrote:
> Is there a way to force the JNDI replication?
Dimitri
-
Using JNDI to establish dependencies
Hi, I'm wondering whether anyone here has used the method of tracking JNDI lookups
to establish dependencies between components. I'm trying to establish a dependency
chain on the server side by which I can authoritatively say that a particular
transaction follows a certain path through a set of components. Is this possible
with WLS?It is not possible to create automagically arbitrary files directly
via FSContext. However it is possible to delete them.
A little example might clarify things:
Context ctx = new InitialContext(env);
System.out.println(ctx.getClass().toString());
// create file
String filename = "foo.txt";
File f = new File(ctx.getNameInNamespace() + "/" + filename);
// store it to file system
if (f.createNewFile())
System.out.println("File " + filename + " created");
// note you cannot do ctx.rebind(filename ,f) with RefFSContext because File is not Referenceable
// check that the file can be found via JNDI
f = (File)ctx.lookup(filename);
System.out.println(f.getClass().toString() + " " + f.toString());
// delete file
ctx.unbind(filename); // <---physically deletes fileCheers,
Kullervo -
Hi,
I register a listener on a tree in LDAP (Netscape Directory Server) and then
go ahead and modify one of the entries and that fires a NamingEvent to the
listeners. Now when the objectChanged() callback method() on the listener is
invoked, I print out the new and old bindings with the
NamingEvent::getNewBinding() and NamingEvent::getOldBinding().
This is what I get on the weblogic server logs:
NEW BINDING IS: cn=gkhanna222,ou=People: null:null:{adminurl=adminurl:
aaaa, buildingname=buil
dingname: ssss, ou=ou: people, objectclass=objectclass: top, fooobjectclass,
o=o:
promptu.com, cn=cn: gkhanna222}
OLD BINDING IS: cn=gkhanna222,ou=People: null:null
The NamingEvent::getNewBinding() gets all the information but the
NamingEvent::getOldBinding() only prints out the cn and the ou. Why is this
happening? Why does it not print out all the attributes of the entry?
Thanks
GauravRFC 2251 says in the section on the bind operation:
Unlike LDAP v2, the client need not send a Bind Request in the first
PDU of the connection. The client may request any operations and the
server MUST treat these as unauthenticated. If the server requires
that the client bind before browsing or modifying the directory, the
server MAY reject a request other than binding, unbinding or an
extended request with the "operationsError" result.
and then says this in the unbind operation
The function of the Unbind Operation is to terminate a protocol
session.
Upon receipt of an UnbindRequest, a protocol server
may assume that the requesting client has terminated the session and
that all outstanding requests may be discarded, and may close the
connection.
While it seems the purpose of bind is to authenticate, the purpose of unbind is not to "unauthenticate", but to terminate the session.
This would lead me to believe that you could open a connection, make requests, then unbind.
Right now I'm trying to convince the client that the unbind is not necessary since the connection is immediately closed when authentication fails, but so far they are not buying it and insisting that an unbind must be performed which we can't do from JNDI. -
Hai,
I have idea about RMI Registry.
I am new to concept of JNDI.
What i understood is that,
* this directory is used by J2EE
* It keeps the java objects on the network
* JNDI service providers are java classes used to
connect with directory services.
* Naming services which provides FQDN (fully qualified domain Name)
(and this JNDI will connect with LDAP.(light weight directory access protocol .........)
theoritically somewhat i can understand.
you just explain me, actually what it happens and the object flow
between the client and the J2EE server
thanks in advanceIn shortest of words, JNDI which is an abbreviation of Java Naming and Directory Indexing is a set of interfaces which provide a generic way of looking up objects from a naming or directory service. The actual access to the service is managed by plugging in the classes for the service provider. These will include the classes to perform operations like binding objects, unbinding them and looking them up.
There are several things you could explore and so far, I found the JNDI tutorial to be the clearest of all.
http://java.sun.com/products/jndi/tutorial/ -
Help with SUN JNDI tutorial example
HI guys there's an example of how to bound an object along with its codebase in the sun jndi tutorial
import javax.naming.*;
import javax.naming.directory.*;
import java.util.Hashtable;
* Demonstrates how to bind a Serializable object to a directory
* with a codebase.
* (Use Unbind to remove binding.)
* usage: java SerObjWithCodebase <codebase URL>
class SerObjWithCodebase {
public static void main(String[] args) {
if (args.length != 1) {
System.err.println("usage: java SerObjWithCodebase <codebase URL>");
System.exit(-1);
String codebase = args[0];
// Set up environment for creating initial context
Hashtable env = new Hashtable(11);
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=JNDITutorial");
try {
// Create the initial context
DirContext ctx = new InitialDirContext(env);
// Create object to be bound
Flower f = new Flower("rose", "pink");
// Perform bind and specify codebase
ctx.bind("cn=Flower", f, new BasicAttributes("javaCodebase", codebase));
// Check that it is bound
Flower f2 = (Flower)ctx.lookup("cn=Flower");
System.out.println(f2);
// Close the context when we're done
ctx.close();
} catch (NamingException e) {
System.out.println("Operation failed: " + e);
So in therory you should be able to retrieve an object in through doing a look up, and then cast it... but in this approach the client that performs the look up shouldn't need to include the class definition of the object that is being retrieved, because it's being included in the code base of the context, but then how do you avoid compilation errors such:
SerObjWithCodebase.java:73: cannot resolve symbol
symbol : class Flower
location: class SerObjWithCodebase
Flower f2 = (Flower)ctx.lookup("cn=Flower");
in the client code that is attepting to perform the look up?... is there a work-around for this problem? please let me know, thanks in advance.As far as I am aware, there is no possible way to compile or execute code without the client knowing it's definition.
The client will always need the class definition if it want's to use it.
If you don't want this coupling, then you could look at using an EJB container (which still requires the client to have skeleton code) or using something like web services -
A Problem with subcontext(JNDI) in WL 6.0
I am creating objects in JNDI using subcontext.
private static void cargarJNDI(String nombre,FamiliasDimensiones lov)
try{
Context ctx = ConexionPool.getInitialContext();
Context CtxApp = ctx.createSubcontext("Portal");
Context CtxLista = CtxApp.createSubcontext("LOV");
CtxLista.unbind(nombre);
CtxLista.rebind(nombre,lov);
}catch(Exception e){
e.printStackTrace();
This code works with WL 5.1 but doesn´t work with WL 6.0.
All objects are built on root tree instead of a hierarchical tree.
Anyone can help me?. are there JNDI API changes between WL5.1 and WL6.0 ?
(NOTE: Initial context is got as new Initial Context() and with the option below:
env.put(weblogic.jndi.WLContext.CREATE_INTERMEDIATE_CONTEXTS, "true"); )
ThanksI had this same problem. You need to look up the base first and only create
if not there:
private static Context getSubcontext(Context parent, String subName)
throws NamingException
Context result = null;
try
Object obj = parent.lookup(subName);
result = (Context) obj;
} catch(NameNotFoundException e) // if not found, create one
result = parent.createSubcontext(subName);
return result;
} // end getSubcontext.
However, can you help me with another problem? I keep loosing my bindings
when the appserver is restarted.
"Francisco Belinchón" <[email protected]> wrote in message
news:3af7adc5$[email protected]..
>
I am creating objects in JNDI using subcontext.
private static void cargarJNDI(Stringnombre,FamiliasDimensiones lov)
try{
Context ctx = ConexionPool.getInitialContext();
Context CtxApp = ctx.createSubcontext("Portal");
Context CtxLista = CtxApp.createSubcontext("LOV");
CtxLista.unbind(nombre);
CtxLista.rebind(nombre,lov);
}catch(Exception e){
e.printStackTrace();
This code works with WL 5.1 but doesn´t work with WL 6.0.
All objects are built on root tree instead of a hierarchical tree.
Anyone can help me?. are there JNDI API changes between WL5.1 and WL6.0 ?
(NOTE: Initial context is got as new Initial Context() and with the optionbelow:
>
env.put(weblogic.jndi.WLContext.CREATE_INTERMEDIATE_CONTEXTS, "true"); )
Thanks -
Java & LDAP, "anonymous unbind" = err=80
Dear experts,
I've found something strange in my performance tests against DSEE 6.3
Please see below some explanations about this "issue":
I use a simple Java code to test my newly created directory server. When I use a search request with the anonymous user (i.e. Context.SECURITY_AUTHENTICATION="none")...I can notice that a connection code & an error code (A1 - Client aborted connection AND err=80 (unknown error)) are always present in the corresponding logs of this request!
When I use the ldapsearch command line to "simulate" the same request (anonymous), I can see that the logs are completely different (connection code is different AND there is no error code (err=80)), that is: "U1 - Connection closed by unbind client" ; Those last logs are really as expected!
When I use a bind user (Context.SECURITY_AUTHENTICATION="simple") instead of anonymous, both tests (Java and ldapsearch) produce the same result, and the connection code is always the same, that is: U1 - Connection closed by unbind client
Here are the two connection codes:
U1: The server closed the client connection because client sent an UNBIND request.
A1: The client has closed the connection without performing an UNBIND.
I've found this article (http://java.sun.com/docs/books/tutorial/jndi/ldap/operations.html) about "How LDAP Operations Map to JNDI APIs"....
We can see that the UNBIND operation correspond to the (Java) procedure: context.close()....this procedure being of course in my code!
Is there a way in Java to "bypass" this issue for the anonymous user?
Thanks a lot in advance.
Regards,
-FranckI have updated the ldap java.schema with below entries, it is working fine
objectclass ( 1.3.6.1.4.1.42.2.27.4.2.1
NAME 'javaContainer'
DESC 'Container for a Java object'
SUP top
STRUCTURAL
MAY ( o $ cn)) -
Does the replication in clustered jndi also support removing replicate
bindings
when you call unbind()?
When I programmatically bind a value (a String), it is replicated throughout
the cluster but when I try to unbind it only gets removed on one server.
Calling rebind with a new value doesn't work either; a message is printed to
the console saying there is a conflict. Has anyone seen this before and/or
is there
something I'm missing.
This is on weblogic5.1sp4.This sounds like a bug.
I suggest that you file a bug report with our support organization. Be sure
to include a complete test case. They will also need information from
you -- please review our external support procedures:
http://www.beasys.com/support/index.html
Thanks,
Michael
Michael Girdley
BEA Systems Inc
"Jonathon Lee" <[email protected]> wrote in message
news:398b4219$[email protected]..
Does the replication in clustered jndi also support removing replicate
bindings
when you call unbind()?
When I programmatically bind a value (a String), it is replicatedthroughout
the cluster but when I try to unbind it only gets removed on one server.
Calling rebind with a new value doesn't work either; a message is printedto
the console saying there is a conflict. Has anyone seen this beforeand/or
is there
something I'm missing.
This is on weblogic5.1sp4. -
Managing Configuration Information using JNDI
I'm considering using JNDI to manage our application configuration. Can
you please comment on these design ideas?
The Admin. server will master the configuration. The nodes will connect
to the Admin. server's JNDI and create a copy of the configuration
context in the local JNDI (anyone know any easy way to do this?).
(I can't use auto. replication, if the admin. server goes down the node
servers will unbind the config. information.)
The nodes will register as NamingListeners to the Admin. server's JNDI.
When a property changes in the Admin. JNDI, the nodes will automatically
pick it up.
I'm worried about when the Admin. server goes down. Do I have to
re-register the nodes as NamingListeners?
In a nutshell, my two questions are:
1) How can I easily copy an entire context between two JNDI trees?
2) How do I deal with the Admin. server going down (it does happen)?
Thanks,
BobBob Lee <[email protected]> wrote:
Actually, that would be excellent. Do either of these implement what I'm
talking about (clustered JNDI with local caches), or would I have ot use
one of these to implement it myself?No, but you will get replication in the cluster. I've used JavaGroups to
replicate JMX configuration and it worked pretty well.
I'd really like to use JNDI for the interface. It's standard (nothing
new for other developers to learn), it decouples the clients from the
underlying storage implementation, and it has the notion of contexts
built in which I really need.
Thanks,
Bob
Dimitri I. Rakitine wrote:
Why don't you simply use Tangosol product or Javagroups for this ?
Bob Lee <[email protected]> wrote:
I'm considering using JNDI to manage our application configuration. Can
you please comment on these design ideas?
The Admin. server will master the configuration. The nodes will connect
to the Admin. server's JNDI and create a copy of the configuration
context in the local JNDI (anyone know any easy way to do this?).
(I can't use auto. replication, if the admin. server goes down the node
servers will unbind the config. information.)
The nodes will register as NamingListeners to the Admin. server's JNDI.
When a property changes in the Admin. JNDI, the nodes will automatically
pick it up.
I'm worried about when the Admin. server goes down. Do I have to
re-register the nodes as NamingListeners?
In a nutshell, my two questions are:
1) How can I easily copy an entire context between two JNDI trees?
2) How do I deal with the Admin. server going down (it does happen)?
Thanks,
Bob
Dimitri -
JNDI /Clusters (Rob can u please take a look at this ?)
Hi ..
I am trying to bind a custom object (which offcourse implements
Serializable) in to the JNDI tree..
The important thing to note here is that the 2 WLS servers are in a
cluster and I am getting the Initial Context with the with the following
(default) properties..
h.put(WLContext.REPLICATE_BINDINGS, "true");
h.put(WLContext.PIN_TO_PRIMARY_SERVER,"false");
h.put(Context.PROVIDER_URL, t3://Server1,Server2:7010 );
Now my custom object's values keep changing Dynamically and hence I am
doing a unbind and binding as
Lets say I do this on "Server2"
MyObject zz = new MyObject( );
zz.changeFustration_Level("Happy");
ctx.bind("MyObject",zz);
//As the program logic changes.... (after some interval....)
ctx.unbind("MyObject");
//Update MyObject .....
MyObject oo = new MyObject( )
oo.changeFustration_Level("Fustrated");
ctx.bind("MyObject",oo);
And I assumed (happily...) that the new Object would get replicated in
the cluster ....
(Also resolvedObject: weblogic.jndi.toolkit.ReplicatedWLContext is
called one of the servers)
But to my utter disgust the Object (in this case MyObject) is a stale
copy on the other server.....("Server1")
And to the best of my knowledge my code is doing everything as described
in the Docs...
Could anyone throw any insight in to this ??
Awaiting reply from all the JNDI gurus...
Thanxs,
NaggiThat thread has been noticed before. It all started with a bad suggestion that no one noticed and corrected. Then the post got slightly scrambled in the new forums. Finally, the original poster added some special root powers and a mess ensued.
-
I have a simple JNDI test program whose source is listed below. Bind fails
with the following error.
Operation failed: javax.naming.CommunicationException. Root exception is
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception
is:
java.io.StreamCorruptedException
at
weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:108
at
weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java
:284)
at
weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java
:244)
at weblogic.jndi.internal.ServerNamingNode_811_WLStub.bind(Unknown Source)
at weblogic.jndi.internal.WLContextImpl.bind(WLContextImpl.java:359)
at javax.naming.InitialContext.bind(InitialContext.java:355)
at com.client.mytest.main(JNDIBindTestClient.java:50)
Caused by: java.io.StreamCorruptedException
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1506)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at
weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedObjectIn
putStream.java:114)
at
weblogic.rjvm.MsgAbbrevInputStream.readObject(MsgAbbrevInputStream.java:111)
at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:466)
at
weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java
:108)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:409)
at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubjec
t.java:353)
at
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
at
weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:404)
at
weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:3
0)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
Exception in thread "main"
I have listed the source code for the test program as well as the class
Fruit (the object I am trying to bind)
JDK 1.4.1_03
BEA WL 8.1
What is going on here? Any help would be greatly appreciated.
------------------------------------mytest.java-----------------------------
package examples.jndi;
import javax.naming.*;
import java.util.Hashtable;
* Demonstrates how to bind a Referenceable object to a context.
* (Use Unbind to remove binding.)
* usage: java RefObj
class mytest {
public static void main(String[] args) {
Hashtable env = new Hashtable(11);
env.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL, "t3://localhost:7001");
try {
// Create the initial context
Context ctx = new InitialContext(env);
// Create object to be bound
Fruit fruit = new Fruit("orange");
// Perform bind
ctx.bind("cn=favorite", fruit);
// Read object back
Fruit f2 = (Fruit) ctx.lookup("cn=favorite");
System.out.println(f2);
// Close the context when we're done
ctx.close();
} catch (NamingException e) {
System.out.println("Operation failed: " + e);
---- ------------------Fruit.java----------------------------------
import javax.naming.*;
public class Fruit implements Referenceable, java.io.Serializable{
String fruit;
public Fruit(String f)
fruit = f;
public Reference getReference() throws NamingException
return new Reference(
Fruit.class.getName(),
new StringRefAddr("fruit", fruit),
FruitFactory.class.getName(),
null); // factory location
public String toString()
return fruit;
--------------------------------------FruitFactory.java---------------------
import javax.naming.*;
import javax.naming.spi.ObjectFactory;
import java.util.Hashtable;
* This is an object factory that when given a reference for a Fruit
* object, will create an instance of the corresponding Fruit.
public class FruitFactory implements ObjectFactory {
public FruitFactory() {
public Object getObjectInstance(Object obj, Name name, Context ctx,
Hashtable env) throws Exception {
if (obj instanceof Reference) {
Reference ref = (Reference)obj;
if (ref.getClassName().equals(Fruit.class.getName())) {
RefAddr addr = ref.get("fruit");
if (addr != null) {
return new Fruit((String)addr.getContent());
return null;did your client progam use the same weblogic.jar on the classpath as the
server it was calling?
MTL wrote:
I have a simple JNDI test program whose source is listed below. Bind fails
with the following error.
Operation failed: javax.naming.CommunicationException. Root exception is
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception
is:
java.io.StreamCorruptedException
at
weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:108
at
weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java
:284)
at
weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java
:244)
at weblogic.jndi.internal.ServerNamingNode_811_WLStub.bind(Unknown Source)
at weblogic.jndi.internal.WLContextImpl.bind(WLContextImpl.java:359)
at javax.naming.InitialContext.bind(InitialContext.java:355)
at com.client.mytest.main(JNDIBindTestClient.java:50)
Caused by: java.io.StreamCorruptedException
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1506)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at
weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedObjectIn
putStream.java:114)
at
weblogic.rjvm.MsgAbbrevInputStream.readObject(MsgAbbrevInputStream.java:111)
at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:466)
at
weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java
:108)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:409)
at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubjec
t.java:353)
at
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
at
weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:404)
at
weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:3
0)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
Exception in thread "main"
I have listed the source code for the test program as well as the class
Fruit (the object I am trying to bind)
JDK 1.4.1_03
BEA WL 8.1
What is going on here? Any help would be greatly appreciated.
------------------------------------mytest.java-----------------------------
package examples.jndi;
import javax.naming.*;
import java.util.Hashtable;
* Demonstrates how to bind a Referenceable object to a context.
* (Use Unbind to remove binding.)
* usage: java RefObj
class mytest {
public static void main(String[] args) {
Hashtable env = new Hashtable(11);
env.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL, "t3://localhost:7001");
try {
// Create the initial context
Context ctx = new InitialContext(env);
// Create object to be bound
Fruit fruit = new Fruit("orange");
// Perform bind
ctx.bind("cn=favorite", fruit);
// Read object back
Fruit f2 = (Fruit) ctx.lookup("cn=favorite");
System.out.println(f2);
// Close the context when we're done
ctx.close();
} catch (NamingException e) {
System.out.println("Operation failed: " + e);
---- ------------------Fruit.java----------------------------------
import javax.naming.*;
public class Fruit implements Referenceable, java.io.Serializable{
String fruit;
public Fruit(String f)
fruit = f;
public Reference getReference() throws NamingException
return new Reference(
Fruit.class.getName(),
new StringRefAddr("fruit", fruit),
FruitFactory.class.getName(),
null); // factory location
public String toString()
return fruit;
--------------------------------------FruitFactory.java---------------------
import javax.naming.*;
import javax.naming.spi.ObjectFactory;
import java.util.Hashtable;
* This is an object factory that when given a reference for a Fruit
* object, will create an instance of the corresponding Fruit.
public class FruitFactory implements ObjectFactory {
public FruitFactory() {
public Object getObjectInstance(Object obj, Name name, Context ctx,
Hashtable env) throws Exception {
if (obj instanceof Reference) {
Reference ref = (Reference)obj;
if (ref.getClassName().equals(Fruit.class.getName())) {
RefAddr addr = ref.get("fruit");
if (addr != null) {
return new Fruit((String)addr.getContent());
return null; -
Unable to resolve JNDI DataSource in weblogic 12c When you upgrade web application
I create a datasource which jndi name is jdbc/allianzB2CDataSource and the target is AdminServer ,and i deploy a web application in AdminServer.In that web application,the code(base on spring framework) is:
public static DataSource getJndiDataSource(String name) {
JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
Properties jndiEnvironment = new Properties();
jndiEnvironment.put("java.naming.factory.initial",
"weblogic.jndi.WLInitialContextFactory");
dsLookup.setJndiEnvironment(jndiEnvironment);
try {
dsLookup.setResourceRef(false);
return dsLookup.getDataSource(name);
} catch (Exception e) {
dsLookup.setResourceRef(true);
return dsLookup.getDataSource(name);
And the parameter is jdbc/allianzB2CDataSource,everything work fine,but when i restart or upgrate the web application,i got the error like this:
javax.naming.NameNotFoundException: Unable to resolve 'jdbc.allianzB2CDataSource'. Resolved 'jdbc'; remaining name 'allianzB2CDataSource'
Unable to resolve 'jdbc.allianzB2CDataSource'. Resolved 'jdbc'; remaining name 'allianzB2CDataSource'I create a datasource which jndi name is jdbc/allianzB2CDataSource and the target is AdminServer ,and i deploy a web application in AdminServer.In that web application,the code(base on spring framework) is:
public static DataSource getJndiDataSource(String name) {
JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
Properties jndiEnvironment = new Properties();
jndiEnvironment.put("java.naming.factory.initial",
"weblogic.jndi.WLInitialContextFactory");
dsLookup.setJndiEnvironment(jndiEnvironment);
try {
dsLookup.setResourceRef(false);
return dsLookup.getDataSource(name);
} catch (Exception e) {
dsLookup.setResourceRef(true);
return dsLookup.getDataSource(name);
And the parameter is jdbc/allianzB2CDataSource,everything work fine,but when i restart or upgrate the web application,i got the error like this:
javax.naming.NameNotFoundException: Unable to resolve 'jdbc.allianzB2CDataSource'. Resolved 'jdbc'; remaining name 'allianzB2CDataSource'
Unable to resolve 'jdbc.allianzB2CDataSource'. Resolved 'jdbc'; remaining name 'allianzB2CDataSource'
Maybe you are looking for
-
HP "another program has control of the device" Scanning Issue on Mac OSX 10.8.5
I am running an HP C7200 series all-in-one on a Mac OSX 10.8.5 system. Everything has worked fine for years. Suddenly when I got to fax using HP Scan I get the following message: The scan cannot be performed because another program has control of the
-
IPhone 4S ERROR 23 when trying to restore
Hi, I bought an iPhone 4S, after a few days when I was browsing the net it crashed and it didn't boot up again. When I try to restore it I get the error 23 and it wont start up. I can only see it in iTunes in recovery mode. What can I do about this e
-
I'm using oracle10g Enterprise Manager. Today I cannot see that pie-chart depicting the active sessions at the start page. There's also written: Active Sessions: Unavailable. When I click the Unavailable link, I can still see the Top sessions, etc..
-
Can I swap hard drives? T410i to T420?
I have a T410i with a Samsung 320GB hard drive. I'd like to swap it with the one in the T420 (also 320GB). Is it a simple swap? Do I need to reload anything? They're both running Windows 7 Pro already. Anything to watch out for?
-
I need to add four 30 second videos to my client's site. Should I use Encore or Flash to create the videos? Which downloads faster? Is there a difference in how I insert them into the page? I have used both programs but am far from an expert in eithe