TestNG Error - Couldn't find resource on the class path: testng.css
willks Mar 1, 2011 5:15 AMGreets,
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