javanetbeansweblogicweblogic-10.xnetbeans-10

Weblogic Error - Could not initialize class weblogic.jndi.Environment


When I try to debug a WebApp configured to run with Oracle Weblogic Server from NetBeans 10, I always get the following error:

There's not even complicated steps, I just open my project and then right-click / Debug.

java.lang.NoClassDefFoundError: Could not initialize class weblogic.jndi.Environment
    at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:117)
    at java.naming/javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:730)
    at java.naming/javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:305)
    at java.naming/javax.naming.InitialContext.init(InitialContext.java:236)
    at java.naming/javax.naming.InitialContext.<init>(InitialContext.java:208)
    at weblogic.management.remote.common.ClientProviderBase.makeConnection(ClientProviderBase.java:178)
    at weblogic.management.remote.common.ClientProviderBase.newJMXConnector(ClientProviderBase.java:84)
    at java.management/javax.management.remote.JMXConnectorFactory.newJMXConnector(JMXConnectorFactory.java:378)
    at org.netbeans.modules.j2ee.weblogic9.WLConnectionSupport$1.call(WLConnectionSupport.java:182)
    at org.netbeans.modules.j2ee.weblogic9.WLConnectionSupport.executeAction(WLConnectionSupport.java:112)
    at org.netbeans.modules.j2ee.weblogic9.WLConnectionSupport.executeAction(WLConnectionSupport.java:161)
    at org.netbeans.modules.j2ee.weblogic9.deploy.WLDeploymentManager.getTargets(WLDeploymentManager.java:632)
    at org.netbeans.modules.j2ee.deployment.impl.ServerInstance.getTargetMap(ServerInstance.java:560)
    at org.netbeans.modules.j2ee.deployment.impl.ServerInstance.getTargets(ServerInstance.java:518)
    at org.netbeans.modules.j2ee.deployment.impl.ServerString.getTargets(ServerString.java:117)
    at org.netbeans.modules.j2ee.deployment.impl.ServerString.toTargets(ServerString.java:155)
    at org.netbeans.modules.j2ee.deployment.impl.TargetServer.init(TargetServer.java:146)
    at org.netbeans.modules.j2ee.deployment.impl.TargetServer.undeploy(TargetServer.java:771)
    at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.undeploy(Deployment.java:337)
    at org.netbeans.modules.j2ee.ant.Undeploy.execute(Undeploy.java:92)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at jdk.internal.reflect.GeneratedMethodAccessor99.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
    at org.apache.tools.ant.Task.perform(Task.java:350)
    at org.apache.tools.ant.Target.execute(Target.java:449)
    at org.apache.tools.ant.Target.performTasks(Target.java:470)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1361)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
    at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:261)
    at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:574)
    at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:128)
BUILD FAILED (total time: 0 seconds)

My environment is:

How to fix?


Solution

  • I've decided to post this question because it took me the whole morning to find a solution... especially because the most common reason for java.lang.NoClassDefFoundError: Could not initialize class weblogic.jndi.Environment to occur, is when weblogic.jar and wlfullclient.jar aren't being properly located by any of IDE, WebApp, or WL.

    To fix the issue just run your project using NetBeans 8.2, this seems to be a bug at NB10 only.

    Also, don't even try running it on NB11, NB12, NB12.1 nor NB12.2. Currently, Java EE plugin for those versions is discontinued so you'll not even be able to add WL to your server list.

    The reason it broke in NB10 is that they started removing Java 8 vendor features from it, And the reason it doesn't even is possible to add WL to NB11 > is because Oracle removed JDK8 features for the followed releases of Java... NB integration is not under Apache Licence so they just aren't giving support to it now (is an issue that they refused to fix). However, with a bit of risk, it can be added manually.