function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vjoshivjoshi 

Tomcat 6 issue with servlet annotation

What is the alternative to servlet 3.0 annotations that is used in REST API sample Force.com application? I am using Tomcat 6 server that does not support annotation package. How can I solve this issue?

@WebServlet(name = "oauth", urlPatterns = { "/oauth/*", "/oauth" }, initParams = {
		// clientId is 'Consumer Key' in the Remote Access UI
		@WebInitParam(name = "clientId", value = "..."),
		// clientSecret is 'Consumer Secret' in the Remote Access UI
		//@WebInitParam(name = "clientSecret", value = "..."),
		// This must be identical to 'Callback URL' in the Remote Access UI
		@WebInitParam(name = "redirectUri", value = "https://<sample ip>/RESTAPITEST/oauth/_callback"),
		@WebInitParam(name = "environment", value = "https://login.salesforce.com") })

 I am getting error in the bold parts.

 

vjoshivjoshi

Can anyone help with this? I removed the above annotations and added the init parameters to web.xml file.

 

 

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

   <session-config>
      <session-timeout>
        30
      </session-timeout>
   </session-config>
   <welcome-file-list>
      <welcome-file>index.html</welcome-file>
   </welcome-file-list>


  <context-param>
    <param-name>clientId</param-name>
    <param-value>3M7G9y650357HlefZvgrKO4VdcJZ7qy3A_f5Mbm8hyCOdPXgHxfpIZEpPKDwLlpQVgGHISdF6LVfPJWXRL9WB</param-value>
  </context-param>

  <context-param>
      <param-name>clientSecret</param-name>
      <param-value>6757642051751912408</param-value>
  </context-param>

  <context-param>
      <param-name>redirectUri</param-name>
      <param-value>https://128.230.184.201:8448/RestTest/oauth/_callback</param-value>
  </context-param>

  <context-param>
      <param-name>environment</param-name>
      <param-value>https://login.salesforce.com</param-value>
  </context-param>

  <servlet>
      <servlet-name>oauth</servlet-name>
      <servlet-class>OAuthServlet</servlet-class>
  </servlet>

  <servlet-mapping>
      <servlet-name>oauth</servlet-name>
      <url-pattern>/oauth</url-pattern>
      <url-pattern>/oauth/*</url-pattern>
  </servlet-mapping>

<!--
 <servlet>
      <servlet-class>DemoREST</servlet-class>
  </servlet>

  <servlet-mapping>
      <url-pattern>/DemoREST</url-pattern>
  </servlet-mapping>
-->
  </web-app>