Need help understanding JNDI and a specific ClassCastException in J2EE

I have enterprise application A and B deployed (in WLS 10.0). A is the wireframe, B is the client application. The client issues the following calls:

Object o = ctx.lookup(jndiName); // line 1
cf = (ConnectionFactory) o; // line 2

ConnectionFactory is an interface defined as:

public interface ConnectionFactory 
    extends java.io.Serializable, javax.resource.Referenceable {
    ...
}

What's happening:

  • If the jar containing the interface class is in the system path, line 2 runs fine
  • If the interface class is not in the system class path, but it is packaged separately with applications, line 2 throws a ClassCastException (which contains informative text, which o is ConnectionFactoryImpl)

? , JNDI ( ?), , - ?

:

  • , , , ...
  • , , ... ..., - .
  • , , , , - -?
  • ...:)

, - , JNDI , ( ?) ..

!

+3
1

, , (1).

JNDI , , . API .

JVM, , Weblogic, , . " ". , , (, , , ).

, , , , , JavaEE - , .

+2

Source: https://habr.com/ru/post/1730340/


All Articles