New-Relic Add-on for Java Application on Heroku Setup

Add New Relic Agent Dependency

 <dependency>
  	<groupId>com.newrelic.agent.java</groupId>
  	<artifactId>newrelic-agent</artifactId>
  	<version>3.5.1</version>
  	<scope>provided</scope>
</dependency>

pom.xml build tag

  <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
                <version>2.3.2</version>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.2</version>
            </plugin>
            
            <plugin>
				<groupId>com.mysema.maven</groupId>
				<artifactId>apt-maven-plugin</artifactId>
				<version>1.0.8</version>
				<dependencies>
					<dependency>
						<groupId>com.mysema.querydsl</groupId>
						<artifactId>querydsl-apt</artifactId>
						<version>2.9.0</version>
					</dependency>
				</dependencies>
				<executions>
					<execution>
						<phase>generate-sources</phase>
						<goals>
							<goal>process</goal>
						</goals>
						<configuration>
							<outputDirectory>target/generated-sources</outputDirectory>
							<processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
						</configuration>
					</execution>
				</executions>
			</plugin>
            
            
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                           <goal>copy</goal>
                        </goals>
                         
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.github.jsimone</groupId>
                                    <artifactId>webapp-runner</artifactId>
                                    <version>7.0.22.3</version>
                                    <destFileName>webapp-runner.jar</destFileName>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                   <execution>
         				 <id>copy-new-relic</id>
          					<phase>package</phase>
         				<goals>
          					 <goal>copy-dependencies</goal>
         				 </goals>
         				 <configuration>
           					 <includeGroupIds>com.newrelic.agent.java</includeGroupIds>
           					 <includeArtifactIds>newrelic-agent</includeArtifactIds>
           					 <stripVersion>true</stripVersion>
          					</configuration>
        			</execution>
                </executions>
            </plugin>
        </plugins>
        <pluginManagement>
	<plugins>
    <!-- Ignore/Execute plugin execution -->
    <plugin>
        <groupId>org.eclipse.m2e</groupId>
        <artifactId>lifecycle-mapping</artifactId>
        <version>1.0.0</version>
        <configuration>
            <lifecycleMappingMetadata>
                <pluginExecutions>
                    <!-- copy-dependency plugin -->
                    <pluginExecution>
                        <pluginExecutionFilter>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-dependency-plugin</artifactId>
                            <versionRange>[1.0.0,)</versionRange>
                            <goals>
                                <goal>copy-dependencies</goal>
                            </goals>
                        </pluginExecutionFilter>
                        <action>
                            <ignore />
                        </action>
                    </pluginExecution>
                </pluginExecutions>
            </lifecycleMappingMetadata>
        </configuration>
    </plugin>
   </plugins></pluginManagement>
        
    </build>
    <name>CloudSole Developer</name>
    <description>CloudSole Developer</description>
    <organization>
    	<name>Thys Michels</name>
    	<url>http://www.thysmichels.com</url>
    </organization>

Create newrelic.yml and save to project route (same level as pom.xml)

.....
license_key: 'OURLICENCEKEYHERE'
....
app_name: CloudSole
....

Add the following flag to your JAVA_OPTS config var on Heroku:

heroku config:set JAVA_OPTS='-Xmx384m -Xss512k -XX:+UseCompressedOops -javaagent:target/dependency/newrelic-agent.jar' NEW_RELIC_APP_NAME="CloudSole"

Sencha Touch Chatter Mobile Application

Chatter Controller

public with sharing class ChatterController {

    public class Response {
        public Boolean success;
        public String errorMessage;
        public List<SObject> records;
        public Integer total;
        Response() {
            records = new List<SObject>();
            success = true;
        }
    }
    
    //One of the parameters supplied by the DirectProxy read method.
    public class QueryRequest {
        Integer start;
        Integer recordCount;
        List<Map<String, String>> sortParams;
        
        Public QueryRequest() {
            start = 1;
            recordCount = 1;
        }
 
        Public QueryRequest(Integer pStart, Integer pRecordCount) {
            start = pStart;
            recordCount = pRecordCount;
        }
 
    }
 
    @RemoteAction
    public static Response Add(List<FeedItem> chatterData){
        return insertLeadList(chatterData);
    }
    
    @RemoteAction
    public static Response Destroy(List<FeedItem> chatterData){
        return deleteChatterList(chatterData);
    }
    
    @RemoteAction
    public static Response Edit(List<FeedItem> chatterData){
        return editChatterList(chatterData);
    }
    
    @RemoteAction
    public static Response EditComment(List<String> chatterCommentData){
        return editCommentChatterList(chatterCommentData);
    }
    
    @RemoteAction
    public static Response Query(QueryRequest qr){
 
        Response resp = new Response();
 
        //Enforce a limit on the number of rows requested.
        final integer QUERY_LIMIT = 500;
        if( qr.start >= QUERY_LIMIT ){
            resp.success = false;
            resp.errorMessage = 'Maximum number of records (' + String.valueOf(QUERY_LIMIT) + ') exceeded!';
            return resp;
        }
 
        try {
            getAllChatter(qr, resp);
        } catch (Exception e) {
            resp.success = false;
            resp.errorMessage = 'Query failed: ' + e.getMessage();
        }
 
        return resp;
    }
    
    private static Response insertCommentOrLike(List<FeedComment> chatterComment, List<FeedLike> chatterLike)
    {
        Response resp = new Response();
        resp.success = true;
 
        try {
            insert chatterComment;
            insert chatterLike;
        } catch (Exception e) {
            resp.success = false;
            resp.errorMessage = 'Insert failed: ' + e.getMessage();
        }
        return resp;
    }
    
    private static void getAllChatter(QueryRequest qr, Response resp){
 
        //Page size is set in the Sencha store as recordCount.  
        Integer pageSize = qr.recordCount; 
 
        //Page number will be calculated.
        Integer pageNumber = 0;
    
        //Start is the record number indicating the start of the page.
        if( qr.start > 0 ){
            pageNumber = qr.start / pageSize;   
        }
 
        //Calculate the offset for SOQL.
        Integer offset = pageNumber * pageSize;
 
        //Build the query in pieces.
        String fieldList = 'Id, Title, Body, LikeCount,CommentCount';
 
        //Construct a base query to which the page offsets will be added.
        String baseQuery = 'SELECT ' + fieldList + ' FROM FeedItem Order By CreatedDate DESC';
 
        //Construct a count query to pass back the total records matching a search criteria.
        String baseCountQuery = 'SELECT COUNT() FROM FeedItem';
 
        //Construct the fetch query with the offset.
        String fetchQuery = baseQuery + ' LIMIT ' + pageSize + ' OFFSET ' + offset;
 
        try {
            //Set the count.
            resp.total = Database.countQuery(baseCountQuery);
 
            //Set the fetched recordset.
            resp.records = Database.query(fetchQuery);
            
            //Set the status flag.
            resp.success = true;
 
        } catch (Exception e) {
 
            //Set the total count of records matching the query.
            resp.total = 0;
            
            //Set the recordset to return.
            resp.records = new List<Lead>();
            
            //Set the status flag.            
            resp.success = false;
 
        }    
                                    
    }
    
    private static Response insertLeadList(List<FeedItem> chatterData){
        Response resp = new Response();
        resp.success = true;
 
        try {
            chatterData[0].ParentId = UserInfo.getUserId();
            insert chatterData;
        } catch (Exception e) {
            resp.success = false;
            resp.errorMessage = 'Insert failed: ' + e.getMessage();
        }
        return resp;
    }
    
    private static Response deleteChatterList(List<FeedItem> ChatterData){
 
        Response resp = new Response();
        resp.success = true;
 
        try {
            delete ChatterData;
        } catch (Exception e) {
            resp.success = false;
            resp.errorMessage = 'Deletion failed: ' + e.getMessage();
        } 
        return resp;
    }
    
    private static Response editChatterList(List<FeedItem> chatterData){
        Response resp = new Response();
        resp.success = true;
 
        try {
            System.debug('Hier: ' + chatterData);
        } catch (Exception e) {
            resp.success = false;
            resp.errorMessage = 'Deletion failed: ' + e.getMessage();
        } 
        return resp;
    }
    
    private static Response editCommentChatterList(List<String> chatterCommentData)
    {
        Response resp = new Response();
        resp.success = true;
 
        try {
            System.debug('Hier: ' + chatterCommentData);
        } catch (Exception e) {
            resp.success = false;
            resp.errorMessage = 'Deletion failed: ' + e.getMessage();
        } 
        return resp;
    }
}

Chatter Component

<apex:component controller="ChatterController">
 <script type="text/javascript">
    Ext.application({
    name: "ChatterPlus",
    models: ["Chatter"],
    stores: ["Chatter"],
    controllers: ["Chatter"],
    views: ["ChatterList", "ChatterEditor", "ChatterLikeCommentEditor"],
   
    launch: function () {
        var chatterListView = {
            xtype: "chatterlistview"
        };
        
        var chatterEditorView = {
            xtype: "chattereditorview"
        };
        
        var chatterLikeCommentEditor = {
            xtype: "chatterlikecommentview"
        };
        
        Ext.Viewport.add([chatterListView, chatterEditorView, chatterLikeCommentEditor]);
    }
});
Ext.define("ChatterPlus.view.ChatterList", {
    extend: "Ext.Container",
    requires: "Ext.dataview.List", 
    alias: "widget.chatterlistview",
    
    config: {
 
        //Take up the full space available in the parent container.
        layout: {
            type: 'fit'
        },
 
 
        //Add the components to include within the list view. 
        items: [
        {
            xtype: "toolbar",
            title: "Chatter",
            docked: "top",
 
            items: [
                { 
                    xtype: 'spacer' 
                },
                {
                    xtype: "button",
                    text: 'New',
                    ui: 'action',
                    itemId: "newButton"
                }
            ]
        }, 
        {
            xtype: "toolbar",
            docked: "bottom",
            itemId: "bottomToolBar",
                        
            items: [
               
            ]
        },
        {
            //The main list and its properties. 
            xtype: "list",
            store: "Chatter",
            itemId:"chatterList",
            
            onItemDisclosure: true,
            indexBar: true,
            grouped: false,
            disableSelection: false,
 
            plugins: [
                {
                    xclass: 'Ext.plugin.ListPaging',
                    autoPaging: true
                }
            ],

            loadingText: "Loading Feed...",
            emptyText: '<div class="chatter-list-empty-text">No feeds found.</div>',
            
            itemTpl: '<div class="list-item-line-main">{Title}</div>' + 
                     '<div class="list-item-line-main">{Body}</div>',                   
        }],
        
        listeners: [{
            delegate: "#newButton",
            event: "tap",
            fn: "onNewButtonTap"
        }, {
            delegate: "#syncButton",
            event: "tap",
            fn: "onSyncButtonTap"
        }, {        
            delegate: "#chatterList",
            event: "disclose",
            fn: "onChatterListDisclose"
        },
        {
            delegate: "#chatterList",
            event: "refresh",
            fn: "onChatterListRefresh",
        },
        {
            //Listener on the view's Activate event fires when redisplayed by transition.
            event: "activate",
            fn: "onChatterListViewActivate",
        }]  
    },
    onSyncButtonTap: function () {
        console.log("syncChatterCommand");
        this.fireEvent("syncChatterCommand", this);
    },
 
    onNewButtonTap: function () {
        console.log("newChatterCommand");
        this.fireEvent("newChatterCommand", this);
    },
 
    onChatterListDisclose: function (list, record, target, index, evt, options) {
        console.log("editChatterCommand");
        this.fireEvent('editChatterCommand', this, record);
    }, 
    onChatterListRefresh: function () {
        console.log("onChatterListRefresh");
        this.updateListCounter();
    },
 
    onChatterListViewActivate: function () {
        console.log("onChatterListViewActivate");
        this.updateListCounter();
    },
 
    //Function to get count of records in the list and show on the search button's badge. 
    updateListCounter: function () {
        var listCount = Ext.getStore("Chatter").getCount();
        //this.getComponent("bottomToolBar").getComponent("syncButton").setBadgeText(listCount);
    }  

});

Ext.define("ChatterPlus.view.ChatterEditor", {
    extend: "Ext.form.Panel",
    requires: "Ext.form.FieldSet",
    alias: "widget.chattereditorview",
 
    config: {
     scrollable: 'vertical',
 
        items: [
            {
                xtype: "toolbar",
                docked: "top",
                title: "Edit Chatter",
        
                items: [
                    {
                        xtype: "button",
                        ui: "back",
                        text: "Home",
                        itemId: "backButton"
                    },
                    { xtype: "spacer" },
                    {
                        xtype: "button",
                        ui: "action",
                        text: "Save",
                        itemId: "saveButton"
                    }
                ]
            },
            {
                xtype: "toolbar",
                docked: "bottom",
                items: [
                    {
                        xtype: "button",
                        iconCls: "trash",
                        iconMask: true,
                        itemId: "deleteButton"
                    }
                ]
            },
            { xtype: "fieldset",
                title: 'Chatter Info',
                items: [
                    {
                        xtype: 'textfield',
                        name: 'Title',
                        label: 'Title',
                        required: true
                    },
                    {
                        xtype: 'textareafield',
                        name: 'Body',
                        label: 'Body',
                        maxRows: 1,
                        required: true
                    },
                    {
                        xtype: 'textfield',
                        name: 'CommentCount',
                        label: 'Comment Count',
                        disabled: true
                        
                    },
                    {
                        xtype: 'textfield',
                        name: 'LikeCount',
                        label: 'Like Count',
                        disabled: true
                    },
                ]           
            },
            { xtype: "fieldset",
                title: 'Chatter Comment & Like',
                items: [
                    { 
                         xtype : 'textareafield',
                         name : 'Comment',
                         label : 'Comment',
                         maxRows: 1
                    },          
                    { 
                         xtype : 'checkboxfield',
                         name : 'Like',
                         label : 'Like'
                    },
                ]
            },      
        ],
        listeners: [
            {
                delegate: "#backButton",
                event: "tap",
                fn: "onBackButtonTap"
            },
            {
                delegate: "#saveButton",
                event: "tap",
                fn: "onSaveButtonTap"
            },
            {
                delegate: "#deleteButton",
                event: "tap",
                fn: "onDeleteButtonTap"
            }
        ]
    },
    
    onSaveButtonTap: function () {
        console.log("saveChatterCommand");
        this.fireEvent("saveChatterCommand", this);
    },
 
    onDeleteButtonTap: function () {
        console.log("deleteChatterCommand");
        Ext.Msg.confirm("Delete Feed", "Are you sure?", function(button){
            if (button == 'yes') {
                this.fireEvent("deleteChatterCommand", this);
            } else {
                return false;
            }
        }, this);
    },
 
    onBackButtonTap: function () {
        console.log("backToHomeCommand");
        this.fireEvent("backToHomeCommand", this);
    }
 
});


Ext.define("ChatterPlus.view.ChatterLikeCommentEditor", {
    extend: "Ext.form.Panel",
    requires: "Ext.form.FieldSet",
    alias: "widget.chatterlikecommentview",
 
    config: {
    }
 
 });
    
    
    
Ext.define("ChatterPlus.controller.Chatter", {
    extend: "Ext.app.Controller",
 
    config: {
 
        refs: {
            chatterListView: "chatterlistview",
            chatterEditorView: "chattereditorview",
            chatterList: "#chatterList",         
        },
 
        control: {
            chatterListView: {
                // The commands fired by the list container.
                syncChatterCommand: "onSyncChatterCommand",
                newChatterCommand: "onNewChatterCommand",
                editChatterCommand: "onEditChatterCommand",
            },
            chatterEditorView: {
                // The commands fired by the note editor.
                saveChatterCommand: "onSaveChatterCommand",
                deleteChatterCommand: "onDeleteChatterCommand",
                backToHomeCommand: "onBackToHomeCommand"
            }
        }
    },
 
    //View Transitions
    slideLeftTransition: { type: 'slide', direction: 'left' },
    slideRightTransition: { type: 'slide', direction: 'right' },
    
    activateChatterEditor: function (record) {
        var chatterEditorView = this.getChatterEditorView();
        chatterEditorView.setRecord(record); 
        Ext.Viewport.animateActiveItem(chatterEditorView, this.slideLeftTransition);
    },
 
    activateChatterList: function () {
        Ext.Viewport.animateActiveItem(this.getChatterListView(), this.slideRightTransition);
    },
 
    onSyncChatterCommand: function () {
        console.log("onSyncChatterCommand");
        this.loadList();
    },
     
    onNewChatterCommand: function () {
        console.log("onNewChatterCommand");
        var newChatter = Ext.create("ChatterPlus.model.Chatter");
        this.activateChatterEditor(newChatter);
    },
    
     onEditChatterCommand: function (list, record) {
        console.log("onEditChatterCommand");
        this.activateChatterEditor(record);
    },
    
    loadList: function () {
 
        //Get a ref to the store and remove it.
        var chatterStore = Ext.getStore("Chatter");
 
        var model = Ext.ModelMgr.getModel('ChatterPlus.model.Chatter');
        model.getProxy();
        
        chatterStore.getData().clear();   
        chatterStore.loadPage(1); 
        
        //Reshow the list.
        this.activateChatterList();
    },
    
    // Base Class functions.
    launch: function () {
        console.log("launch");
        this.callParent(arguments);
        
        //Load up the Store associated with the controller and its views. 
        console.log("load Chatter");
        this.loadList();
        
   },
   
   onSaveChatterCommand: function () {
        console.log("onSaveChatterCommand");
       
        var chatterEditorView = this.getChatterEditorView();
        var currentChatter = chatterEditorView.getRecord();
        var newValues = chatterEditorView.getValues();
        this.getChatterEditorView().updateRecord(currentChatter);     
 
        var errors = currentChatter.validate();
        if (!errors.isValid()) {
            var msg = '';
            errors.each(function(error) {
                msg += error.getMessage() + '<br/>';
            });
            console.log('Errors: ' + msg);
            Ext.Msg.alert('Please correct errors!', msg, Ext.emptyFn);
            currentChatter.reject();
            return;
        }
 
        //Get a ref to the store.
        var chatterStore = Ext.getStore("Chatter");
        var chatterCommentStore = Ext.getStore("ChatterComment");
        //var newChatterComment = Ext.create("ChatterPlus.model.ChatterComment");
        
        //Add new record to the store.
        if (null == chatterStore.findRecord('id', currentChatter.data.id)) {
            chatterStore.add(currentChatter);
           //chatterCommentStore.add(newChatterComment);
        }
        
        chatterCommentStore.sync();
        //Resync the proxy and activate the list.   
        chatterStore.sync();
        this.activateChatterList();
    },
 
    onDeleteChatterCommand: function () {
        console.log("onDeleteChatterCommand");
        
        //Get a ref to the form and its record. 
        var chatterEditorView = this.getChatterEditorView();
        var currentChatter = chatterEditorView.getRecord();

        var chatterStore = Ext.getStore("Chatter");
        chatterStore.remove(currentChatter);
              
        chatterStore.sync();
        this.activateChatterList();
    },
 
    onBackToHomeCommand: function () {
        console.log("onBackToHomeCommand");
        this.activateChatterList();
    },
 
    init: function() {
 
        this.callParent(arguments);
        console.log("init");
 
        //Listen for exceptions observed by the proxy so we can report them and clean up.
        Ext.getStore('Chatter').getProxy().addListener('exception', function (proxy, response, operation, options) {
            // only certain kinds of errors seem to have useful information returned from the server
            if (response) {
                if (response.errorMessage) {
                    Ext.Msg.alert('Error', response.errorMessage);
                } else {
                    Ext.Msg.alert('Error', operation.config.action + ' failed: ' + response.errorMessage);
                }
            } else {
                Ext.Msg.alert('Error', operation.config.action + ' failed for an unknown reason: proxy = ' + proxy);
            }
        });
 
    },
 
});

Ext.define("ChatterPlus.model.Chatter", {
    extend: "Ext.data.Model",
 
    config: {
        idProperty: 'Id',
 
        fields: [
            { name: 'Id', type: 'string', persist: false},
            { name: 'Title', type: 'string'},
            { name: 'Body', type: 'string'},
            { name: 'LikeCount', type: 'string', persist: false},
            { name: 'CommentCount', type: 'string', persist: false},
            { name: 'Comment', type: 'string', persist: false},
            { name: 'Like', type: 'string', persist: false},
            { name: 'ParentId', type: 'string'}
        ],
 
        validations: [
             { type: 'presence', field: 'Title', message: 'Enter a Title' },
             { type: 'presence', field: 'Body', message: 'Enter a Body' } 
        ],
 
        //Bind each CRUD functions to a @RemoteAction method in the Apex controller
        proxy: {
            type: 'direct',
            api: {
                read:     ChatterController.Query,
                create:   ChatterController.Add,
                update:   ChatterController.Edit,
                destroy:  ChatterController.Destroy
            },
            limitParam: 'recordCount',   // because "limit" is an Apex keyword
            sortParam: 'sortParams',     // because "sort" is a keyword too
            pageParam: false,            // we don't use this in the controller, so don't send it
            reader: {
                type: 'json',
                rootProperty: 'records',
                messageProperty: 'errorMessage'
            },
            writer: {
                type: 'json',
                root: 'records',
                writeAllFields: false,   // otherwise empty fields will transmit as empty strings, instead of "null"/not present
                allowSingle: false,      // need to always be an array for code simplification
                encode:  false           // docs say "set this to false when using DirectProxy"
            }
 
        }
    },
 
});

Ext.define("ChatterPlus.model.ChatterComment", {
    extend: "Ext.data.Model",
 
    config: {
        idProperty: 'Id',
 
        fields: [
            { name: 'Comment', type: 'string'}
        ],
 
        validations: [
            
        ],
 
        //Bind each CRUD functions to a @RemoteAction method in the Apex controller
        proxy: {
            type: 'direct',
            api: {
                update:   ChatterController.EditComment
            },
            writer: {
                type: 'json',
                root: 'records',
                writeAllFields: false,   // otherwise empty fields will transmit as empty strings, instead of "null"/not present
                allowSingle: false,      // need to always be an array for code simplification
                encode:  false           // docs say "set this to false when using DirectProxy"
            }
 
        }
    },
 
});



ChatterController.Query.directCfg.method.getArgs = 
    function (params, paramOrder, paramsAsHash) {
        console.log('getArgs: ' + params.data);
        return [params]; 
    }
 
Ext.data.proxy.Direct.prototype.createRequestCallback =
    function(request, operation, callback, scope){
        var me = this;
        return function(data, event){
             console.log('createRequestCallback: ' + operation);    
             me.processResponse(event.status, operation, request, data, callback, scope);
    };
    
};

Ext.define("ChatterPlus.store.Chatter", {
    extend: "Ext.data.Store",
    requires: "Ext.data.proxy.LocalStorage",
    config: {
        model: "ChatterPlus.model.Chatter",
        autoLoad: true,
        pageSize: 25,     
    },
 
    listeners: {
        load: function(){
             console.log('store.load(): loaded!');                
        },
    }
 
});

</script>
</apex:component>

Creating your first stateless session bean using RAD 7.5 running on WAS 7

Creating my first stateless session bean using Rational Application Developer 7.5 and deployed to Websphere Application Server V7.0.0.7 that shows the current system time.
Step 1: Create a new Enterprise Application Project.
Step 2: Create a new EJB Project by right clicking on the newly created Enterprise Application Project.
Make sure that to add the Enterprise Application Project as a EAR member.
Step 3: Right click on your newly created EJB project and select -> Session Bean
Enter the package name as: com.ibm.ejb.time
Enter the class name as: time
Make sure that business interface is set to Local
Step 4: Open the newly created Session Bean called time and add the following method.
Make sure that to add the Enterprise Application Project as a EAR member.
public String getTimeInfo(String timeinput) {
Calendar cal = Calendar.getInstance();
Date now = cal.getTime();
DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
if timeinput != null && timeinput.length() > 0) {
timeinput = timeinput.toUpperCase();
}
return DateFormat.getTimeInstance().format(now) + ” on ” + df.format(now);
Make sure to add all the neccessary Imports using Quick Fix.
Step 5: Right click anywhere in the editor and Navigate to Java EE Tool -> Promote Method
Select ‘getTimeInfo’ method and click ‘OK’
Step 6: Go back to your Enterprise Exlorer and right click on the Enterprise Application Project created in Step 1.
Select New -> Dynamic Web Project
Make sure that to add the Enterprise Application Project as a EAR member.
Step 7: Right click on your newly created Dynamic Web Project and select ‘Properties’
Step 8: Select ‘Java EE Module Dependencies’
Select ‘Allow Both’ under reference to EJB JARs with EJB client JARs.
Select both JARs and click ‘OK’
Step 9: Create a new Servlet by right clicking on the Dynamic Web Project and selecting New->Servlet.
Enter the package name as: com.ibm.ejb.time
Enter the class name as: timeServlet
Accept the superclass javax.servlet.http.HTTPServlet
Click Finish.
Step 10: Open the new timeServlet.java file.
Add the following two commands under TimeServlet class:
@EJB
TimeLocal time;
Using quick fix import the neccessary packages.
Add the following commands under doGet class:
PrintWriter out = response.getWriter();
String time = clock.getClockInfo(“medium”);
out.println(“<html><body>”);
out.println(“<h3>The current time is:</h3>”);
out.println(“<p>” + time + “</p>”);
out.println(“</body></html>”);
Using quick fix import the neccessary packages.
Add the following commands under doPost class:
String format = request.getParameter(“timeinput”);
request.setAttribute(“time”, clock.getTimeInfo(timeinput));
RequestDispatcher rd = getServletContext().
getRequestDispatcher(“/index.jsp”);
rd.forward(request, response);
return;
Step 11: Import the index.jsp file into your Dynamic Web Project.
Step 12: Start an instance of Websphere Application Server inside RAD 7.5
After the instance has started right click on the Server and click on ‘Add and Remove Projects’
Step 13: Run the Dynamic Web Project by right clicking on it and selecting ‘Run As’->’Run on Server’Creating my first stateless session bean using Rational Application Developer 7.5 and deployed to Websphere Application Server V7.0.0.7 that shows the current system time.