1

I try to run Web app locally following all instructions in Canvas Developer Guide. But get next exception:

HTTP ERROR 500

Problem accessing /examples/hello-world/index.jsp. Reason:

PWC6033: Unable to compile class for JSP

PWC6199: Generated servlet error: The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files

PWC6199: Generated servlet error: The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files

Caused by:

org.apache.jasper.JasperException: PWC6033: Unable to compile class for JSP

PWC6199: Generated servlet error: The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files

PWC6199: Generated servlet error: The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files

at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:123)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:296)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:376)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:437)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:608)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:360)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:486)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:380)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:565)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:479)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:521)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1031)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:406)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:965)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
at org.eclipse.jetty.server.Server.handle(Server.java:349)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:449)
at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:47)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:910)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:634)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:66)
at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:254)
at org.eclipse.jetty.server.ssl.SslSocketConnector$SslConnectorEndPoint.run(SslSocketConnector.java:665)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
at java.lang.Thread.run(Unknown Source)

Powered by Jetty://


My index.jsp :

"<%@ page import="canvas.SignedRequest" %>
<%@ page import="java.util.Map" %>
<%
    // Pull the signed request out of the request body and verify/decode it.
    Map<String, String[]> parameters = request.getParameterMap();
    String[] signedRequest = parameters.get("signed_request");
    if (signedRequest == null) {%>
        This App must be invoked via a signed request!<%
        return;
    }
    String yourConsumerSecret=System.getenv("CANVAS_CONSUMER_SECRET");
    //String yourConsumerSecret="1818663124211010887";
    String signedRequestJson = SignedRequest.verifyAndDecodeAsJson(signedRequest[0], yourConsumerSecret);
%>"

"

<title>Hello World Canvas Example</title>

<link rel="stylesheet" type="text/css" href="/sdk/css/canvas.css" />

<!-- Include all the canvas JS dependencies in one file -->
<script type="text/javascript" src="/sdk/js/canvas-all.js"></script>
<!-- Third part libraries, substitute with your own -->
<script type="text/javascript" src="/scripts/json2.js"></script>

<script>
    if (self === top) {
        // Not in Iframe
        alert("This canvas app must be included within an iframe");
    }

    Sfdc.canvas(function() {
        var sr = JSON.parse('<%=signedRequestJson%>');
        // Save the token
        Sfdc.canvas.oauth.token(sr.oauthToken);
        Sfdc.canvas.byId('username').innerHTML = sr.context.user.fullName;
    });

</script>

<h1>Hello <span id='username'></span></h1>

I think maybe anything wrong with building app, but actually I don't know

pom.xml :

" < 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/maven-v4_0_0.xsd" >

<modelVersion>4.0.0</modelVersion>
<groupId>sfdc</groupId>
<version>1.0-SNAPSHOT</version>
<name>Salesforce Canvas Framework SDK</name>
<artifactId>sfdc-canvas-sdk</artifactId>

<properties>
    <java.version>1.7</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <!-- Servlet API -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
    </dependency>
    <dependency>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jsp-2.1-glassfish</artifactId>
        <version>2.1.v20100127</version>
    </dependency>
    <!-- Jackson -->
    <dependency>
      <groupId>org.codehaus.jackson</groupId>
      <artifactId>jackson-mapper-asl</artifactId>
      <version>1.9.0</version>
    </dependency>
    <!-- Jetty -->
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-webapp</artifactId>
        <version>7.6.0.v20120127</version>
    </dependency>
    <dependency>
      <groupId>asm</groupId>
      <artifactId>asm</artifactId>
      <version>3.2</version>
    </dependency>

    <!-- Need this for some of the JSON parsing in OAuthServlet -->
    <dependency>
         <groupId>org.json</groupId>
         <artifactId>json</artifactId>
         <version>20080701</version>
     </dependency>

    <!-- Needed for the proxy -->
    <dependency>
         <groupId>commons-httpclient</groupId>
         <artifactId>commons-httpclient</artifactId>
         <version>3.1</version>
        <exclusions>
            <exclusion>
                <groupId>commons-codec</groupId>
                <artifactId>commons-codec</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <!-- Newer version of this is needed for thew Base64 Encoding -->
    <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
        <version>1.4</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>${java.version}</source>
                <target>${java.version}</target>
            </configuration>
        </plugin>
        <!-- The maven app assembler plugin will generate a script that sets up the classpath and runs your project -->
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>appassembler-maven-plugin</artifactId>
            <version>1.1.1</version>
            <configuration>
                <assembleDirectory>target</assembleDirectory>
                <programs>
                    <program>
                        <mainClass>Main</mainClass>
                        <name>webapp</name>
                    </program>
                </programs>
            </configuration>
            <executions>
                <execution>
                    <id>execution1</id>
                    <phase>package</phase>
                    <goals>
                        <goal>assemble</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

(Edit 1) I change my pom.xml as you say

" < 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 maven.apache.org/maven-v4_0_0.xsd" >

<modelVersion>4.0.0</modelVersion>
<groupId>sfdc</groupId>
<version>1.0-SNAPSHOT</version>
<name>Salesforce Canvas Framework SDK</name>
<artifactId>sfdc-canvas-sdk</artifactId>

<properties>
    <java.version>1.6</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <!-- Servlet API -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
    </dependency>
    <dependency>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jsp-2.1-glassfish</artifactId>
        <version>2.1.v20100127</version>
    </dependency>
    <!-- Jackson -->
    <dependency>
      <groupId>org.codehaus.jackson</groupId>
      <artifactId>jackson-mapper-asl</artifactId>
      <version>1.9.0</version>
    </dependency>
    <!-- Jetty -->
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>9.3.0.v20150612</version>
    </dependency>
    <dependency>
      <groupId>asm</groupId>
      <artifactId>asm</artifactId>
      <version>3.2</version>
    </dependency>

    <!-- Need this for some of the JSON parsing in OAuthServlet -->
    <dependency>
         <groupId>org.json</groupId>
         <artifactId>json</artifactId>
         <version>20080701</version>
     </dependency>

    <!-- Needed for the proxy -->
    <dependency>
         <groupId>commons-httpclient</groupId>
         <artifactId>commons-httpclient</artifactId>
         <version>3.1</version>
        <exclusions>
            <exclusion>
                <groupId>commons-codec</groupId>
                <artifactId>commons-codec</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <!-- Newer version of this is needed for thew Base64 Encoding -->
    <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
        <version>1.4</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>${java.version}</source>
                <target>${java.version}</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>9.3.0.v20150612</version>
            <configuration>
                <scanIntervalSeconds>10</scanIntervalSeconds>
                <httpConnector>
                    <port>${jetty.port}</port>
                    <idleTimeout>60000</idleTimeout>
                </httpConnector>
                <stopKey>foo</stopKey>
                <stopPort>${jetty.stop.port}</stopPort>
            </configuration>
        </plugin>
        <!-- The maven app assembler plugin will generate a script that sets up the classpath and runs your project -->
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>appassembler-maven-plugin</artifactId>
            <version>1.1.1</version>
            <configuration>
                <assembleDirectory>target</assembleDirectory>
                <programs>
                    <program>
                        <mainClass>Main</mainClass>
                        <name>webapp</name>
                    </program>
                </programs>
            </configuration>
            <executions>
                <execution>
                    <id>execution1</id>
                    <phase>package</phase>
                    <goals>
                        <goal>assemble</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>


But now when I build get following exception:

[INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ sfdc-canvas-sdk ---

[INFO] Using 'UTF-8' encoding to copy filtered resources.

[INFO] skip non existing resourceDirectory C:\Users\Ivan_Kliavakin\code\SalesforceCanvasFrameworkSDK\src\main\resources

[INFO] [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ sfdc-canvas-sdk ---

[INFO] Compiling 11 source files to C:\Users\Ivan_Kliavakin\code\SalesforceCanvasFrameworkSDK\target\classes

[INFO] -------------------------------------------------------------

[ERROR] COMPILATION ERROR :

[INFO] -------------------------------------------------------------

[ERROR] \Users\Ivan_Kliavakin\code\SalesforceCanvasFrameworkSDK\src\main\java\Main.java:[29,35] error: package org.eclipse.jetty.server.bio does not exist

[ERROR] \Users\Ivan_Kliavakin\code\SalesforceCanvasFrameworkSDK\src\main\java\Main.java:[30,35] error: package org.eclipse.jetty.server.ssl does not exist

[INFO] 2 errors

[INFO] -------------------------------------------------------------

[INFO] ------------------------------------------------------------------------

[INFO] BUILD FAILURE

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 15.371 s

[INFO] Finished at: 2016-07-28T16:36:16+03:00

[INFO] Final Memory: 20M/281M

[INFO] ------------------------------------------------------------------------

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project sfdc-canvas-sdk: Compilation failure: Compilation failure:

[ERROR] \Users\Ivan_Kliavakin\code\SalesforceCanvasFrameworkSDK\src\main\java\Main.java:[29,35] error: package org.eclipse.jetty.server.bio does not exist

[ERROR] \Users\Ivan_Kliavakin\code\SalesforceCanvasFrameworkSDK\src\main\java\Main.java:[30,35] error: package org.eclipse.jetty.server.ssl does not exist

[ERROR] -> [Help 1]

[ERROR]

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

[ERROR]

[ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1] /cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

1

As indicated by the error log, this is caused due to a mismatch in the versions (relatively common occurence in Java world). In your pom.xml file, replace the portion related to jetty with this under the plugins section

 <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.3.0.v20150612</version>
                <configuration>
                    <scanIntervalSeconds>10</scanIntervalSeconds>
                    <httpConnector>
                        <port>${jetty.port}</port>
                        <idleTimeout>60000</idleTimeout>
                    </httpConnector>
                    <stopKey>foo</stopKey>
                    <stopPort>${jetty.stop.port}</stopPort>
                </configuration>
            </plugin>

This should fix it.

| improve this answer | |
  • I think about your question and find something similar(stackoverflow.com/questions/5264609/…), but I am not fully understand what they mean and what and where I must use ';' instead of ':' as a path separator? – I.Kliavakin Jul 28 '16 at 15:09
  • Yes, simply adding this to the pom.xml does not solve the problem. I am not a Maven or Jetty expert, so I don't know how to make it happen that the most recent version of Jetty is used. In webapp.bat I see that still an old version of Jetty is used, one that is not compatible with Java 1.8, the version that I have on my system. – Sander de Jong Oct 24 '18 at 6:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.