[JBoss Microcontainer] - Using a deployer to add jars to a webapp classpath.
by Stan Silvert
Stan Silvert [http://community.jboss.org/people/stan.silvert%40jboss.com] created the discussion
"Using a deployer to add jars to a webapp classpath."
To view the discussion, visit: http://community.jboss.org/message/536136#536136
--------------------------------------------------------------
In AS5 this was fairly straightforward. But in AS6 the same code doesn't work.
I want to add the JSF impl jars on the fly using a JSFDeployer. The reason is that I want to allow different JSF impls or no impl at all.
I did the following:
* Removed jsf-libs directory from the classpath in jbossweb.sar/META-INF/jboss-structure.xml
* extend AbstractSimpleVFSRealDeployer<JBossWebMetaData>
* In constructor, setStage(DeploymentStages.POST_PARSE)
* In deploy(VFSDeploymentUnit unit, JBossWebMetaData metaData), do this:
{code}private void addClasspath(VFSDeploymentUnit unit, URL url) throws MalformedURLException
{
// note: url points to the directory where the JSF impl jars live
try
{
// add jar files if url is a directory
if (vFile.isDirectory())
{
for (VirtualFile jarFile : vFile.getChildrenRecursively(JAR_FILTER))
{
unit.addClassPath(jarFile);
System.out.println("$2 Added " + jarFile + " to classpath for " + unit.getName());
}
}
}
catch (IOException e)
{
log.warn("Unable to add URL to classpath: " + url.toString());
}
catch (URISyntaxException e)
{
log.warn("Unable to add URL to classpath: " + url.toString());
}
}{code}
The System.out shows me that the code found all the correct jars and called unit.AddClassPath().
{quote}14:13:35,261 INFO [STDOUT] $2 Added "/C:/projects/astrunk/build/target/jboss-6.0.0-SNAPSHOT/server/default/deployers/jsf.deployer/Mojarra-2.0/jsf-api.jar" to classpath for vfs:///C:/projects/astrunk/build/target/jboss-6.0.0-SNAPSHOT/server/default/deploy/jboss-jsf-20test-jsfunit.war
14:13:35,267 INFO [STDOUT] $2 Added "/C:/projects/astrunk/build/target/jboss-6.0.0-SNAPSHOT/server/default/deployers/jsf.deployer/Mojarra-2.0/jsf-impl.jar" to classpath for vfs:///C:/projects/astrunk/build/target/jboss-6.0.0-SNAPSHOT/server/default/deploy/jboss-jsf-20test-jsfunit.war{quote}
But in AS6, Tomcat is no longer able to load the JSF impl classes. The only reason it finds JBossJSFConfigureListener is because I unjarred the class and put it in the root of deployers/jsf.deployer:
{quote}14:13:54,446 INFO [TomcatDeployment] deploy, ctxPath=/jboss-jsf-20test-jsfunit
14:13:54,507 ERROR [[/jboss-jsf-20test-jsfunit]] Error configuring application listener of class org.jboss.jsf.integration.config.JBossJSFConfigureListener: java.lang.NoClassDefFoundError: com/sun/faces/config/ConfigureListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at org.jboss.classloader.spi.base.BaseClassLoader.access$200(BaseClassLo
ader.java:70)
at org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.
java:668)
at org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.
java:627)
at java.security.AccessController.doPrivileged(Native Method)
at org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseC
lassLoader.java:626)
at org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseC
lassLoader.java:603){quote}
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/536136#536136]
Start a new discussion in JBoss Microcontainer at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
16 years
Re: [jboss-user] [JBoss Tools] - Confortable testing with SWTBot
by Denis Golovin
Denis Golovin [http://community.jboss.org/people/dgolovin] commented on the document
"Confortable testing with SWTBot"
To view all comments on this document, visit: http://community.jboss.org/docs/DOC-15111#comment-3094
--------------------------------------------------
You have couple different options to consider for to achieve the same:
1. start vncserver
2. create virtual buffer using Xvfb
After you have created new display just pass display number as local environment variable in your command line like DISPLAY=:N ${your-command-line-here} and you'll never see your eclipse workbench window :) But if you need to follow tests for a while or just check what is going on from time to time you can use vncviewer or xwud for first or second option accordingly.
--------------------------------------------------
16 years