University of Sheffield NLP GATE development hints Reporting bugs Submitting a patch The user guide Continuous integration.

Slides:



Advertisements
Similar presentations
Chapter 6 Server-side Programming: Java Servlets
Advertisements

May 13th, Lucek Consulting Basic Java Servlet/JSP Web Development David Lucek Lucek Consulting
JSP and web applications
Struts Portlet Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
WEB SERVICES. FIRST AND FOREMOST - LINKS Tomcat AXIS2 -
Introduction to Maven 2.0 An open source build tool for Enterprise Java projects Mahen Goonewardene.
OpusCollege and Spring-DM. OSGi based web applications – three strategies OSGi container embedded in another container: OSGi Bridge Server (OBS)  e.g.
Developing in CAS. Why? As distributed you edit CAS 3 with Eclipse and build with Maven 2 – Best Practice for Release Engineering – Difficult edit-debug.
Kit Chan ATS Lua Plugin Kit Chan Hi, My name is kit.
Apache Struts Technology
A Blackboard Building Block™ Crash Course for Web Developers
The SBML Java™ library. Concept of JSBML Compromise: –High compatibility to libSBML –Java-like library Main developers –Nicolas Rodriguez and Andreas.
J.Sant Servlets Joseph Sant Sheridan Institute of Technology.
MC365 Application Servers: Servlets. Today We Will Cover: What a servlet is The HTTPServlet and some of its more important methods How to configure the.
JSP: JavaServer Pages Juan Cruz Kevin Hessels Ian Moon.
Object-Oriented Enterprise Application Development Tomcat 3.2 Configuration Last Updated: 03/30/2001.
An introduction to Java Servlet Programming
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
18-Jun-15 JSP Java Server Pages Reference: Tutorial/Servlet-Tutorial-JSP.html.
ASP.NET Programming with C# and SQL Server First Edition
Session-02.
SE-2840 Dr. Mark L. Hornick1 Java Servlet-based web apps Servlet Architecture.
Java Servlets. What Are Servlets? Basically, a java program that runs on the server Basically, a java program that runs on the server Creates dynamic.
Understanding and Managing WebSphere V5
UNIT-V The MVC architecture and Struts Framework.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
Servlets Environment Setup. Agenda:  Setting up Java Development Kit  Setting up Web Server: Tomcat  Setting up CLASSPATH.
MAVEN-BLUEMARTINI Yannick Robin. What is maven-bluemartini?  maven-bluemartini is Maven archetypes for Blue Martini projects  Open source project on.
SchwartzGBIF Nodes III29 April 2003 DiGIR Portal Installation And Configuration.
JSP Java Server Pages Softsmith Infotech.
 Embeds Java code  In HTML tags  When used well  Simple way to generate dynamic web-pages  When misused (complex embedded Java)  Terribly messy.
Chapter 5 Being a Web App. Very few servlet or JSP stands alone Many times in our application, different servlets or JSPs need to share information 
JAVA SERVER PAGES. 2 SERVLETS The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java, with a little.
Chapter 3.5 Memory and I/O Systems. 2 Memory Management Memory problems are one of the leading causes of bugs in programs (60-80%) MUCH worse in languages.
Chapter 3 Servlet Basics. 1.Recall the Servlet Role 2.Basic Servlet Structure 3.A simple servlet that generates plain text 4.A servlet that generates.
Webcommerce Computer Networks Webcommerce by Linnea Reppa Douglas Martindale Lev Shalevich.
Running Servlets JSDK2.1 default.cfg : Web Server configuration information batch files to start and stop server Servlet properties in /webpages/WEB-INF.
Introduction to GATE Developer Ian Roberts. University of Sheffield NLP Overview The GATE component model (CREOLE) Documents, annotations and corpora.
Threading Servlets Can handle multiple clients concurrently Shared resources must be synchronized or create a servlet that handles one request at a time.
@2008 Huynh Ngoc Tin Chapter #2 JAVA SERVLET PRGRAMMING.
INTEGRATION OF BACKBONE.JS WITH SPRING 3.1. Agenda New Features and Enhancements in Spring 3.1 What is Backbone.js and why I should use it Spring 3.1.
SE-2840 Dr. Mark L. Hornick1 Servlet Threads and Sessions.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
1 Java Servlets l Servlets : programs that run within the context of a server, analogous to applets that run within the context of a browser. l Used to.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Spring MVC Essentials Getting started.
Java Enterprise Edition Programming Page 1 of 9Configuring Servlets Web Application Context Name  In multiple web applications, a “context name” is used.
JS (Java Servlets). Internet evolution [1] The internet Internet started of as a static content dispersal and delivery mechanism, where files residing.
Spring and DWR Frameworks for Rich Web Enterprise Application Thomas Wiradikusuma Presentation to the 20 th.
JAVA BEANS JSP - Standard Tag Library (JSTL) JAVA Enterprise Edition.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Data Access with Spring.
Threads. Readings r Silberschatz et al : Chapter 4.
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
GATE Applications as Web Services Ian Roberts. University of Sheffield NLP Introduction Scenario:  Implementing a web service (or other web application)
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Chapter 4 Request and Response. Servlets are controlled by the container.
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
Bayu Priyambadha, S.Kom. Static content  Web Server delivers contents of a file (html) 1. Browser sends request to Web Server 3. Web Server sends HTML.
Google Code Libraries Dima Ionut Daniel. Contents What is Google Code? LDAPBeans Object-ldap-mapping Ldap-ODM Bug4j jOOR Rapa jongo Conclusion Bibliography.
CS-4220 Dr. Mark L. Hornick1 Single class doing too many things =Bad Code Smell.
GATE Applications as Web Services
Servlet Sessions and Cookies
Play Framework: Introduction
Course Outcomes of Advanced Java Programming AJP (17625, C603)
Introduction to J2EE Architecture
Unit 6-Chapter 2 Struts.
Skill Based Assessment
CCA Skill Certification
Introduction to JBoss application server
Java Servlets and JSP.
Presentation transcript:

University of Sheffield NLP GATE development hints Reporting bugs Submitting a patch The user guide Continuous integration

University of Sheffield NLP Bugs, feature requests Use the tracker on SourceForge Give as much detail as possible GATE version, build number, platform, Java version (1.5.0_15, 1.6.0_03, etc.) Steps to reproduce Full stack trace of any exceptions, including "Caused by…" Check whether the bug is already fixed in the latest nightly build

University of Sheffield NLP Patches Use the patches tracker on SourceForge Best format is an svn diff against the latest subversion Save the diff as a file and attach it, don't paste the diff into the bug report. We generally don't accept patches against earlier versions

University of Sheffield NLP Patches (2) GATE must compile and run on Java 5 Not sufficient to set source="1.5" and target="1.5" but compile on Java 6 This doesn't prevent you calling classes/methods that don't exist in 5 Test your patch on Java 5 before submitting

University of Sheffield NLP The User Guide Everything in GATE is (theoretically) documented in the GATE User Guide Every change to the core should be mentioned in the change log User guide is written in LaTeX

University of Sheffield NLP Updating the user guide Lives in subversion userguide/trunk Build requires pdflatex, htlatex (tex4ht package), sed, make, etc. On Windows, use Cygwin Download and put in directory above the.tex files

University of Sheffield NLP Updating the user guide (2) Edit the.tex files Graphics, screenshots, etc. should be.png Check in changes to.tex files, the PDF and HTML are regenerated automatically by…

University of Sheffield NLP Hudson Continuous integration platform Automatically rebuilds GATE and user guide (among others) whenever they change Also does a clean build of GATE every night Nightly builds published at

University of Sheffield NLP Hudson Junit test results available for each build

Running GATE Embedded in Tomcat (or any multithreaded system) Issues and tricks

University of Sheffield NLP Introduction Scenario: Implementing a web service (or other web application) that uses GATE Embedded to process requests. Want to support multiple concurrent requests Long running process - need to be careful to avoid memory leaks, etc. Example used is a plain HttpServlet Principles apply to other frameworks (struts, Spring MVC, Metro/CXF, Grails…)

University of Sheffield NLP Setting up GATE libraries in WEB-INF/lib gate.jar + JARs from lib Usual GATE Embedded requirements: A directory to be "gate.home" Site and user config files Plugins directory Call Gate.init() once (and only once) before using any other GATE APIs

University of Sheffield NLP Initialisation using a ServletContextListener ServletContextListener is registered in web.xml Called when the application starts up public void contextInitialized(ServletContextEvent e) { ServletContext ctx = e.getServletContext(); File gateHome = new File(ctx.getRealPath("/WEB-INF")); Gate.setGateHome(gateHome); File userConfig = new File(ctx.getRealPath("/WEB-INF/user.xml")); Gate.setUserConfigFile(userConfig); // site config is gateHome/gate.xml // plugins dir is gateHome/plugins Gate.init(); } gate.web..example.GateInitListener

University of Sheffield NLP GATE in a multithreaded environment GATE PRs are not thread-safe Due to design of parameter-passing as JavaBean properties Must ensure that a given PR/Controller instance is only used by one thread at a time

University of Sheffield NLP First attempt: one instance per request Naïve approach - create new PRs for each request public void doPost(request, response) { ProcessingResource pr = Factory.createResource(...); try { Document doc = Factory.newDocument(getTextFromRequest(request)); try { // do some stuff } finally { Factory.deleteResource(doc); } finally { Factory.deleteResource(pr); } Many levels of nested try/finally: ugly but necessary to make sure we clean up even when errors occur. You will get very used to these…

University of Sheffield NLP Problems with this approach Guarantees no interference between threads But inefficient, particularly with complex PRs (large gazetteers, etc.) Hidden problem with JAPE: Parsing a JAPE grammar creates and compiles Java classes Once created, classes are never unloaded Even with simple grammars, eventually OutOfMemoryError (PermGen space)

University of Sheffield NLP Second attempt: using ThreadLocals Store the PR/Controller in a thread local variable private ThreadLocal controller = new ThreadLocal () { protected CorpusController initialValue() { return loadController(); } }; private CorpusController loadController() { //... } public void doPost(request, response) { CorpusController c = controller.get(); // do stuff with the controller }

University of Sheffield NLP Better than attempt 1… Only initialise resources once per thread Interacts nicely with typical web server thread pooling But if a thread dies, no way to clean up its controller Possibility of memory leaks

University of Sheffield NLP A solution: object pooling Manage your own pool of Controller instances Take a controller from the pool at the start of a request, return it (in a finally!) at the end Number of instances in the pool determines maximum concurrency level

University of Sheffield NLP Simple example private BlockingQueue pool; public void init() { pool = new LinkedBlockingQueue (); for(int i = 0; i < POOL_SIZE; i++) { pool.add(loadController()); } public void doPost(request, response) { CorpusController c = pool.take(); try { // do stuff } finally { pool.add(c); } public void destroy() { for(CorpusController c : pool) Factory.deleteResource(c); } Blocks if the pool is empty: use poll() if you want to handle empty pool yourself

University of Sheffield NLP Exporting the grunt work - the Spring Framework Spring Framework Handles application startup and shutdown Configure your business objects and connections between them using XML GATE provides helpers to initialise GATE, load saved applications, etc. Built-in support for object pooling Web application framework (Spring MVC) Used by other frameworks (Grails, CXF, …)

University of Sheffield NLP Initialising GATE with Spring <beans xmlns=" xmlns:gate=" <gate:init gate-home="/WEB-INF" plugins-home="/WEB-INF/plugins" site-config-file="/WEB-INF/gate.xml" user-config-file="/WEB-INF/user-gate.xml"> /WEB-INF/plugins/ANNIE

University of Sheffield NLP Loading a saved application <gate:saved-application id="myApp" location="/WEB-INF/application.xgapp" scope="prototype" /> scope="prototype" means create a new instance each time we ask for it Default is singleton - one and only one instance

University of Sheffield NLP Spring servlet example Spring provides HttpRequestHandler interface to manage servlet-type objects with Spring Declare an HttpRequestHandlerServlet in web.xml with the same name as the Spring bean

University of Sheffield NLP Spring servlet example public class MyHandler implements HttpRequestHandler { public void setApplication(CorpusController app) {... } public void handleRequest(request, response) { Document doc = Factory.newDocument(getTextFromRequest(request)); try { // do some stuff with the app } finally { Factory.deleteResource(doc); } Write the handler assuming single- threaded access Will use Spring to handle pooling for us

University of Sheffield NLP Tying it together web.xml org.springframework.web.context.ContextLoaderListener mainHandler org.springframework.web.context.support.HttpRequestHandlerServlet

University of Sheffield NLP Tying it together (2) applicationContext.xml <gate:saved-application id="myApp" location="/WEB-INF/application.xgapp" scope="prototype" /> <bean id="handlerTargetSource" class="org.springframework.aop.target.CommonsPoolTargetSource"> <bean id="mainHandler" class="org.springframework.aop.framework.ProxyFactoryBean">