Announcement Announcement Module
No announcement yet.
Cannot instantiate class: weblogic.jndi.WLInitialContextFactory - Spring Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cannot instantiate class: weblogic.jndi.WLInitialContextFactory - Spring


    I'm facing some problems with SimpleRemoteStatelessSessionProxyFactoryBean.

    I have the following configuration in my xml:

    <bean id="traducaoEjb" class="org.springframework.ejb.access.SimpleRemote StatelessSessionProxyFactoryBean">
    <property name="jndiName" value="XXXXXXEjb" />
    <property name="businessInterface" value="......XXXXXEjb" />
    <property name="cacheHome" value="true" />
    <property name="lookupHomeOnStartup" value="false" />
    <property name="resourceRef" value="false" />
    <property name="refreshHomeOnConnectFailure" value="true" />
    <property name="jndiEnvironment">
    <prop key="java.naming.factory.initial">weblogic.jndi.WL InitialContextFactory</prop>
    <prop key="java.naming.provider.url">t3://</prop>

    When I'm in the weblogic the following error occurs:

    javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory [Root exception is java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory]
    at javax.naming.spi.NamingManager.getInitialContext(N
    at javax.naming.InitialContext.getDefaultInitCtx(Init
    at javax.naming.InitialContext.init(InitialContext.ja va:223)
    at javax.naming.InitialContext.<init>(InitialContext. java:197)

    Probably because it can't fined wlclient.jar

    If I instead of use spring (SimpleRemoteStatelessSessionProxyFactoryBean) I connect to the ejb directly in a Java class, the error does not occurs:

    Context context = null;
    Properties prop = new Properties();
    prop.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    prop.put(Context.PROVIDER_URL, "t3://");

    EJBHome home = null;
    if(context == null){
    try {
    context = new InitialContext(prop);
    } catch (NamingException e) {

    Object obj = null;
    try {
    obj = context.lookup("XXXXEjb");
    } catch (NamingException e) {
    // TODO Auto-generated catch block
    home = (EJBHome) PortableRemoteObject.narrow(obj, XXXXEjb.class);

    try {
    XXXXEjbHOme homex = (XXXXEjbHOme) home;
    traducaoEjb = homex.create();

    } catch (RemoteException ex) {
    } catch (CreateException ex) {

    When I test in my computer and I add the wlclient.jar in the application classpath both solution works.

    Why when I use SimpleRemoteStatelessSessionProxyFactoryBean it can't find wlclient.jar???

  • #2

    The problem was not spring.

    I configured the properties with double quotes.

    <prop key="java.naming.factory.initial">${property.inita l.factory}</prop>

    property.inital.factory="weblogic.jndi.WL InitialContextFactory"

    After I removed that it worked properly.