Run the Web App Locally
In this step, you’ll package the Web app using Maven and then run it locally using Jetty. When you package the Web app, the process downloads all the components needed to run the Web app, including Jetty.
- Open a command window and navigate to c:\SalesforceCanvasFrameworkSDK.
-
Enter the command mvn package.
You’ll see output in the command window as Maven packages the app and its
dependent components. If the process completes successfully, you’ll see
something like this:
[INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 28.016s [INFO] Finished at: Tue Jul 03 08:00:42 PDT 2012 [INFO] Final Memory: 8M/59M [INFO] ------------------------------------------------------------------------
- To use Jetty to run the app, you’ll need to enable local SSL support. This step only needs to be done once per app, so if you’ve already done this, skip this step. Ensure that the command window is open and you’re in the directory c:\SalesforceCanvasFrameworkSDK.
-
Run the following command: keytool -keystore
keystore -alias jetty -genkey -keyalg RSA.
After you run this command, you’ll be prompted for the following information. Enter 123456 for the keystore password and yes to confirm at the end. When prompted, “Enter key password for <jetty>,” press Enter to use the keystore password. For the other information, you can enter values or leave them blank.
Enter keystore password: <Choose Your Password> Re-enter new password: <Choose Your Password> What is your first and last name? [Unknown]: <Enter First and Last Name> What is the name of your organizational unit? [Unknown]: <Enter an Org Unit> What is the name of your organization? [Unknown]: <Enter an Org> What is the name of your City or Locality? [Unknown]: <Enter a City> What is the name of your State or Province? [Unknown]: <Enter a State> What is the two-letter country code for this unit? [Unknown]: <Enter a Country> Is CN=XXXX, OU=XXXX, O=XXXX, L=XXXX, ST=XX, C=XX correct? [no]: yes Enter key password for <jetty> (RETURN if same as keystore password):
This creates a file named keystore in the directory c:\SalesforceCanvasFrameworkSDK. The keystore is used by Jetty for SSL support.
-
Run the Web server by entering this command: target\bin\webapp.bat (Windows) or sh
target/bin/webapp (Unix/OS X).
If you’re using Unix/OS X, you may need to add execute permissions to webapp before you can run it. Use this command to do so: chmod +x target/bin/webapp.
-
Verify that the app is running by opening a browser and navigating to the
following URL:
https://localhost:8443/examples/hello-world/index.jsp.
Depending on your browser and security settings, you might need to add a security exception because you’re running a site with an unsigned SSL certificate.
You should see a message that says, “This App must be invoked via a signed request!” This is an indication that the Web app is running locally. This message appears because the app is designed to receive a signed request from Salesforce, therefore, the app won’t run outside of the Salesforce canvas environment.