sayan801 / java-webservice

1 stars 0 forks source link

Install prerequisites #1

Open sayan801 opened 10 years ago

sayan801 commented 10 years ago

Created a Droplet with following config

1GB / 1 CPU
30GB SSD DISK
2TB TRANSFER
sayan801 commented 10 years ago

installing jdk

root@webservice:/# sudo apt-get install openjdk-7-jdk

root@webservice:/# apt-get update

root@webservice:/# sudo apt-get install openjdk-7-jdk

root@webservice:/# java -version
java version "1.7.0_55"
OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1ubuntu1)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)
root@webservice:/#
sayan801 commented 10 years ago

Setting Java_Home

root@webservice:/usr/lib/jvm/java-7-openjdk-amd64# export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64

root@webservice:/usr/lib/jvm/java-7-openjdk-amd64#  cd /etc/profile.d/

root@webservice:/etc/profile.d# nano add_java_home.sh

//add following line here and save
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64

root@webservice:/etc/profile.d#  echo $JAVA_HOME
/usr/lib/jvm/java-7-openjdk-amd64

root@webservice:/# javac
Usage: javac <options> <source files>
where possible options include:
  -g                         Generate all debugging info
  -g:none                    Generate no debugging info
  -g:{lines,vars,source}     Generate only some debugging info
  -nowarn                    Generate no warnings
  -verbose                   Output messages about what the compiler is doing
  -deprecation               Output source locations where deprecated APIs are used
  -classpath <path>          Specify where to find user class files and annotation processors
  -cp <path>                 Specify where to find user class files and annotation processors
  -sourcepath <path>         Specify where to find input source files
  -bootclasspath <path>      Override location of bootstrap class files
  -extdirs <dirs>            Override location of installed extensions
  -endorseddirs <dirs>       Override location of endorsed standards path
  -proc:{none,only}          Control whether annotation processing and/or compilation is done.
  -processor <class1>[,<class2>,<class3>...] Names of the annotation processors to run; bypasses default discovery process
  -processorpath <path>      Specify where to find annotation processors
  -d <directory>             Specify where to place generated class files
  -s <directory>             Specify where to place generated source files
  -implicit:{none,class}     Specify whether or not to generate class files for implicitly referenced files
  -encoding <encoding>       Specify character encoding used by source files
  -source <release>          Provide source compatibility with specified release
  -target <release>          Generate class files for specific VM version
  -version                   Version information
  -help                      Print a synopsis of standard options
  -Akey[=value]              Options to pass to annotation processors
  -X                         Print a synopsis of nonstandard options
  -J<flag>                   Pass <flag> directly to the runtime system
  -Werror                    Terminate compilation if warnings occur
  @<filename>                Read options and filenames from file

root@webservice:/# java
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
where options include:
    -d32          use a 32-bit data model if available
    -d64          use a 64-bit data model if available
    -server       to select the "server" VM
    -zero         to select the "zero" VM
    -jamvm        to select the "jamvm" VM
    -avian        to select the "avian" VM
                  The default VM is server.

    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
                  A : separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -D<name>=<value>
                  set a system property
    -verbose:[class|gc|jni]
                  enable verbose output
    -version      print product version and exit
    -version:<value>
                  require the specified version to run
    -showversion  print product version and continue
    -jre-restrict-search | -no-jre-restrict-search
                  include/exclude user private JREs in the version search
    -? -help      print this help message
    -X            print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions with specified granularity
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions with specified granularity
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:<libname>[=<options>]
                  load native agent library <libname>, e.g. -agentlib:hprof
                  see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
                  load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument
    -splash:<imagepath>
                  show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
root@webservice:/#
sayan801 commented 10 years ago

install postgresql

https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-14-04

root@webservice:/etc/profile.d# sudo apt-get install postgresql postgresql-contrib
root@webservice:/# service postgresql restart
 * Restarting PostgreSQL 9.3 database server 
sayan801 commented 10 years ago

install jboss

following this tutorial ( https://www.digitalocean.com/community/tutorials/how-to-install-jboss-on-ubuntu-12-10-64bit)

root@webservice:/test# wget http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.tar.gz

root@webservice:/test# tar xfvz jboss-as-7.1.1.Final.tar.gz

root@webservice:/test# ls
jboss-as-7.1.1.Final  jboss-as-7.1.1.Final.tar.gz

root@webservice:/test# mv jboss-as-7.1.1.Final /usr/local/share/jboss

root@webservice:/usr/local/share/jboss# adduser appserver

root@webservice:/usr/local/share/jboss# chown -R appserver /usr/local/share/jboss

appserver@webservice:/usr/local/share/jboss/bin$ ./add-user.sh

What type of user do you wish to add?
 a) Management User (mgmt-users.properties)
 b) Application User (application-users.properties)
(a): a

Enter the details of the new user to add.
Realm (ManagementRealm) :

Username (chandra) : technicise
Password :
Re-enter Password :
About to add user 'technicise' for realm 'ManagementRealm'
Is this correct yes/no? yes
Added user 'technicise' to file '/usr/local/share/jboss/standalone/configuration/mgmt-users.properties'
Added user 'technicise' to file '/usr/local/share/jboss/domain/configuration/mgmt-users.properties'
appserver@webservice:/usr/local/share/jboss/bin$

appserver@webservice:/usr/local/share/jboss/bin$ ./standalone.sh -Djboss.bind.address=128.199.255.162 -Djboss.bind.address.management=128.199.255.162&
[1] 11306
appserver@webservice:/usr/local/share/jboss/bin$ =========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /usr/local/share/jboss

  JAVA: /usr/lib/jvm/java-7-openjdk-amd64/bin/java

  JAVA_OPTS:  -server -XX:+UseCompressedOops -XX:+TieredCompilation -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.server.default.config=standalone.xml

=========================================================================

16:17:45,934 INFO  [org.jboss.modules] JBoss Modules version 1.1.1.GA
16:17:46,341 INFO  [org.jboss.msc] JBoss MSC version 1.0.2.GA
16:17:46,405 INFO  [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting
16:17:47,838 INFO  [org.xnio] XNIO Version 3.0.3.GA
16:17:47,851 INFO  [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)
16:17:47,865 INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA
16:17:47,898 INFO  [org.jboss.remoting] JBoss Remoting version 3.2.3.GA
16:17:47,956 INFO  [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
16:17:47,973 INFO  [org.jboss.as.configadmin] (ServerService Thread Pool -- 26) JBAS016200: Activating ConfigAdmin Subsystem
16:17:48,014 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 31) JBAS010280: Activating Infinispan subsystem.
16:17:48,085 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 44) JBAS013101: Activating Security Subsystem
16:17:48,107 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 38) JBAS011800: Activating Naming Subsystem
16:17:48,103 INFO  [org.jboss.as.osgi] (ServerService Thread Pool -- 39) JBAS011940: Activating OSGi Subsystem
16:17:48,144 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
16:17:48,171 INFO  [org.jboss.as.connector] (MSC service thread 1-1) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final)
16:17:48,275 INFO  [org.jboss.as.security] (MSC service thread 1-1) JBAS013100: Current PicketBox version=4.0.7.Final
16:17:48,353 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
16:17:48,743 INFO  [org.jboss.as.naming] (MSC service thread 1-2) JBAS011802: Starting Naming Service
16:17:48,914 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-1) JBoss Web Services - Stack CXF Server 4.0.2.GA
16:17:49,236 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-2) JBAS015400: Bound mail session [java:jboss/mail/Default]
16:17:49,279 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-1) Starting Coyote HTTP/1.1 on http--128.199.255.162-8080
16:17:49,779 INFO  [org.jboss.as.remoting] (MSC service thread 1-1) JBAS017100: Listening on /128.199.255.162:9999
16:17:49,862 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-2) JBAS015012: Started FileSystemDeploymentService for directory /usr/local/share/jboss/standalone/deployments
16:17:49,944 INFO  [org.jboss.as.remoting] (MSC service thread 1-1) JBAS017100: Listening on /128.199.255.162:4447
16:17:50,023 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
16:17:50,050 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://128.199.255.162:9990
16:17:50,051 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 4968ms - Started 133 of 208 services (74 services are passive or on-demand)

server running on http://128.199.255.162:9990/console/App.html

image

sayan801 commented 10 years ago

PostgreSQL JDBC driver install

http://jdbc.postgresql.org/download.html

root@webservice:/test# wget http://jdbc.postgresql.org/download/postgresql-9.3-1102.jdbc41.jar
--2014-08-15 16:27:38--  http://jdbc.postgresql.org/download/postgresql-9.3-1102.jdbc41.jar
Resolving jdbc.postgresql.org (jdbc.postgresql.org)... 174.143.35.228, 2001:4800:1501:1::228
Connecting to jdbc.postgresql.org (jdbc.postgresql.org)|174.143.35.228|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 592322 (578K) [application/java-archive]
Saving to: ‘postgresql-9.3-1102.jdbc41.jar’

100%[==================================================>] 592,322      188KB/s   in 3.1s

2014-08-15 16:27:42 (188 KB/s) - ‘postgresql-9.3-1102.jdbc41.jar’ saved [592322/592322]

create a directory /usr/local/share/jboss/modules/org/postgresql/main and copy the jdbc driver there

 root@webservice:/usr/local/share/jboss/modules/org/postgresql/main# pwd
/usr/local/share/jboss/modules/org/postgresql/main
dolu1602 commented 10 years ago

create folders under \jboss-as-7.1.1.Final\modules\org\postgresql\main

  1. copy postgresql-9.2-1004.jdbc41.jar to \jboss-as-7.1.1.Final\modules\org\postgresql\main 2, create module,xml under this folder or copy paste attached file
sayan801 commented 10 years ago

added module.xml in root@webservice:/usr/local/share/jboss/modules/org/postgresql/main folder

<?xml version="1.0" encoding="UTF-8"?>

       <module xmlns="urn:jboss:module:1.0" name="org.postgresql">
       <resources>
           <resource-root path="postgresql-9.3-1102.jdbc41.jar"/>
       </resources>
       <dependencies>
               <module name="javax.api"/>
               <module name="javax.transaction.api"/>
               </dependencies>

</module>
sayan801 commented 10 years ago

Creating db in postgres

root@webservice:/test# su - postgres

postgres@webservice:~$ createuser --superuser chandra
postgres@webservice:~$ psql
psql (9.3.5)
Type "help" for help.

postgres=# \password chandra
Enter new password:
Enter it again:
postgres=# \q

postgres@webservice:~$ su
Password:

root@webservice:/# su postgres
postgres@webservice:/$ psql

psql (9.3.5)
Type "help" for help.

postgres=# CREATE DATABASE chandradb OWNER chandra;
CREATE DATABASE
postgres=# \list
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 chandradb | chandra  | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
(4 rows)

postgres=#
sayan801 commented 10 years ago

go to /usr/local/share/jboss/standalone/configuration and open standalone.xml

add in datasource section

 <datasource jndi-name="java:jboss/datasources/JavaWebserviceTest" pool-nam$
                   <connection-url>jdbc:postgresql://localhost:5432/chandradb</connection-$
                   <driver>postgresql-jdbc4</driver>
                   <pool>
                       <min-pool-size>2</min-pool-size>
                       <max-pool-size>20</max-pool-size>
                   </pool>
                   <security>
                       <user-name>chandra</user-name>
                       <password>chandra123</password>
                   </security>
               </datasource>

paste in drivers section

 <driver name="postgresql-jdbc4" module="org.postgresql">
                       <driver-class>org.postgresql.Driver</driver-class>
                   </driver>
sayan801 commented 10 years ago

@vepanjerigovinda Start jboss is showing error...

postgres@webservice:/usr/local/share/jboss/bin$ ./standalone.sh -Djboss.bind.address=128.199.255.162 -Djboss.bind.address.management=128.199.255.162&
[1] 11795
postgres@webservice:/usr/local/share/jboss/bin$ =========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /usr/local/share/jboss

  JAVA: /usr/lib/jvm/java-7-openjdk-amd64/bin/java

  JAVA_OPTS:  -server -XX:+UseCompressedOops -XX:+TieredCompilation -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.server.default.config=standalone.xml

=========================================================================

Unable to set property fileName on class org.jboss.logmanager.handlers.FileHandler: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.jboss.logmanager.PropertyConfigurator.configureProperties(PropertyConfigurator.java:187)
        at org.jboss.logmanager.PropertyConfigurator.configureHandler(PropertyConfigurator.java:312)
        at org.jboss.logmanager.PropertyConfigurator.configure(PropertyConfigurator.java:128)
        at org.jboss.logmanager.PropertyConfigurator.configure(PropertyConfigurator.java:86)
        at org.jboss.logmanager.LogManager.readConfiguration(LogManager.java:246)
        at org.jboss.logmanager.LogManager.readConfiguration(LogManager.java:231)
        at java.util.logging.LogManager$2.run(LogManager.java:312)
        at java.util.logging.LogManager$2.run(LogManager.java:310)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.util.logging.LogManager.readPrimordialConfiguration(LogManager.java:310)
        at java.util.logging.LogManager.getLogManager(LogManager.java:292)
        at java.util.logging.Logger.<init>(Logger.java:265)
        at java.util.logging.LogManager$RootLogger.<init>(LogManager.java:1430)
        at java.util.logging.LogManager$RootLogger.<init>(LogManager.java:1428)
        at java.util.logging.LogManager$1.run(LogManager.java:196)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.util.logging.LogManager.<clinit>(LogManager.java:173)
        at org.jboss.modules.Main.main(Main.java:275)
Caused by: java.io.FileNotFoundException: /usr/local/share/jboss/standalone/log/boot.log (Permission denied)
        at java.io.FileOutputStream.open(Native Method)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
        at org.jboss.logmanager.handlers.FileHandler.setFile(FileHandler.java:152)
        at org.jboss.logmanager.handlers.FileHandler.setFileName(FileHandler.java:183)
        ... 22 more
17:27:57,595 INFO  [org.jboss.modules] JBoss Modules version 1.1.1.GA
17:27:58,011 INFO  [org.jboss.msc] JBoss MSC version 1.0.2.GA
17:27:58,081 INFO  [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting
17:27:58,094 ERROR [org.jboss.msc.service.fail] MSC00001: Failed to start service jboss.as: org.jboss.msc.service.StartException in service jboss.as: Failed to start service
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_55]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_55]
        at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_55]
Caused by: java.lang.IllegalStateException: JBAS014922: Directory /usr/local/share/jboss/standalone/data/content is not writable
        at org.jboss.as.repository.ContentRepository$Factory$ContentRepositoryImpl.<init>(ContentRepository.java:123)
        at org.jboss.as.repository.ContentRepository$Factory.addService(ContentRepository.java:97)
        at org.jboss.as.server.ApplicationServerService.start(ApplicationServerService.java:134) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
        ... 3 more

17:27:58,102 ERROR [stderr] java.util.concurrent.ExecutionException: Operation failed
17:27:58,102 ERROR [stderr]     at org.jboss.threads.AsyncFutureTask.operationFailed(AsyncFutureTask.java:74)
17:27:58,103 ERROR [stderr]     at org.jboss.threads.AsyncFutureTask.get(AsyncFutureTask.java:268)
17:27:58,103 ERROR [stderr]     at org.jboss.as.server.Main.main(Main.java:98)
17:27:58,104 ERROR [stderr]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
17:27:58,104 ERROR [stderr]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
17:27:58,104 ERROR [stderr]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
17:27:58,105 ERROR [stderr]     at java.lang.reflect.Method.invoke(Method.java:606)
17:27:58,105 ERROR [stderr]     at org.jboss.modules.Module.run(Module.java:260)
17:27:58,106 ERROR [stderr]     at org.jboss.modules.Main.main(Main.java:291)
17:27:58,106 ERROR [stderr] Caused by: org.jboss.msc.service.StartException in service jboss.as: Failed to start service
17:27:58,107 ERROR [stderr]     at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767)
17:27:58,107 ERROR [stderr]     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
17:27:58,107 ERROR [stderr]     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
17:27:58,108 ERROR [stderr]     at java.lang.Thread.run(Thread.java:744)
17:27:58,110 ERROR [stderr] Caused by: java.lang.IllegalStateException: JBAS014922: Directory /usr/local/share/jboss/standalone/data/content is not writable
17:27:58,111 ERROR [stderr]     at org.jboss.as.repository.ContentRepository$Factory$ContentRepositoryImpl.<init>(ContentRepository.java:123)
17:27:58,111 ERROR [stderr]     at org.jboss.as.repository.ContentRepository$Factory.addService(ContentRepository.java:97)
17:27:58,111 ERROR [stderr]     at org.jboss.as.server.ApplicationServerService.start(ApplicationServerService.java:134)
17:27:58,111 ERROR [stderr]     at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
17:27:58,112 ERROR [stderr]     at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
17:27:58,112 ERROR [stderr]     ... 3 more