The jsp scripting currently requires the jsp source files. If the correct classes are at /var/classes and have a newer last modified as the jsp, then the jsp is not recompiled but directly loaded.
Carsten 2012/5/18 sam ” <[email protected]>: > Just to clarify, I wanted to put compiled jsp classes directly under > /var/classes/ (and possibly do not include .jsp files in the bundle or > package at all) so that sling does not have to recompile jsp scripts. > > Is this okay? Has anyone successfully done this? If so, is a simple example > project available? > > Goal is to have `mvn install` install the bundle with compiled jsp classes > as resource under /var/classes. > Or, `mvn package` creates CRX package with /var/classes only (no /apps/..). > > > > On Fri, May 18, 2012 at 3:26 PM, Felix Meschberger <[email protected]>wrote: > >> Hi, >> >> Am 18.05.2012 um 20:45 schrieb sam ”: >> >> > I'm not using maven bundle plugin. >> > This is actually a CQ project that is built as a CRX Package using >> > maven-jar-plugin . >> >> In this case you might want to use the maven-vault-plugin to create the >> content package with the jsps and classes in it. >> >> Regards >> Felix >> >> > >> > Is there a sample project that uses maven-bundle-plugin? I use >> > maven-bundle-plugin to build OSGi bundles only. I never put OSGi bundles >> > and jsp scripts together. >> > Is putting jsp scripts with bundle a common practice? >> > >> > >> > On Fri, May 18, 2012 at 12:43 PM, Paul McMahon <[email protected]> wrote: >> > >> >> If you check out http://sling.apache.org/site/jspc.html and scroll to >> the >> >> bottom you will see a note about deployment: >> >> >> >> The generated JSP classes as well as the Declarative Services descriptor >> >> are automatically copied to the generated bundle jar file if the Maven >> >> Bundle Plugin (from the Apache Felix) project is used to build the >> project >> >> package. >> >> >> >> Paul McMahon >> >> Acquity Group >> >> >> >> >> >> >> >> ________________________________ >> >> From: sam ” <[email protected]> >> >> To: [email protected] >> >> Sent: Friday, May 18, 2012 12:32 PM >> >> Subject: Re: jspc and java.lang.NoClassDefFoundError: >> >> org/apache/sling/commons/classloader/DynamicClassLoader >> >> >> >> <plugin> >> >> <groupId>org.apache.sling</groupId> >> >> <artifactId>maven-jspc-plugin</artifactId> >> >> <executions> >> >> <execution> >> >> <id>compile-jsp</id> >> >> <goals> >> >> <goal>jspc</goal> >> >> </goals> >> >> <configuration> >> >> >> >> <sourceDirectory>${basedir}/src/main/content/jcr_root</sourceDirectory> >> >> </configuration> >> >> </execution> >> >> </executions> >> >> <dependencies> >> >> <dependency> >> >> <groupId>org.apache.sling</groupId> >> >> >> >> <artifactId>org.apache.sling.commons.classloader</artifactId> >> >> <version>1.2.2</version> >> >> </dependency> >> >> </dependencies> >> >> </plugin> >> >> >> >> >> >> How can I put compiled jsp classes to the repository (under >> /var/classes)? >> >> A bunch of curl commands? There are around 1000 jsp/class files. >> >> I don't want to put jsp files but class files only to the repository. >> >> Or, I don't want to have the application compile jsp on the fly. >> >> >> >> >> >> On Wed, May 16, 2012 at 5:13 PM, sam ” <[email protected]> wrote: >> >> >> >>> Hrm.. >> >>> I did build maven-jspc-plugin with commons.classloader as dependency >> with >> >>> runtime scope and compile scope, too. >> >>> And, I used that built plugin to compile my jsp files. >> >>> But both failed with the same error. >> >>> >> >>> I'll try again >> >>> >> >>> On Wed, May 16, 2012 at 4:34 PM, Felix Meschberger <[email protected] >> >>> wrote: >> >>> >> >>>> Hi, >> >>>> >> >>>> Hmm, this sounds like the commons.classloader should be a compile >> >>>> dependency of the jspc plugin such that on runtime the >> >> commons.classloader >> >>>> is visible to the plugin. >> >>>> >> >>>> You might try to add the commons.classloader as a dependency to the >> >>>> plugin declaration and see whether it works. If so, you might create >> an >> >>>> issue asking for the commons.classloader dependency to be explicitly >> >> added >> >>>> to the jspc plugin. >> >>>> >> >>>> Regards >> >>>> Felix >> >>>> >> >>>> Am 16.05.2012 um 18:03 schrieb sam ”: >> >>>> >> >>>>> I modified maven script to include >> >>>>> org.apache.sling.commons.classloader-1.2.2.jar in classpath. >> >>>>> >> >>>>> >> >>>>> exec "$JAVACMD" \ >> >>>>> $MAVEN_OPTS \ >> >>>>> -classpath >> >>>>> >> >>>> >> >> >> "${HOME}/.m2/repository/org/apache/sling/org.apache.sling.commons.classloader/1.2.2/org.apache.sling.commons.classloader-1.2.2.jar:${M2_HOME}/boot/classworlds-1.1.jar" >> >>>>> \ >> >>>>> "-Dclassworlds.conf=${M2_HOME}/bin/m2.conf" \ >> >>>>> "-Dmaven.home=${M2_HOME}" \ >> >>>>> ${CLASSWORLDS_LAUNCHER} $QUOTED_ARGS >> >>>>> >> >>>>> >> >>>>> >> >>>>> Then jspc works without complaining. >> >>>>> Why would jspc use >> >>>> org.apache.sling.commons.classloader.DynamicClassLoader >> >>>>> ? >> >>>>> >> >>>>> Why would DynamicClassLoader have to be added to jvm's classpath ? >> >>>>> >> >>>>> >> >>>>> >> >>>>> >> >>>>> On Wed, May 16, 2012 at 11:14 AM, sam ” <[email protected]> wrote: >> >>>>> >> >>>>>> Hey, >> >>>>>> >> >>>>>> I am using maven-jspc-plugin 2.0.7-SNAPSHOT to compile jsp files. >> >>>>>> >> >>>>>> I get the following error. >> >>>>>> >> >>>>>> $ mvn clean compile >> >>>>>> [INFO] [clean:clean {execution: default-clean}] >> >>>>>> [INFO] [enforcer:enforce {execution: enforce-java}] >> >>>>>> [INFO] [resources:resources {execution: default-resources}] >> >>>>>> [INFO] Using 'UTF-8' encoding to copy filtered resources. >> >>>>>> [INFO] Copying 1 resource >> >>>>>> [INFO] Copying 6 resources to META-INF >> >>>>>> [INFO] Copying 2574 resources to jcr_root >> >>>>>> [INFO] [compiler:compile {execution: default-compile}] >> >>>>>> [INFO] Nothing to compile - all classes are up to date >> >>>>>> [INFO] [jspc:jspc {execution: compile-jsp}] >> >>>>>> [FATAL ERROR] org.apache.sling.maven.jspc.JspcMojo#execute() caused >> a >> >>>>>> linkage error (java.lang.NoClassDefFoundError) and may be >> >> out-of-date. >> >>>>>> Check the realms: >> >>>>>> [FATAL ERROR] Plugin realm = >> >>>>>> >> >> app0.child-container[org.apache.sling:maven-jspc-plugin:2.0.7-SNAPSHOT] >> >>>>>> urls[0] = >> >>>>>> >> >>>> >> >> >> file:/home/sam/.m2/repository/org/apache/sling/maven-jspc-plugin/2.0.7-SNAPSHOT/maven-jspc-plugin-2.0.7-SNAPSHOT.jar >> >>>>>> urls[1] = >> >>>>>> >> >>>> >> >> >> file:/home/sam/.m2/repository/org/apache/sling/org.apache.sling.api/2.2.2/org.apache.sling.api-2.2.2.jar >> >>>>>> urls[2] = >> >>>>>> >> >>>> >> >> >> file:/home/sam/.m2/repository/org/apache/sling/org.apache.sling.scripting.jsp/2.0.18/org.apache.sling.scripting.jsp-2.0.18.jar >> >>>>>> urls[3] = >> >>>>>> >> >>>> >> >> >> file:/home/sam/.m2/repository/org/apache/tomcat/jsp-api/6.0.14/jsp-api-6.0.14.jar >> >>>>>> urls[4] = >> >>>>>> >> >>>> >> >> >> file:/home/sam/.m2/repository/org/apache/tomcat/el-api/6.0.14/el-api-6.0.14.jar >> >>>>>> urls[5] = >> >>>>>> >> >>>> >> >> >> file:/home/sam/.m2/repository/org/apache/tomcat/servlet-api/6.0.14/servlet-api-6.0.14.jar >> >>>>>> urls[6] = >> >>>>>> >> >>>> >> >> >> file:/home/sam/.m2/repository/org/apache/tomcat/jasper-el/6.0.14/jasper-el-6.0.14.jar >> >>>>>> urls[7] = >> >>>>>> >> >>>> >> >> >> file:/home/sam/.m2/repository/org/apache/tomcat/jasper-jdt/6.0.14/jasper-jdt-6.0.14.jar >> >>>>>> urls[8] = >> >>>>>> >> >>>> >> >> >> file:/home/sam/.m2/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar >> >>>>>> urls[9] = >> >>>>>> >> >>>> >> >> >> file:/home/sam/.m2/repository/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1.jar >> >>>>>> urls[10] = >> >>>>>> >> >>>> >> >> >> file:/home/sam/.m2/repository/commons-io/commons-io/1.4/commons-io-1.4.jar >> >>>>>> urls[11] = >> >>>>>> >> >>>> >> >> >> file:/home/sam/.m2/repository/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar >> >>>>>> urls[12] = >> >>>>>> >> >>>> >> >> >> file:/home/sam/.m2/repository/org/apache/maven/maven-archiver/2.0/maven-archiver-2.0.jar >> >>>>>> urls[13] = >> >>>>>> >> >>>> >> >> >> file:/home/sam/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar >> >>>>>> urls[14] = >> >>>>>> >> >>>> >> >> >> file:/home/sam/.m2/repository/org/codehaus/plexus/plexus-archiver/1.0-alpha-3/plexus-archiver-1.0-alpha-3.jar >> >>>>>> urls[15] = >> >>>>>> >> >>>> >> >> >> file:/home/sam/.m2/repository/org/slf4j/slf4j-api/1.5.2/slf4j-api-1.5.2.jar >> >>>>>> urls[16] = >> >>>>>> >> >>>> >> >> >> file:/home/sam/.m2/repository/org/slf4j/slf4j-simple/1.5.2/slf4j-simple-1.5.2.jar >> >>>>>> [FATAL ERROR] Container realm = plexus.core >> >>>>>> urls[0] = file:/home/sam/opt/maven/lib/maven-2.2.1-uber.jar >> >>>>>> [INFO] >> >>>>>> >> >>>> >> ------------------------------------------------------------------------ >> >>>>>> [ERROR] FATAL ERROR >> >>>>>> [INFO] >> >>>>>> >> >>>> >> ------------------------------------------------------------------------ >> >>>>>> [INFO] org/apache/sling/commons/classloader/DynamicClassLoader >> >>>>>> org.apache.sling.commons.classloader.DynamicClassLoader >> >>>>>> [INFO] >> >>>>>> >> >>>> >> ------------------------------------------------------------------------ >> >>>>>> [INFO] Trace >> >>>>>> java.lang.NoClassDefFoundError: >> >>>>>> org/apache/sling/commons/classloader/DynamicClassLoader >> >>>>>> at >> >>>>>> >> >>>> >> >> >> org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.loadTagFile(JspServletWrapper.java:241) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> org.apache.sling.scripting.jsp.jasper.compiler.TagFileProcessor.loadTagFile(TagFileProcessor.java:574) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> org.apache.sling.scripting.jsp.jasper.compiler.TagFileProcessor.access$000(TagFileProcessor.java:49) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> org.apache.sling.scripting.jsp.jasper.compiler.TagFileProcessor$TagFileLoaderVisitor.visit(TagFileProcessor.java:625) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> org.apache.sling.scripting.jsp.jasper.compiler.Node$CustomTag.accept(Node.java:1507) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> org.apache.sling.scripting.jsp.jasper.compiler.Node$Nodes.visit(Node.java:2338) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> org.apache.sling.scripting.jsp.jasper.compiler.Node$Visitor.visitBody(Node.java:2388) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> org.apache.sling.scripting.jsp.jasper.compiler.Node$Visitor.visit(Node.java:2394) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> org.apache.sling.scripting.jsp.jasper.compiler.Node$Root.accept(Node.java:489) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> org.apache.sling.scripting.jsp.jasper.compiler.Node$Nodes.visit(Node.java:2338) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> org.apache.sling.scripting.jsp.jasper.compiler.TagFileProcessor.loadTagFiles(TagFileProcessor.java:643) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> org.apache.sling.scripting.jsp.jasper.compiler.Compiler.generateJava(Compiler.java:191) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> org.apache.sling.scripting.jsp.jasper.compiler.Compiler.compile(Compiler.java:311) >> >>>>>> at >> >>>> org.apache.sling.maven.jspc.JspcMojo.processFile(JspcMojo.java:362) >> >>>>>> at >> >>>>>> >> >> org.apache.sling.maven.jspc.JspcMojo.executeInternal(JspcMojo.java:316) >> >>>>>> at org.apache.sling.maven.jspc.JspcMojo.execute(JspcMojo.java:228) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180) >> >>>>>> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328) >> >>>>>> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138) >> >>>>>> at org.apache.maven.cli.MavenCli.main(MavenCli.java:362) >> >>>>>> at >> >>>>>> >> >> org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60) >> >>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) >> >>>>>> at java.lang.reflect.Method.invoke(Method.java:597) >> >>>>>> at >> >>>> org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) >> >>>>>> at org.codehaus.classworlds.Launcher.launch(Launcher.java:255) >> >>>>>> at >> >>>>>> >> org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430) >> >>>>>> at org.codehaus.classworlds.Launcher.main(Launcher.java:375) >> >>>>>> Caused by: java.lang.ClassNotFoundException: >> >>>>>> org.apache.sling.commons.classloader.DynamicClassLoader >> >>>>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:202) >> >>>>>> at java.security.AccessController.doPrivileged(Native Method) >> >>>>>> at java.net.URLClassLoader.findClass(URLClassLoader.java:190) >> >>>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:306) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:255) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:274) >> >>>>>> at >> >>>>>> >> >>>> >> >> >> org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.java:214) >> >>>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:247) >> >>>>>> ... 35 more >> >>>>>> >> >>>>>> >> >>>>>> >> >>>>>> How do you use jspc plugin? >> >>>>>> >> >>>>>> >> >>>>>> my pom.xml is >> >>>>>> <build> >> >>>>>> <plugins> >> >>>>>> <plugin> >> >>>>>> <groupId>org.apache.sling</groupId> >> >>>>>> <artifactId>maven-jspc-plugin</artifactId> >> >>>>>> <executions> >> >>>>>> <execution> >> >>>>>> <id>compile-jsp</id> >> >>>>>> <goals> >> >>>>>> <goal>jspc</goal> >> >>>>>> </goals> >> >>>>>> <configuration> >> >>>>>> >> >>>>>> >> >> <sourceDirectory>${basedir}/src/main/content/jcr_root</sourceDirectory> >> >>>>>> </configuration> >> >>>>>> </execution> >> >>>>>> </executions> >> >>>>>> </plugin> >> >>>>>> </plugins> >> >>>>>> </build> >> >>>>>> >> >>>>>> And, I get the same error even if I put this in dependencies: >> >>>>>> <dependency> >> >>>>>> <groupId>org.apache.sling</groupId> >> >>>>>> >> >>>> <artifactId>org.apache.sling.commons.classloader</artifactId> >> >>>>>> <version>1.2.2</version> >> >>>>>> </dependency> >> >>>>>> >> >>>>>> >> >>>>>> >> >>>>>> >> >>>>>> >> >>>>>> >> >>>> >> >>>> >> >>> >> >> >> >> -- Carsten Ziegeler [email protected]
