Uploaded image for project: 'Thorntail'
  1. Thorntail
  2. THORN-673

Weld SE container STATIC_INSTANCE is already running!

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 2016.11.0
    • Component/s: None
    • Labels:
      None

      Description

      When we run this test case

      /**
       * Copyright 2015-2016 Red Hat, Inc, and individual contributors.
       *
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.
       * You may obtain a copy of the License at
       *
       * http://www.apache.org/licenses/LICENSE-2.0
       *
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       */
      package org.wildfly.swarm.container;
      
      import org.junit.*;
      import org.wildfly.swarm.Swarm;
      import org.wildfly.swarm.container.runtime.cdi.ProjectStageFactory;
      import org.wildfly.swarm.spi.api.ProjectStage;
      import org.wildfly.swarm.spi.api.SwarmProperties;
      
      import java.util.List;
      import java.util.Map;
      
      import static org.junit.Assert.*;
      
      /**
       * @author Heiko Braun
       * @since 07/04/16
       */
      public class ProjectStagesTest {
      
          @Before
          public void prepareStage() {
              testStages = new ProjectStageFactory().loadStages(
                      ProjectStagesTest.class.getClassLoader().getResourceAsStream("project-stages.yml")
              );
          }
      
          @After
          public void clearProps() {
              // cleanup the props used, otherwise they interfere with followup tests
              for (ProjectStage stage : testStages) {
                  for (String key : stage.getProperties().keySet()) {
                      System.clearProperty(key);
                  }
              }
              System.clearProperty(SwarmProperties.PROJECT_STAGE);
          }
      
          @Test
          public void testParser() {
      
              ProjectStageFactory factory = new ProjectStageFactory();
              List<ProjectStage> stages = factory.loadStages(
                      ProjectStagesTest.class.getClassLoader().getResourceAsStream("project-stages.yml")
              );
      
              Assert.assertEquals(3, stages.size());
      
              for (ProjectStage stage : stages) {
                  System.out.println("["+stage.getName()+"]");
                  Map<String, String> properties = stage.getProperties();
                  assertEquals(6, properties.keySet().size());
      
                  assertTrue("Property is missing", properties.keySet().contains("swarm.magic.enabled"));
                  assertTrue("Property is missing", properties.keySet().contains(SwarmProperties.PORT_OFFSET));
                  properties.entrySet().forEach(e -> System.out.println(e.getKey()+"="+e.getValue()));
              }
      
          }
      
          @Test
          public void testStageConfigurationLoading() throws Exception {
      
              System.setProperty(SwarmProperties.PROJECT_STAGE, "development");
      
              Swarm container = new Swarm()
                      .withStageConfig(
                              ProjectStagesTest.class.getClassLoader().getResource("project-stages.yml")
                      );
      
              container.start();
      
              assertEquals("50", System.getProperty(SwarmProperties.PORT_OFFSET));
              assertEquals("DEBUG", System.getProperty("logger.level"));
      
              container.stop();
          }
      
      
          @Test
          public void testArgsPrecendence() throws Exception {
      
              System.setProperty(SwarmProperties.PROJECT_STAGE, "development");
              System.setProperty(SwarmProperties.PORT_OFFSET, "150");
      
              Swarm container = new Swarm()
                      .withStageConfig(
                              ProjectStagesTest.class.getClassLoader().getResource("project-stages.yml")
                      );
              container.start();
      
              assertEquals("150", System.getProperty(SwarmProperties.PORT_OFFSET));
      
              container.stop();
      
          }
      
          @Test
          public void testUnknownStageConfiguration() throws Exception {
      
              Swarm container = null;
              System.setProperty(SwarmProperties.PROJECT_STAGE, "foobar");
              try {
                  container = new Swarm();
                  container.withStageConfig(ProjectStagesTest.class.getClassLoader().getResource("project-stages.yml"));
                  fail();
              } catch(RuntimeException ex) {
                  // TODO
                  assertEquals(true,ex.getMessage().contains("WFSWARM0003"));
              }
      
          }
      
      /*    @Test
          public void testStageConfigAPI() throws Exception {
      
              Swarm container = new Swarm()
                      .withStageConfig(
                              ProjectStagesTest.class.getClassLoader().getResource("project-stages.yml")
                      )
                      .fraction(new Fraction() {
                          @Override
                          public void initialize(InitContext initContext) {
                              Assert.assertTrue("stage config is not present", initContext.projectStage().isPresent());
                              StageConfig stageConfig = initContext.projectStage().get();
                              Assert.assertEquals("DEBUG", stageConfig.resolve("logger.level").getValue());
      
                              Integer intVal = stageConfig
                                      .resolve(SwarmProperties.PORT_OFFSET)
                                      .as(Integer.class)
                                      .getValue();
      
                              Assert.assertEquals(new Integer(10), intVal);
      
                              Boolean boolVal = stageConfig
                                      .resolve("swarm.magic.enabled")
                                      .as(Boolean.class)
                                      .getValue();
      
                              Assert.assertEquals(Boolean.TRUE, boolVal);
                          }
                      });
      
              container.start().stop();
          }*/
      
          private List<ProjectStage> testStages;
      }
      

      this error is reported

      [WARN] logging not available, logging will not be configured
      Sep 12, 2016 6:39:10 PM org.wildfly.swarm.Swarm loadStageConfiguration
      INFO: WFSWARM0024: Using project stage: development
      Sep 12, 2016 6:39:10 PM org.wildfly.swarm.Swarm withStageConfig
      WARN: WFSWARM0022: Project stage superseded by external configuration null
      Sep 12, 2016 6:39:10 PM org.wildfly.swarm.container.runtime.ServerBootstrapImpl logFraction
      INFO: WFSWARM0018: Installed fraction:                Container - STABLE          org.wildfly.swarm:container:2016.10-SNAPSHOT
      Sep 12, 2016 6:39:10 PM org.wildfly.swarm.container.runtime.ServerBootstrapImpl logFraction
      WARN: WFSWARM0018: Installed fraction:        Arquillian Daemon - UNSTABLE        org.wildfly.swarm:arquillian-daemon:2016.10-SNAPSHOT
      Sep 12, 2016 6:39:10 PM org.wildfly.swarm.container.runtime.ServerBootstrapImpl logFraction
      INFO: WFSWARM0018: Installed fraction:                      MSC - STABLE          org.wildfly.swarm:msc:2016.10-SNAPSHOT
      Sep 12, 2016 6:39:10 PM org.jboss.weld.environment.deployment.discovery.DiscoveryStrategyFactory create
      INFO: WELD-ENV-000020: Using jandex for bean discovery
      Sep 12, 2016 6:39:10 PM org.jboss.weld.bootstrap.WeldStartup startContainer
      INFO: WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
      
      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:659)
      	at org.wildfly.swarm.container.runtime.ServerBootstrapImpl.bootstrap(ServerBootstrapImpl.java:97)
      	at org.wildfly.swarm.Swarm.start(Swarm.java:294)
      	at org.wildfly.swarm.Swarm.start(Swarm.java:272)
      	at org.wildfly.swarm.container.ProjectStagesTest.testStageConfigurationLoading(ProjectStagesTest.java:85)
      

      This error doesn't exist when the test ("org.wildfly.swarm.container.ProjectStagesTest#testStageConfigurationLoading") is executed individually

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                kenfinni Ken Finnigan
                Reporter:
                cmoulliard Charles Moulliard
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: