Skip to content

Commit 8ac4d37

Browse files
committed
Initial commit
0 parents  commit 8ac4d37

36 files changed

+6973
-0
lines changed

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# How to Run and Deploy the Java PostgreSQL Upload App #
2+
3+
## Overview of the app ##
4+
5+
This is a Java app that uses the following cloud services:
6+
7+
- PostgreSQL Database
8+
9+
This app demonstrates how to connect to a PostgreSQL database on BlueMix from a Java app.
10+
Simply upload a line-separated file of text (e.g. tweets), and it will add each line to Postgres.
11+
12+
## Prerequisites ##
13+
14+
Before we begin, we first need to install the command line tool that will be used to upload and manage your application. Cloud Foundry uses a tool called [**cf**](https://github.com/cloudfoundry/cf). This tool is written in Ruby, so you must have Ruby installed. If you are running on Windows, you can install Ruby from [this](http://rubyinstaller.org/downloads/) website.
15+
16+
For Linux systems, consult your documentation for how to install the **ruby** package - for Ubuntu the command:
17+
18+
apt-get install ruby
19+
20+
should work for you.
21+
22+
Once Ruby is installed, cf can be installed by using the **gem install** command:
23+
24+
gem install cf
25+
26+
## Download the App ##
27+
28+
The source for this app is at GitHub so, for example, if you are using the command line you can clone the repository like this:
29+
30+
git clone https://github.com/ibmjstart/bluemix-java-postgresql-upload.git
31+
32+
If you want to use Eclipse to work on it, there are two ways you can get the source into Eclipse:
33+
34+
1. Import the Eclipse project by following these instructions:
35+
1. Start by cloning the repository, as described above
36+
2. Open Eclipse
37+
3. Select File->Import
38+
4. Under the header labeled "General", click "Existing Projects Into Workspace" and click Next
39+
5. Click "Browse" next to the first text field, and navigate to the cloned repository and find the folder labeled "app" and click ok.
40+
6. Under Projects you should now see a project called "PostgreSQLUpload", make sure the checkbox next to the "PostgreSQLUpload" project is checked and then click Finish
41+
7. You should now see the "PostgreSQLUpload" project in your list of projects in Eclipse.
42+
43+
2. Import the WAR File
44+
1. Navigate to https://github.com/ibmjstart/bluemix-java-postgresql-upload/releases
45+
2. Click the green button labeled "PostgreSQLUpload.war" and that will download the WAR file.
46+
3. Open Eclipse
47+
4. Then File->Import
48+
5. Scroll down to the "Web" section, expand that section and click WAR File then click Next.
49+
6. Click next and then Finish and the project should be imported into Eclipse
50+
51+
## Deploying the App ##
52+
53+
In the terminal, go in the directory of the app. The application is wrapped in a WAR file. You can directly deploy/push the WAR file using push command:
54+
55+
cf push
56+
57+
Just follow the instructions on the screen. You can select the default settings for deploying the app, i.e. for URL, memory reservations (512 Recommended), number of instances. You need to bind the PostgreSQL service to your application.
58+
59+
### Binding a Service to Your App ###
60+
61+
For the app to function correctly, you must create the service instance and bind the service instance while deploying the app. The **cf push** command will ask, "Create services for application?" Answer yes, then you will be presented with a list of services. Choose PostgreSQL from this list. Below, you can see some screenshots of what this should look like when deploying from the command line.
62+
63+
Here are some snapshots of how to deploy the app and create services required for the app:
64+
65+
(These are to be added)
66+
67+
After the application is deployed using **cf push**, you can check the status of the app using the following command: **cf apps**. If the status is RUNNING, you can hit the URL in the browser and see the application is running.
68+
69+
70+
## Troubleshooting ##
71+
72+
- Sometimes your app may not work as expected and debugging needs to be done. The cf command line tool can be used to assist with debugging. With the cf you can check your app's logs by typing the command **cf logs [app_name]**
73+
- When you first start using the cf tool, you may potentially have trouble logging in due to no target being set. To view the target that is set, type **cf target** and if you want to set a new target type **cf target [target_url]**. Note: The target URL will usually be in the form of http://api.xxx.tld
74+
- From time to time your app may stop working, this means it could require a restart. To do this you must first stop it by typing **cf stop**. Once the app has been stopped, you can type **cf start** and if there are no other problems your app should start.

app/.classpath

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5+
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/json-simple-1.1.jar"/>
6+
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-fileupload-1.3.jar"/>
7+
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-io-2.4.jar"/>
8+
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/postgresql-9.1-901.jdbc4.jar"/>
9+
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
10+
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
11+
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/servlet-api-2.5.jar"/>
12+
<classpathentry kind="output" path="bin"/>
13+
</classpath>

app/.project

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>PostgreSQLUpload</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.wst.common.project.facet.core.builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.jdt.core.javabuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>org.eclipse.wst.validation.validationbuilder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
</buildSpec>
29+
<natures>
30+
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
31+
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
32+
<nature>org.eclipse.jdt.core.javanature</nature>
33+
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
34+
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
35+
</natures>
36+
</projectDescription>

app/.settings/.jsdtscope

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry excluding="js/" kind="src" path="WebContent"/>
4+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
5+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
6+
<attributes>
7+
<attribute name="hide" value="true"/>
8+
</attributes>
9+
</classpathentry>
10+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
11+
<classpathentry kind="output" path=""/>
12+
</classpath>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
4+
org.eclipse.jdt.core.compiler.compliance=1.5
5+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7+
org.eclipse.jdt.core.compiler.source=1.5
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
2+
<wb-module deploy-name="TwitterSearch0">
3+
<wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
4+
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
5+
<property name="java-output-path" value="/TwitterSearch0/bin"/>
6+
<property name="context-root" value="TwitterSearch0"/>
7+
</wb-module>
8+
</project-modules>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<faceted-project>
3+
<fixed facet="wst.jsdt.web"/>
4+
<installed facet="java" version="1.5"/>
5+
<installed facet="jst.web" version="2.5"/>
6+
<installed facet="wst.jsdt.web" version="1.0"/>
7+
</faceted-project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Window

app/WebContent/META-INF/MANIFEST.MF

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Manifest-Version: 1.0
2+
Class-Path:
3+
Binary file not shown.
Binary file not shown.
181 KB
Binary file not shown.
Binary file not shown.
21.3 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
222 KB
Binary file not shown.
25.9 KB
Binary file not shown.
15.7 KB
Binary file not shown.
Binary file not shown.
116 KB
Binary file not shown.

app/WebContent/WEB-INF/web.xml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
3+
<welcome-file-list>
4+
<welcome-file>index.html</welcome-file>
5+
</welcome-file-list>
6+
<servlet>
7+
<display-name>HomeServlet</display-name>
8+
<servlet-name>HomeServlet</servlet-name>
9+
<servlet-class>com.ibm.bluemix.samples.HomeServlet</servlet-class>
10+
</servlet>
11+
<servlet-mapping>
12+
<servlet-name>HomeServlet</servlet-name>
13+
<url-pattern></url-pattern>
14+
</servlet-mapping>
15+
<servlet>
16+
<display-name>DeleteServlet</display-name>
17+
<servlet-name>DeleteServlet</servlet-name>
18+
<servlet-class>com.ibm.bluemix.samples.DeleteServlet</servlet-class>
19+
</servlet>
20+
<servlet-mapping>
21+
<servlet-name>DeleteServlet</servlet-name>
22+
<url-pattern>/delete</url-pattern>
23+
</servlet-mapping>
24+
<servlet>
25+
<display-name>UploadServlet</display-name>
26+
<servlet-name>UploadServlet</servlet-name>
27+
<servlet-class>com.ibm.bluemix.samples.UploadServlet</servlet-class>
28+
</servlet>
29+
<servlet-mapping>
30+
<servlet-name>UploadServlet</servlet-name>
31+
<url-pattern>/upload</url-pattern>
32+
</servlet-mapping>
33+
</web-app>

0 commit comments

Comments
 (0)