org.apache.jasper.JasperException: using jstl in jsp embedded jetty

HI,
I am getting the following error  :
org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
	at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:55)
	at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:277)
	at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:75)
	at org.apache.jasper.compiler.TagLibraryInfoImpl.generateTldResourcePath(TagLibraryInfoImpl.java:243)
	at org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:124)
	at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:411)
	at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:469)
	at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1430)
	at org.apache.jasper.compiler.Parser.parse(Parser.java:139)
	at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:227)
	at org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
	at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:199)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
	at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:585)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:363)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
	at org.eclipse.jetty.jsp.JettyJspServlet.service(JettyJspServlet.java:107)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:816)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:566)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1156)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1088)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
	at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:199)
	at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:74)
	at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:168)
	at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
	at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1244)
	at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1027)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:971)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:816)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1156)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1088)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
	at org.eclipse.jetty.server.Server.handle(Server.java:517)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:306)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:245)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
	at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75)
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
	at java.lang.Thread.run(Thread.java:745)

Open in new window


When accessing a page of my spring mvc embedded jetty application.. dont know whats wrong with it..
I have included apache-jstl in pom here is dependency part of  pom.xml :

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.directi.code</groupId>
    <artifactId>snippet</artifactId>
    <version>1.0-SNAPSHOT</version>

    <name>snippet</name>
    <url>http://maven.apache.org</url>

    <properties>
        <java.version>1.7</java.version>
        <spring.version>4.2.1.RELEASE</spring.version>
        <cglib.version>2.2.2</cglib.version>
        <jetty.version>9.3.3.v20150827</jetty.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-annotations</artifactId>
            <version>${jetty.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-webapp</artifactId>
            <version>${jetty.version}</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>apache-jsp</artifactId>
            <version>${jetty.version}</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>apache-jstl</artifactId>
            <version>${jetty.version}</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>

        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.4</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
            <type>jar</type>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib-nodep</artifactId>
            <version>${cglib.version}</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>codemirror</artifactId>
            <version>5.6</version>
        </dependency>

        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.13</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.6.2</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>4.2.1.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.36</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.5</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.12</version>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-dbcp2</artifactId>
            <version>2.1.1</version>
        </dependency>

    </dependencies>

Open in new window


My main java file :

package org.directi.code;

import org.apache.log4j.PropertyConfigurator;
import org.apache.tomcat.InstanceManager;
import org.apache.tomcat.SimpleInstanceManager;
import org.eclipse.jetty.annotations.ServletContainerInitializersStarter;
import org.eclipse.jetty.apache.jsp.JettyJasperInitializer;
import org.eclipse.jetty.plus.annotation.ContainerInitializer;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.webapp.WebAppContext;
import org.springframework.core.io.ClassPathResource;

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

public class AppStart {
    private int port;
    public static Server server;

    public static void main(String[] args) throws Exception {
        String env = System.getProperty("FLOCK_APPS_CONFIG");
        PropertyConfigurator.configure(AppStart.class.getResourceAsStream("/properties/" + env + "/log4j.properties"));
        Properties props = new Properties();
        props.load(AppStart.class.getResourceAsStream("/properties/" + env + "/jetty.properties"));
        int port = Integer.parseInt(props.getProperty("port"));
        AppStart appStart = new AppStart(port);
        System.setProperty("org.apache.jasper.compiler.disablejsr199", "false");

        try {
            appStart.start();
            appStart.waitForInterrupt();
        } finally {
            appStart.stop();
        }
    }

    public AppStart(int port) {
        this.port = port;
    }

    public void start() throws Exception {
        server = new Server();
        ServerConnector connector = connector();
        server.addConnector(connector);
        WebAppContext webAppContext = getWebAppContext();
        server.setHandler(webAppContext);
        server.start();
    }

    private ServerConnector connector() {
        ServerConnector connector = new ServerConnector(server);
        connector.setPort(port);
        return connector;
    }

    private WebAppContext getWebAppContext() throws IOException {
        WebAppContext context = new WebAppContext();
        context.setContextPath("/");
        context.setDescriptor("webapp/WEB-INF/web.xml");
        context.setAttribute("javax.servlet.context.tempdir", getScratchDir());
        context.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
                ".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/.*taglibs.*\\.jar$");
        context.setResourceBase(new ClassPathResource("webapp").getURI().toASCIIString());
        context.setAttribute("org.eclipse.jetty.containerInitializers", jspInitializers());
        context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
        context.addBean(new ServletContainerInitializersStarter(context), true);
        context.addServlet(defaultServletHolder(new ClassPathResource("webapp").getURI()), "/");
        context.setClassLoader(getUrlClassLoader());
        return context;
    }
    private ServletHolder defaultServletHolder(URI baseUri)
    {
        ServletHolder holderDefault = new ServletHolder("default", DefaultServlet.class);
        holderDefault.setInitParameter("resourceBase", baseUri.toASCIIString());
        holderDefault.setInitParameter("dirAllowed", "true");
        return holderDefault;
    }
    private List<ContainerInitializer> jspInitializers() {
        JettyJasperInitializer sci = new JettyJasperInitializer();
        ContainerInitializer initializer = new ContainerInitializer(sci, null);
        List<ContainerInitializer> initializers = new ArrayList<ContainerInitializer>();
        initializers.add(initializer);
        return initializers;
    }

    private ClassLoader getUrlClassLoader() {
        ClassLoader jspClassLoader = new URLClassLoader(new URL[0], this.getClass().getClassLoader());
        return jspClassLoader;
    }

    public void stop() throws Exception {
        if (server != null) {
            server.stop();
        }
    }

    public void waitForInterrupt() throws InterruptedException {
        if (server != null) {
            server.join();
        }
    }

    private File getScratchDir() throws IOException
    {
        File tempDir = new File(System.getProperty("java.io.tmpdir"));
        File scratchDir = new File(tempDir.toString(), "embedded-jetty-jsp");

        if (!scratchDir.exists())
        {
            if (!scratchDir.mkdirs())
            {
                throw new IOException("Unable to create scratch directory: " + scratchDir);
            }
        }
        return scratchDir;
    }
}

Open in new window

For some reason i am unable to use taglibs in my jsp's .
If iremove the line from jsp : <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
Things work...

Thanks
Rohit BajajAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gurpsbassiCommented:
have a read of the this.

It could be a class path issue. The documentation mentions that you need to ensure the jars are picked up in the containers class path before the application.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mccarlIT Business Systems Analyst / Software DeveloperCommented:
Can you remind us again, how are you packaging your application and how are you running it?
0
Rohit BajajAuthor Commented:
HI,
I am starting it using the command :
java -DFLOCK_APPS_CONFIG=dev -jar target/snippet.jar >>./startup.log 2>&1 &

Open in new window


I discovered that the page loads properly when i start the application with Intellij IDEA.

But when using the command line it fails.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Rohit BajajAuthor Commented:
I guess its not able to resolve jstl libraries when using fat jar .
using the following plugins  in pom.xml

 <plugins>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-jspc-maven-plugin</artifactId>
                <version>${jetty.version}</version>
                <executions>
                    <execution>
                        <id>jspc</id>
                        <goals>
                            <goal>jspc</goal>
                        </goals>
                        <configuration>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.4.2</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                </filter>
                            </filters>
                            <transformers>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>org.directi.code.AppStart</mainClass>
                                </transformer>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/spring.handlers</resource>
                                </transformer>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/spring.schemas</resource>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>rpm-maven-plugin</artifactId>
                <version>2.0</version>
                <extensions>true</extensions>
                <configuration>
                    <name>flock-snippets</name>
                    <copyright>2015</copyright>
                    <group>Application/Collectors</group>
                    <projversion>1.0</projversion>
                    <defineStatements>
                        <defineStatement>groupname %{name}</defineStatement>
                        <defineStatement>username %{name}</defineStatement>
                    </defineStatements>
                    <mappings>
                        <mapping>
                            <directoryIncluded>true</directoryIncluded>
                            <directory>/opt/flock-snippets</directory>
                            <username>flock-snippets</username>
                            <groupname>flock-snippets</groupname>
                            <sources>
                                <source>
                                    <location>target/snippet.jar</location>
                                </source>
                            </sources>
                        </mapping>
                        <mapping>
                            <directoryIncluded>true</directoryIncluded>
                            <directory>/opt/flock-snippets</directory>
                            <username>flock-snippets</username>
                            <groupname>flock-snippets</groupname>
                            <sources>
                                <source>
                                    <location>src/main/script/flock-snippets</location>
                                </source>
                            </sources>
                        </mapping>
                        <mapping>
                            <directoryIncluded>false</directoryIncluded>
                            <directory>/etc/init.d</directory>
                            <username>root</username>
                            <groupname>root</groupname>
                            <sources>
                                <source>
                                    <location>src/main/script/init.d/snippet</location>
                                </source>
                            </sources>
                        </mapping>
                    </mappings>
                    <preinstallScriptlet>
                        <scriptFile>src/main/script/pre_deploy.sh</scriptFile>
                        <fileEncoding>utf-8</fileEncoding>
                    </preinstallScriptlet>
                    <postinstallScriptlet>
                        <scriptFile>src/main/script/post_deploy.sh</scriptFile>
                        <fileEncoding>utf-8</fileEncoding>
                    </postinstallScriptlet>
                    <preremoveScriptlet>
                        <scriptFile>src/main/script/pre_remove.sh</scriptFile>
                        <fileEncoding>utf-8</fileEncoding>
                    </preremoveScriptlet>
                    <needarch>noarch</needarch>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <fork>true</fork>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
        </plugins>

Open in new window


I can see the following files getting created : /Users/robinsuri/Checkout/flock-snippets/target/snippet/META-INF/maven/org.apache.taglibs/pom.properties and pom.xml
which gets from apache-jstl declaration in pom file...

But there is probably some issue with the generation of fat jar using maven shade plugin...due to which its unable to resolve taglib.
0
Rohit BajajAuthor Commented:
Any pointers to how can i make it work.. or what things i can try will be great .

Also i tried another approach of precompiling JSPS using jetty-jspc-maven-plugin
After building when i started the application it errored out :
015-11-20 19:26:41 WARN  AbstractLifeCycle:213 - FAILED org.apache.jsp.resources.jsp.edit_jsp@c09b191f==org.apache.jsp.resources.jsp.edit_jsp,-1,false: java.lang.NoClassDefFoundError: org/apache/jasper/runtime/JspSourceImports
java.lang.NoClassDefFoundError: org/apache/jasper/runtime/JspSourceImports
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:487)
	at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:428)
	at org.eclipse.jetty.util.Loader.loadClass(Loader.java:86)
	at org.eclipse.jetty.servlet.BaseHolder.doStart(BaseHolder.java:95)
	at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:347)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
	at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:874)
	at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:346)
	at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1380)
	at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1342)
	at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:772)
	at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:259)
	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:518)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
	at org.eclipse.jetty.server.Server.start(Server.java:405)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:106)
	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
	at org.eclipse.jetty.server.Server.doStart(Server.java:372)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
	at org.directi.code.AppStart.start(AppStart.java:52)
	at org.directi.code.AppStart.main(AppStart.java:35)
Caused by: java.lang.ClassNotFoundException: org.apache.jasper.runtime.JspSourceImports
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 34 more
2015-11-20 19:26:41 DEBUG ServletHandler:879 - EXCEPTION 
java.lang.NoClassDefFoundError: org/apache/jasper/runtime/JspSourceImports
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:487)
	at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:428)
	at org.eclipse.jetty.util.Loader.loadClass(Loader.java:86)
	at org.eclipse.jetty.servlet.BaseHolder.doStart(BaseHolder.java:95)
	at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:347)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
	at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:874)
	at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:346)
	at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1380)
	at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1342)
	at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:772)
	at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:259)
	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:518)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
	at org.eclipse.jetty.server.Server.start(Server.java:405)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:106)
	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
	at org.eclipse.jetty.server.Server.doStart(Server.java:372)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
	at org.directi.code.AppStart.start(AppStart.java:52)
	at org.directi.code.AppStart.main(AppStart.java:35)
Caused by: java.lang.ClassNotFoundException: org.apache.jasper.runtime.JspSourceImports
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 34 more

Open in new window


JspSourceImports class i saw is used inside compiled JSP and its unable to resolve this.
This is really strange.. I couldnt find anything related to JspSourceImports any maven repo which could resolve it...
0
Rohit BajajAuthor Commented:
I am bulding project using mvn package
0
girionisCommented:
Can you do a search for all jar files that contain "jstl" in your file system and add them to the classpath/generated jar file? If this fails then have a look at the classpath IntelliJ is using and use the exact same one. The problem is most likely a classpath issue.
0
Rohit BajajAuthor Commented:
Hi,
I found something on  :
http://stackoverflow.com/questions/6020495/embedded-jetty-fails-to-load-jsp-taglibs-when-classpath-specified-in-jar
It says :

Found the solution. Turns out when embedding Jetty, and not using it to load a web application, some things just don't work as its not standard convention. Extracting the tld files into src/main/resources/META-INF/tld allowed them to be found at runtime when the class path is specified in the jar.


I tried extracting TlD's from taglib jar  and put it under resources. It didnt work..
Any pointers how do i include these tld's into my project as he is suggesting in above post
0
girionisCommented:
Have you tried my suggestion?
0
Rohit BajajAuthor Commented:
Hi,
I placed the taglibs-standard-impl-1.2.5 , taglibs-standard-spec-1.2.5 and apache-jstl-9.2.11.v20150529 jar in my project resources folder so that they automatically get included in the resultant jar..
But it didnt work. I also put the jar inside webapp still it didnt work

Intellij uses the following command which is huge.. i wonder if i can use that  :
/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java -DFLOCK_APPS_CONFIG=config.sample -Didea.launcher.port=7536 "-Didea.launcher.bin.path=/Applications/IntelliJ IDEA 14 CE.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/packager.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/lib/tools.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/jfxswt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Users/robinsuri/Checkout/flock-snippets/target/classes:/Users/robinsuri/.m2/repository/org/springframework/spring-web/4.2.1.RELEASE/spring-web-4.2.1.RELEASE.jar:/Users/robinsuri/.m2/repository/org/springframework/spring-aop/4.2.1.RELEASE/spring-aop-4.2.1.RELEASE.jar:/Users/robinsuri/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar:/Users/robinsuri/.m2/repository/org/springframework/spring-beans/4.2.1.RELEASE/spring-beans-4.2.1.RELEASE.jar:/Users/robinsuri/.m2/repository/org/springframework/spring-context/4.2.1.RELEASE/spring-context-4.2.1.RELEASE.jar:/Users/robinsuri/.m2/repository/org/springframework/spring-core/4.2.1.RELEASE/spring-core-4.2.1.RELEASE.jar:/Users/robinsuri/.m2/repository/commons-logging/commons-logging/1.2/commons-logging-1.2.jar:/Users/robinsuri/.m2/repository/org/springframework/spring-context-support/4.2.1.RELEASE/spring-context-support-4.2.1.RELEASE.jar:/Users/robinsuri/.m2/repository/org/springframework/spring-webmvc/4.2.1.RELEASE/spring-webmvc-4.2.1.RELEASE.jar:/Users/robinsuri/.m2/repository/org/springframework/spring-expression/4.2.1.RELEASE/spring-expression-4.2.1.RELEASE.jar:/Users/robinsuri/.m2/repository/org/apache/commons/commons-lang3/3.4/commons-lang3-3.4.jar:/Users/robinsuri/.m2/repository/cglib/cglib-nodep/2.2.2/cglib-nodep-2.2.2.jar:/Users/robinsuri/.m2/repository/org/webjars/codemirror/5.6/codemirror-5.6.jar:/Users/robinsuri/.m2/repository/org/codehaus/jackson/jackson-mapper-asl/1.9.13/jackson-mapper-asl-1.9.13.jar:/Users/robinsuri/.m2/repository/org/codehaus/jackson/jackson-core-asl/1.9.13/jackson-core-asl-1.9.13.jar:/Users/robinsuri/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.6.2/jackson-databind-2.6.2.jar:/Users/robinsuri/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.6.0/jackson-annotations-2.6.0.jar:/Users/robinsuri/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.6.2/jackson-core-2.6.2.jar:/Users/robinsuri/.m2/repository/org/springframework/spring-jdbc/4.2.1.RELEASE/spring-jdbc-4.2.1.RELEASE.jar:/Users/robinsuri/.m2/repository/org/springframework/spring-tx/4.2.1.RELEASE/spring-tx-4.2.1.RELEASE.jar:/Users/robinsuri/.m2/repository/mysql/mysql-connector-java/5.1.36/mysql-connector-java-5.1.36.jar:/Users/robinsuri/.m2/repository/org/slf4j/slf4j-api/1.7.5/slf4j-api-1.7.5.jar:/Users/robinsuri/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar:/Users/robinsuri/.m2/repository/org/eclipse/jetty/jetty-webapp/9.3.5.v20151012/jetty-webapp-9.3.5.v20151012.jar:/Users/robinsuri/.m2/repository/org/eclipse/jetty/jetty-xml/9.3.5.v20151012/jetty-xml-9.3.5.v20151012.jar:/Users/robinsuri/.m2/repository/org/eclipse/jetty/jetty-servlet/9.3.5.v20151012/jetty-servlet-9.3.5.v20151012.jar:/Users/robinsuri/.m2/repository/org/eclipse/jetty/jetty-security/9.3.5.v20151012/jetty-security-9.3.5.v20151012.jar:/Users/robinsuri/.m2/repository/org/eclipse/jetty/jetty-annotations/9.2.11.v20150529/jetty-annotations-9.2.11.v20150529.jar:/Users/robinsuri/.m2/repository/org/eclipse/jetty/jetty-plus/9.2.11.v20150529/jetty-plus-9.2.11.v20150529.jar:/Users/robinsuri/.m2/repository/org/eclipse/jetty/jetty-jndi/9.2.11.v20150529/jetty-jndi-9.2.11.v20150529.jar:/Users/robinsuri/.m2/repository/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2.jar:/Users/robinsuri/.m2/repository/org/ow2/asm/asm/5.0.1/asm-5.0.1.jar:/Users/robinsuri/.m2/repository/org/ow2/asm/asm-commons/5.0.1/asm-commons-5.0.1.jar:/Users/robinsuri/.m2/repository/org/ow2/asm/asm-tree/5.0.1/asm-tree-5.0.1.jar:/Users/robinsuri/.m2/repository/org/slf4j/slf4j-log4j12/1.7.12/slf4j-log4j12-1.7.12.jar:/Users/robinsuri/.m2/repository/org/eclipse/jetty/jetty-servlets/9.3.5.v20151012/jetty-servlets-9.3.5.v20151012.jar:/Users/robinsuri/.m2/repository/org/eclipse/jetty/jetty-continuation/9.3.5.v20151012/jetty-continuation-9.3.5.v20151012.jar:/Users/robinsuri/.m2/repository/org/eclipse/jetty/jetty-http/9.3.5.v20151012/jetty-http-9.3.5.v20151012.jar:/Users/robinsuri/.m2/repository/org/eclipse/jetty/jetty-util/9.3.5.v20151012/jetty-util-9.3.5.v20151012.jar:/Users/robinsuri/.m2/repository/org/eclipse/jetty/jetty-io/9.3.5.v20151012/jetty-io-9.3.5.v20151012.jar:/Users/robinsuri/.m2/repository/org/eclipse/jetty/jetty-server/9.3.5.v20151012/jetty-server-9.3.5.v20151012.jar:/Users/robinsuri/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar:/Users/robinsuri/.m2/repository/org/eclipse/jetty/apache-jsp/9.2.11.v20150529/apache-jsp-9.2.11.v20150529.jar:/Users/robinsuri/.m2/repository/org/eclipse/jetty/toolchain/jetty-schemas/3.1.M0/jetty-schemas-3.1.M0.jar:/Users/robinsuri/.m2/repository/org/mortbay/jasper/apache-jsp/8.0.9.M3/apache-jsp-8.0.9.M3.jar:/Users/robinsuri/.m2/repository/org/mortbay/jasper/apache-el/8.0.9.M3/apache-el-8.0.9.M3.jar:/Users/robinsuri/.m2/repository/org/eclipse/jetty/orbit/org.eclipse.jdt.core/3.8.2.v20130121/org.eclipse.jdt.core-3.8.2.v20130121.jar:/Users/robinsuri/.m2/repository/org/eclipse/jetty/apache-jstl/9.2.11.v20150529/apache-jstl-9.2.11.v20150529.jar:/Users/robinsuri/.m2/repository/org/apache/taglibs/taglibs-standard-spec/1.2.1/taglibs-standard-spec-1.2.1.jar:/Users/robinsuri/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.1/taglibs-standard-impl-1.2.1.jar:/Users/robinsuri/.m2/repository/commons-dbcp/commons-dbcp/1.4/commons-dbcp-1.4.jar:/Users/robinsuri/.m2/repository/commons-pool/commons-pool/1.5.4/commons-pool-1.5.4.jar:/Applications/IntelliJ IDEA 14 CE.app/Contents/lib/idea_rt.jar" com.intellij.rt.execution.application.AppMain org.directi.code.AppStart

Open in new window



I am attaching file structure inside my jar file which is generated using mvn clean package.
It generates a fat jar  code-snippets.jar
I extracted the jar...
I didnt find any jars inside it instead there were folders like :
File-structure-inside-jar.pngThis folder path is directly inside my extracted jar/META-INF/maven..
Instead of having jar files it has pom.properties and pom.xml for each library i included in pom.xml
0
girionisCommented:
First things first. How do you create your .war file? Inside the .war file there should be a /lib folder (inside WEB-INF), can you put the jstl jar files there?
0
Rohit BajajAuthor Commented:
I am creating a jar file using the command mvn clean package

my pom.xml has the following plugins especially the shade plugin which creates a fat jar :
<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.4.2</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <createDependencyReducedPom>false</createDependencyReducedPom>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                </filter>
                            </filters>
                            <transformers>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>org.yatra.code.AppStart</mainClass>
                                </transformer>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/spring.handlers</resource>
                                </transformer>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/spring.schemas</resource>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

 <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <fork>true</fork>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>

Open in new window


Here is a snapshot of files inside my jar file :
files-inside-jar.png
0
Rohit BajajAuthor Commented:
The question remains unsolved... i will repost it some day later... with some actual code... so that experts can have direct view...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.