0

My wildfly server not running after adding the line

@Resource private SessionContext sessionContext;

How to inject Session Context in embeded arquillian with wildfly 8.2 version??? I even tried to add the line

.addAsWebInfResource(new File("D:\wildfly-.2.0.Final\domain\configuration\domain.xml")) mentioning the domain.xml of my wildfly server where I have crated users. but again not able to start the server. Also when I remove the line of injecting SessionContext my server starts normally.

@RunWith(Arquillian.class)

public class CRLManagerTest {

private static final Logger LOGGER = LoggerFactory.getLogger(CRLManagerTest.class);

@Deployment
public static WebArchive createDeployment() {

    WebArchive  webArchive = ShrinkWrap.create(WebArchive.class, "test.war")
            .addClass(CrManagerFacade1.class)
            .addClass(SessionContext.class)
            .addClass(CrManagerFacade.class)
            .addClass(CrManager.class)

            .addAsResource("META-INF/persistence.xml", "META-INF/persistence.xml")
            .addAsWebInfResource(new File("D:\\wildfly-.2.0.Final\\domain\\configuration\\domain.xml"))
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml") .addAsManifestResource("META-INF/persistence.xml", "persistence.xml") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
            ;
    return webArchive;
}
@Resource
private SessionContext sessionContext;

@Test
public void testUpdateReceipt1() throws Exception {
    LOGGER.info(">>>>>>>>>>>>> This is a test");
    Assert.assertEquals("hello","hello");
}

Here is my arquillian.xml

<container qualifier="jboss-managed" default="true">
    <configuration>
        <property name="jbossHome">${jbossHome}</property>          
    </configuration>
</container>

2 Answers2

0

Looks like you're not using the Servlet protocol, so Arquillian isn't doing an http request, which would mean nothing that relies on a servlet or anything in the Request / Session would be available. Wildfly does not use the servlet protocol by default so you need to enable it.

Add this to your arquillian.xml:

    <!-- Sets the protocol which is how Arquillian talks and executes the tests inside the container -->
<defaultProtocol type="Servlet 3.0" />

And this to your pom.xml:

<dependency>
    <groupId>org.jboss.arquillian.protocol</groupId>
    <artifactId>arquillian-protocol-servlet</artifactId>
    <scope>test</scope>
</dependency>
LightGuard
  • 5,298
  • 19
  • 19
0

The correct answer is to add classess to ShrinkWrat.create method.

.addClasses(CRLManagerTest.class, CrManagerFacade.class, CrManager.class)