6 Replies Latest reply on Mar 29, 2011 6:48 AM by willks

    TestNG Error - Couldn't find resource on the class path: testng.css

    willks

      Greets,    

            I've been bashing my head in trying to figure out this issue for the last 3 nights (moonlighting is a beautiful thing - right?!). For the record, I'm trying to migrage of Spring now that I found Arquillian - many things in Spring (like the awful @Configuration class) forced my hand on this. However, it's not as easy as the Arquillian CDI examples go - well, they probably are but at least not for me! I've been following documentation and numerous posts all round the 'webz trying to figure this out... but to no avail. So I will start with some detail:

       

       

      Entities:

      {code}

      /**

      * A base entity supporting the common fields for all entities

      */

      @MappedSuperclass

      public abstract class BaseEntity implements Serializable{

       

       

          private static final long serialVersionUID = -7979088681300801112L;

          /**

           * Primary key for entity

           */

          @Id

          @GeneratedValue(strategy = GenerationType.TABLE, generator = "sequences")

          @TableGenerator(name = "sequences", initialValue = 1, allocationSize = 50)

          private Long id;

       

       

          /**

           * Version of object, supporting optimistic lock

           */

          @Column (name = "opt_lock")

          @Version()

          private Long optimisticLock;

       

       

          /**

           * Flag to disable entity

           */

          @Column

          private boolean deleted = false;

       

          /**

           * Audit

           */

          @Embedded

          private Audit audit;

       

          public Long getId() {

              return id;

          }

       

          public Long getOptimisticLock() {

              return optimisticLock;

          }

      }

       

      /**

      * Test entity

      */

      @Entity()

      @Table(name = "test_entity")

      public class BaseEntityTest extends BaseEntity{

          @Column(length = 16)

          private String testColumn;

       

       

          public String getTestColumn() {

              return testColumn;

          }

       

       

          public void setTestColumn(String testColumn) {

              this.testColumn = testColumn;

          }

      }

       

      {code}

       

      The service (only one EJB with a base class)

       

      {code}

      /**

      Test EJB

      */

      @Singleton(name = "baseServiceTest")

      public class BaseServiceTestImpl extends BaseServiceImpl<BaseEntityTest> {

          @PersistenceContext(unitName = "testUnit")

          private EntityManager entityManager;

       

       

          @Override

          public EntityManager getEntityManager() {

              return entityManager;

          }

      }

       

      /**

      * Default implementation of BaseService

      */

      @TransactionAttribute(value = TransactionAttributeType.SUPPORTS)

      public abstract class BaseServiceImpl<T extends BaseEntity> implements BaseService<T> {

       

          private Class<T> managedClass;

       

          @EJB(beanName = "baseDAO")

          private BaseDAO baseDAO;

       

          /**

           * Get the parent entity manager

           * @return

           */

          public abstract EntityManager getEntityManager();

       

          @Override

          @TransactionAttribute(value = TransactionAttributeType.REQUIRED)

          public T save(T entity) {

              return baseDAO.save(getEntityManager(), entity);

          }

      }

      {code}

       

      Finally, the test:

      {code}

       

      public class BaseServiceTest extends Arquillian {

       

         @Deployment

         public static Archive<?> createTestArchive() {

            return ShrinkWrap.create(JavaArchive.class, "test.jar")

                      .addClass(BaseEntityTest.class)

                      .addClass(BaseEntity.class)

                      .addClass(Audit.class)

                      .addManifestResource("test-beans.xml", ArchivePaths.create("beans.xml"))

                      .addManifestResource("test-persistence.xml", ArchivePaths.create("persistence.xml"))

                      .addManifestResource(new ByteArrayAsset("<beans/>".getBytes()), ArchivePaths.create("beans.xml"));

         }

       

       

          @EJB(beanName = "baseServiceTest")

          private BaseService<BaseEntityTest> baseService;

       

       

          @Test

          public void testSave() throws Exception{

              BaseEntityTest baseEntityTest = new BaseEntityTest();

              baseEntityTest.setTestColumn("test value");

       

       

              //Save the test entity

              baseEntityTest = baseService.save(baseEntityTest);

              // Check nulls!

              Assert.assertNotNull(baseEntityTest.getId());

          }

      }

       

       

      {code}

       

      Now, the pom.xml:

       

      {code:xml}

       

       

      <project

              xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"

              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

              xmlns="http://maven.apache.org/POM/4.0.0">

       

              <dependency>

                  <groupId>org.hibernate.javax.persistence</groupId>

                  <artifactId>hibernate-jpa-2.0-api</artifactId>

                  <version>1.0.0.Final</version>

                  <scope>provided</scope>

              </dependency>

              <!-- Test -->

              <dependency>

                  <groupId>org.jboss.arquillian</groupId>

                  <artifactId>arquillian-testng</artifactId>

                  <version>1.0.0.Alpha</version>

                  <scope>test</scope>

              </dependency>

              <dependency>

                  <groupId>org.testng</groupId>

                  <artifactId>testng</artifactId>

                  <version>5.12.1</version>

                  <scope>test</scope>

              </dependency>

          </dependencies>

          <profiles>

              <profile>

                  <id>jbossas-remote-6</id>

                  <activation>

                      <activeByDefault>true</activeByDefault>

                  </activation>

                  <dependencies>

                      <dependency>

                          <groupId>org.jboss.arquillian.container</groupId>

                          <artifactId>arquillian-jbossas-remote-6</artifactId>

                          <version>${arquillian.version}</version>

                          <scope>test</scope>

                      </dependency>

                      <dependency>

                          <groupId>org.jboss.spec</groupId>

                          <artifactId>jboss-javaee-6.0</artifactId>

                          <version>1.0.0.Final</version>

                          <type>pom</type>

                          <scope>provided</scope>

                      </dependency>

                      <dependency>

                          <groupId>org.jboss.jbossas</groupId>

                          <artifactId>jboss-as-client</artifactId>

                          <version>6.0.0.Final</version>

                          <scope>provided</scope>

                          <type>pom</type>

                      </dependency>

                  </dependencies>

                  <build>

                      <testResources>

                          <testResource>

                              <directory>src/test/</directory>

                          </testResource>

                      </testResources>

                      <plugins>

                          <plugin>

                              <groupId>org.apache.maven.plugins</groupId>

                              <artifactId>maven-surefire-plugin</artifactId>

                              <configuration>

                                  <includes>

                                      <include>**/*.java</include>

                                  </includes>

                              </configuration>

                          </plugin>

                      </plugins>

                  </build>

              </profile>

          </profiles>

          <repositories>

              <repository>

                  <id>Jboss</id>

                  <url>http://repository.jboss.org/nexus/content/groups/public/</url>

              </repository>

              <repository>

                  <id>PublicJboss</id>

                  <url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>

              </repository>

              <repository>

                  <id>PublicJbossSnapshot3rdParty</id>

                  <url>http://repository.jboss.org/nexus/content/groups/public-thirdparty-snapshots/</url>

              </repository>

          </repositories>

      </project>

       

      {code}

       

       

      When executing through command line, I always get a fail in the server.log:

       

      2011-03-01 20:14:40,385 ERROR [STDERR] (http-127.0.0.1-8080-1) Couldn't find resource on the class path: testng.css

       

      But, the testSave() method is enver even reached. What is more confusing is this:

       

      {noformat}

      2011-03-01 20:14:38,340 [main] DEBUG  - Start: names=[test.war]

      2011-03-01 20:14:40,290 [main] DEBUG  - End start: names=[test.war]

      2011-03-01 20:14:40,290 [main] DEBUG  - removed SocketClientInvoker[2a44b7f7, socket://127.0.0.1:4446] from registry

      2011-03-01 20:14:40,290 [main] DEBUG  - SocketClientInvoker[2a44b7f7, socket://127.0.0.1:4446] disconnecting ...

      2011-03-01 20:14:40,291 [main] DEBUG  - Client[768981123:5c4oa2z-8jp3of-gkqlpz8f-1-gkqlq0e4-c] is disconnected

      2011-03-01 20:14:40,408 [main] DEBUG  - Client[1151109057:5c4oa2z-8jp3of-gkqlpz8f-1-gkqlq1zs-e].connect(null)

      2011-03-01 20:14:40,415 [main] DEBUG  - SocketClientInvoker[94b318, socket://127.0.0.1:4446] setting enableTcpNoDelay to true

      2011-03-01 20:14:40,415 [main] DEBUG  - SocketClientInvoker[94b318, socket://127.0.0.1:4446] constructed

      2011-03-01 20:14:40,415 [main] DEBUG  - SocketClientInvoker[94b318, socket://127.0.0.1:4446] setting enableTcpNoDelay to true

      2011-03-01 20:14:40,415 [main] DEBUG  - SocketClientInvoker[94b318, socket://127.0.0.1:4446] connecting

      2011-03-01 20:14:40,415 [main] DEBUG  - Creating semaphore with size 50

      2011-03-01 20:14:40,415 [main] DEBUG  - SocketClientInvoker[94b318, socket://127.0.0.1:4446] connected

      2011-03-01 20:14:40,415 [main] DEBUG  - Client[1151109057:5c4oa2z-8jp3of-gkqlpz8f-1-gkqlq1zs-e] connected to InvokerLocator [socket://127.0.0.1:4446/?dataType=invocation&enableTcpNoDelay=true&marshaller=org.jboss.invocation.unified.marshall.InvocationMarshaller&unmarshaller=org.jboss.invocation.unified.marshall.InvocationUnMarshaller]

      2011-03-01 20:14:40,415 [main] DEBUG  - Client[1151109057:5c4oa2z-8jp3of-gkqlpz8f-1-gkqlq1zs-e] is connected

      2011-03-01 20:14:40,422 [main] DEBUG  - removed SocketClientInvoker[94b318, socket://127.0.0.1:4446] from registry

      2011-03-01 20:14:40,423 [main] DEBUG  - SocketClientInvoker[94b318, socket://127.0.0.1:4446] disconnecting ...

      2011-03-01 20:14:40,423 [main] DEBUG  - Client[1151109057:5c4oa2z-8jp3of-gkqlpz8f-1-gkqlq1zs-e] is disconnected

      2011-03-01 20:14:40,423 [main] DEBUG  - Calling remoting server with locator of: InvokerLocator [socket://127.0.0.1:4446/?dataType=invocation&enableTcpNoDelay=true&marshaller=org.jboss.invocation.unified.marshall.InvocationMarshaller&unmarshaller=org.jboss.invocation.unified.marshall.InvocationUnMarshaller]

      2011-03-01 20:14:40,423 [main] DEBUG  - Client[91819241:5c4oa2z-8jp3of-gkqlpz8f-1-gkqlq207-g].connect(null)

      2011-03-01 20:14:40,430 [main] DEBUG  - SocketClientInvoker[4e3e97cd, socket://127.0.0.1:4446] setting enableTcpNoDelay to true

      2011-03-01 20:14:40,430 [main] DEBUG  - SocketClientInvoker[4e3e97cd, socket://127.0.0.1:4446] constructed

      2011-03-01 20:14:40,430 [main] DEBUG  - SocketClientInvoker[4e3e97cd, socket://127.0.0.1:4446] setting enableTcpNoDelay to true

      2011-03-01 20:14:40,430 [main] DEBUG  - SocketClientInvoker[4e3e97cd, socket://127.0.0.1:4446] connecting

      2011-03-01 20:14:40,430 [main] DEBUG  - Creating semaphore with size 50

      2011-03-01 20:14:40,430 [main] DEBUG  - SocketClientInvoker[4e3e97cd, socket://127.0.0.1:4446] connected

      2011-03-01 20:14:40,430 [main] DEBUG  - Client[91819241:5c4oa2z-8jp3of-gkqlpz8f-1-gkqlq207-g] connected to InvokerLocator [socket://127.0.0.1:4446/?dataType=invocation&enableTcpNoDelay=true&marshaller=org.jboss.invocation.unified.marshall.InvocationMarshaller&unmarshaller=org.jboss.invocation.unified.marshall.InvocationUnMarshaller]

      2011-03-01 20:14:40,430 [main] DEBUG  - Client[91819241:5c4oa2z-8jp3of-gkqlpz8f-1-gkqlq207-g] is connected

      2011-03-01 20:14:40,430 [main] DEBUG  - Begin stop: names=[test.war]

      2011-03-01 20:14:40,577 [main] DEBUG  - End stop

      2011-03-01 20:14:40,577 [main] DEBUG  - removed SocketClientInvoker[4e3e97cd, socket://127.0.0.1:4446] from registry

      2011-03-01 20:14:40,577 [main] DEBUG  - SocketClientInvoker[4e3e97cd, socket://127.0.0.1:4446] disconnecting ...

      2011-03-01 20:14:40,577 [main] DEBUG  - Client[91819241:5c4oa2z-8jp3of-gkqlpz8f-1-gkqlq207-g] is disconnected

      2011-03-01 20:14:40,577 [main] DEBUG  - Client[93608538:5c4oa2z-8jp3of-gkqlpz8f-1-gkqlq24h-i].connect(null)

      2011-03-01 20:14:40,584 [main] DEBUG  - SocketClientInvoker[4eb7cd92, socket://127.0.0.1:4446] setting enableTcpNoDelay to true

      2011-03-01 20:14:40,584 [main] DEBUG  - SocketClientInvoker[4eb7cd92, socket://127.0.0.1:4446] constructed

      2011-03-01 20:14:40,584 [main] DEBUG  - SocketClientInvoker[4eb7cd92, socket://127.0.0.1:4446] setting enableTcpNoDelay to true

      2011-03-01 20:14:40,584 [main] DEBUG  - SocketClientInvoker[4eb7cd92, socket://127.0.0.1:4446] connecting

      2011-03-01 20:14:40,584 [main] DEBUG  - Creating semaphore with size 50

      2011-03-01 20:14:40,584 [main] DEBUG  - SocketClientInvoker[4eb7cd92, socket://127.0.0.1:4446] connected

      2011-03-01 20:14:40,584 [main] DEBUG  - Client[93608538:5c4oa2z-8jp3of-gkqlpz8f-1-gkqlq24h-i] connected to InvokerLocator [socket://127.0.0.1:4446/?dataType=invocation&enableTcpNoDelay=true&marshaller=org.jboss.invocation.unified.marshall.InvocationMarshaller&unmarshaller=org.jboss.invocation.unified.marshall.InvocationUnMarshaller]

      2011-03-01 20:14:40,584 [main] DEBUG  - Client[93608538:5c4oa2z-8jp3of-gkqlpz8f-1-gkqlq24h-i] is connected

      2011-03-01 20:14:40,592 [main] DEBUG  - removed SocketClientInvoker[4eb7cd92, socket://127.0.0.1:4446] from registry

      2011-03-01 20:14:40,592 [main] DEBUG  - SocketClientInvoker[4eb7cd92, socket://127.0.0.1:4446] disconnecting ...

      2011-03-01 20:14:40,592 [main] DEBUG  - Client[93608538:5c4oa2z-8jp3of-gkqlpz8f-1-gkqlq24h-i] is disconnected

      2011-03-01 20:14:40,592 [main] DEBUG  - Calling remoting server with locator of: InvokerLocator [socket://127.0.0.1:4446/?dataType=invocation&enableTcpNoDelay=true&marshaller=org.jboss.invocation.unified.marshall.InvocationMarshaller&unmarshaller=org.jboss.invocation.unified.marshall.InvocationUnMarshaller]

      2011-03-01 20:14:40,592 [main] DEBUG  - Client[2054019297:5c4oa2z-8jp3of-gkqlpz8f-1-gkqlq24w-k].connect(null)

      2011-03-01 20:14:40,598 [main] DEBUG  - SocketClientInvoker[41b9da92, socket://127.0.0.1:4446] setting enableTcpNoDelay to true

      2011-03-01 20:14:40,599 [main] DEBUG  - SocketClientInvoker[41b9da92, socket://127.0.0.1:4446] constructed

      2011-03-01 20:14:40,599 [main] DEBUG  - SocketClientInvoker[41b9da92, socket://127.0.0.1:4446] setting enableTcpNoDelay to true

      2011-03-01 20:14:40,599 [main] DEBUG  - SocketClientInvoker[41b9da92, socket://127.0.0.1:4446] connecting

      2011-03-01 20:14:40,599 [main] DEBUG  - Creating semaphore with size 50

      2011-03-01 20:14:40,599 [main] DEBUG  - SocketClientInvoker[41b9da92, socket://127.0.0.1:4446] connected

      2011-03-01 20:14:40,599 [main] DEBUG  - Client[2054019297:5c4oa2z-8jp3of-gkqlpz8f-1-gkqlq24w-k] connected to InvokerLocator [socket://127.0.0.1:4446/?dataType=invocation&enableTcpNoDelay=true&marshaller=org.jboss.invocation.unified.marshall.InvocationMarshaller&unmarshaller=org.jboss.invocation.unified.marshall.InvocationUnMarshaller]

      2011-03-01 20:14:40,599 [main] DEBUG  - Client[2054019297:5c4oa2z-8jp3of-gkqlpz8f-1-gkqlq24w-k] is connected

      2011-03-01 20:14:40,599 [main] DEBUG  - Begin remove: names=[test.war]

      2011-03-01 20:14:40,602 [main] DEBUG  - End remove

      2011-03-01 20:14:40,602 [main] DEBUG  - removed SocketClientInvoker[41b9da92, socket://127.0.0.1:4446] from registry

      2011-03-01 20:14:40,602 [main] DEBUG  - SocketClientInvoker[41b9da92, socket://127.0.0.1:4446] disconnecting ...

      2011-03-01 20:14:40,602 [main] DEBUG  - Client[2054019297:5c4oa2z-8jp3of-gkqlpz8f-1-gkqlq24w-k] is disconnected

      Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.121 sec

       

       

      Results :

       

       

      Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

       

       

      [INFO] ------------------------------------------------------------------------

      [INFO] BUILD SUCCESSFUL

      [INFO] ------------------------------------------------------------------------

      [INFO] Total time: 15 seconds

      [INFO] Finished at: Tue Mar 01 20:14:41 EST 2011

      [INFO] Final Memory: 146M/301M

       

      {noformat}

       

      Ok - so from the servier logs, the only error is:

       

      2011-03-01 20:14:40,385 ERROR [STDERR] (http-127.0.0.1-8080-1) Couldn't find resource on the class path: testng.css

       

      And, the testSave() method is never called (using debug modes and attaching to running jBoss instance - and, also using 'System.out.prinln'. The test method is NEVER reached. So my problem seems to be the missing testng.css. I've followed every possible example but am thinking of going for the jUnit framework now. Does anyone know - or know of - or have any definitive documentation on how to get something like this going?

       

       

      EDIT: Apologies about the formatting, I am using the tags, but it is not showing up as I thought it would

        • 1. TestNG Error - Couldn't find resource on the class path: testng.css
          willks

          Team has decided Spring 3 is the next choice for compliance. Compliance in this case means that 99% of developers know how to use it and we can quickly hire for (assuming XML configuration). Compliance in their minds mean that tests work (strangely I agree that tests should work).

           

          [INFO] BUILD SUCCESSFUL

           

          This is the straw that broke the camel's back. In Spring "[INFO] BUILD SUCCESSFUL" is good.

           

          With Arquillian/jBoss 6/TestNG it means "something happened, something really did happen - but we don't know what it was so we assume it worked"

           

           

          I know it did not work - still, I want to know what is wrong with my code. We can't just replace spring because it works!

          • 2. TestNG Error - Couldn't find resource on the class path: testng.css
            kpiwko

            Hi,

             

            could you try running your test using newest releseas versions of Arquillian (1.0.0.Alpha4.SP1), TestNG (5.14.x) and Surefire (2.7.2) plugin?

            If you have time, it would be awesome if you could build Arquillian TestNG from source at https://github.com/arquillian/arquillian/tree/next using https://github.com/shrinkwrap/shrinkwrap/tree/SHRINKWRAP-140, which incorporate massive changes going into Arquillian 1.0.0.Beta1 release and test if this can be reproduced with new TestNG runner.

            • 3. TestNG Error - Couldn't find resource on the class path: testng.css
              aslak

              Not sure if that is your real pom, but it seems to be missing the arquillian.version property, and the arquillian-testng artifact has v. 1.0.0.Alpha ?

               

              You can ignore the testng.css error, it does not cause your test to fail. (trying to find some resources when writing out the reports on the server side, not used / needed)

               

              What does the server log say?

              • 4. TestNG Error - Couldn't find resource on the class path: testng.css
                willks

                Apologies with my 'Charlie Sheen' episode - guess I got caught up with all the media bombardment

                 

                Ok here is my properties block:

                 

                <arquillian.version>1.0.0.Alpha4.SP1</arquillian.version>

                 

                As far as I saw when I wrote the tests, this was the latest version available. I'll give this another good round of testing again.

                 

                Thanks

                • 5. TestNG Error - Couldn't find resource on the class path: testng.css
                  aslak

                  I am supericed that this runs successfully.

                   

                  You seem to be missing items from your deployment definition, e.g. the actual EJB: BaseService.

                  You are also adding the beans.xml twice, once from file then as a empty item. This result might be the same, but probably not what you intended.

                   

                  If you can zip up the project I can have a look at it.

                   

                  ps: The latest 'real' Arquillian release is Alpha4, the Alpha4.SP1 is a special 'internal' OSGi releated release for the OSGi team and should not really be used by others. We're working on merging the trees.

                  1 of 1 people found this helpful
                  • 6. TestNG Error - Couldn't find resource on the class path: testng.css
                    willks

                    Ok I forgot to post a follow up. After upgrading to 1.0.0.Alpha5 everything started working as expected - well, it just exposed some bugs in my code also (@Inject vs @EJB in the test for instance).

                     

                    Though I have it working I have some concerns about my POM files, but  I will post this as a separate issue.

                     

                    Thanks though!