2 Replies Latest reply on Aug 17, 2016 10:37 AM by brucespringfield

    WELD-ENV-002000: Weld SE container STATIC_INSTANCE is already running!

    brucespringfield

      Trying to start Weld Container in a JUnit test and get the following message:

       

      WELD-ENV-002000: Weld SE container STATIC_INSTANCE is already running!

       

      What does this mean? And how can I fix it?

       

      Full Error message:

       

      java.lang.IllegalStateException: WELD-ENV-002000: Weld SE container STATIC_INSTANCE is already running!

        at org.jboss.weld.environment.se.WeldContainer.initialize(WeldContainer.java:136)

        at org.jboss.weld.environment.se.Weld.initialize(Weld.java:544)

        at com.mydomain.CdiContainer.initializeCdiContainer(CdiContainer.java:59)

        at com.mydomain.bc.acontact.test.AContactServiceExampleBCT.initializeCdiDependencies(AContactServiceExampleBCT.java:82)

        at com.mydomain.bc.acontact.test.AContactServiceExampleBCT.setUpClass(AContactServiceExampleBCT.java:75)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        at java.lang.reflect.Method.invoke(Method.java:497)

        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)

        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)

        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)

        at org.junit.runners.ParentRunner.run(ParentRunner.java:309)

        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)

        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)

        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)

        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)

        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

        • 1. Re: WELD-ENV-002000: Weld SE container STATIC_INSTANCE is already running!
          mkouba

          Hi Bruce,

          this means you are running multiple Weld instances of the same ID (default one) at the same time (and not isolated by ClassLoader). You will get this error if you run e.g.:

          public static void main(String[] args) {
            Weld weld1 = new Weld().initialize();
            Weld weld2 = new Weld().initialize(); // WELD-ENV-002000 and IllegalStateException is thrown
          }
          

          You should either shut down the weld1 container first or, if you really need to run multiple containers in parallel, specify a unique container ID via org.jboss.weld.environment.se.Weld.containerId(String):

          public static void main(String[] args) {
            Weld weld1 = new Weld().containerId("alpha").initialize();
            Weld weld2 = new Weld().containerId("bravo").initialize();
            weld1.shutdown();
            weld2.shutdown();
          }
          

          It's also possible to inspect all running containers - see also org.jboss.weld.environment.se.WeldContainer.getRunningContainerIds().

          1 of 1 people found this helpful
          • 2. Re: WELD-ENV-002000: Weld SE container STATIC_INSTANCE is already running!
            brucespringfield

            Okay, I see. Thanks for the help!