This tutorial will guide you through the process of starting a new project in Eclipse using the SharpBlock platform.

It assumes the following components to be properly installed in the device:

  • Java 7 or higher version
  • An application server able to run the full platform of Java EE 6
  • Eclipse IDE for Java EE developers already setup with the application server mentioned above
  • A SharpBlock database server running

 

In this example we will use a local SQLite database and JBoss EAP 6.4.0.GA.

 

  1. Launch your Eclipse IDE and create a Dynamic Web Project through the toolbar menu File > New > Dynamic WebProject.
    You can also right-click anywhere in the Project Explorer view to access a context menu and select New > Project, and scroll down to Web folder and select Dynamic Web Project, or type Dynamic Web Project in the filter text.

    setup img 1
    ImgCreateProject - Create a Dynamic Web Project

  2. Add the necessary files to the new project
    • Copy the libraries to WebContent\WEB-INF\lib
    • Create a new log4j2.xml Log4J configuration file in the Java src folder
    • Create the sharpblock.properties file in WebContent with the entries shown to indicate the database parameter
    • Create the web.xml in WebContent\WEB-INF with the entries visible in the image below, ImgCfgFiles
      setup img 2
      ImgCfgFiles - Adding required files
  3. Add the new project to your application server's deploy configuration, and start the server.
    It may be needed to restart the server the first time for the project to be fully deployed.

    setup img 3
    ImgServerStart - Add project to server and start the server
  4. Access the project from your browser in the port your application server is publishing it.
    The URL format is http://localhost:<port>/<project-name>/SharpService
    setup img 4
    ImgBrowseProject - Access the new project in a browser


<TODO insert link for DB config>Further configuration</TODO> is necessary to display another content. You will see a "Default Route" page once you access the project.

 

Here are the contents of the configuration files used in this example:

 

<TODO insert code sections>

sharpblock.properties
db.connection.string=jdbc:sqlite:C:/path/to/sqlite.db
db.username=DemoUsername #Not needed for SQLite
db.password=DemoPassword #Not needed for SQLite

 

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jsp="http://java.sun.com/xml/ns/javaee/jsp" xmlns:web="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <jsp-config>
    <jsp-property-group>
      <url-pattern>*.ssp</url-pattern>
      <url-pattern>*.hsp</url-pattern>
      <url-pattern>*.wsp</url-pattern>
      <el-ignored>false</el-ignored>
    </jsp-property-group>
  </jsp-config>
</web-app>

 

log4j2.xml

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" name="demo" packages="">
    <Appenders>
        <File name="demo" fileName="C:/logs/demo.log">
            <PatternLayout>
                <Pattern>%d %p %c %t %m%n</Pattern>
            </PatternLayout>
        </File>
    </Appenders>
    <Loggers>
        <Root level="trace">
            <AppenderRef ref="demo"/>
        </Root>
    </Loggers>
</Configuration>