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&containerType=14&container=2114]
_______________________________________________ jboss-user mailing list [email protected] https://lists.jboss.org/mailman/listinfo/jboss-user
