B4J Tutorial [server] Run a Server on a VPS

Discussion in 'B4J Tutorials' started by Erel, Nov 15, 2015.

  1. Erel

    Erel Administrator Staff Member Licensed User

    The steps required to run a B4J server on a hosted server (such as a VPS) are:

    1. Download Java JRE 8 (in most cases you will need the Linux version):
    http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html

    If you are not familiar with Linux then download it to your development computer, unzip it and upload the files with FTP. You do not need to install anything.

    2. Upload the compiled jar with any additional files (www folder for example).

    3. Start the server with:
    Code:
    nohup path_to_java/bin/java -jar somejar.jar > nohup.out &
    The console output will be written to nohup.out.
    You need to use nohup as otherwise the server will be killed when you log out.

    4. Make sure that the relevant port is open in the firewall settings.

    5. If you want to kill the server you can use this command to find the process number:
    Code:
    ps -ef | grep java
    kill <process number>
    6. Tip: Use tail -f nohup.out
    To monitor the server logs.

    If there is another http server running on the computer, like Apache or IIS, then you should not copy the B4J server to its public_html / www / or any other publicly accessible folder.
     
    Last edited: Jul 7, 2017
    DonManfred, Beja, fredo and 8 others like this.
  2. codie01

    codie01 Member Licensed User

    Good Day Erel,

    I have unzipped the jre to my computer, Ftp ready, which directory do I install these to?

    Thanks Phil
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    You don't need to install it. Just unpack it to whichever folder you like.
     
  4. codie01

    codie01 Member Licensed User

    Hi all, Erel

    Hope this is the right place. I have setup a VPS - Linux, I have installed Jetty and Java.

    When I fire up Jetty all seems well and I can see the Jetty Logo etc when i browse the ip of the server xxx.xxx.xxx.xxx:8080

    However when I run the server Jar I get a bundle error shown in red as follows:

    ---------------- LOG -----------------

    2015-12-17 16:26:36.481:INFO::main: Logging initialized @526ms

    2015-12-17 16:26:36.573:INFO:eek:ejs.Server:main: jetty-9.1.z-SNAPSHOT

    2015-12-17 16:26:36.596:WARN:eek:ejh.MimeTypes:main: java.util.MissingResourceException: Can't find bundle for base name org/eclipse/jetty/http/encoding, locale en_US

    2015-12-17 16:26:36.628:INFO:eek:ejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@675d3402{/,0.0.0.0:51042}

    2015-12-17 16:26:36.646:INFO:eek:ejs.Server:main: Started @698ms

    ---------------- LOG -----------------

    Thanks in advanced,

    Philip
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    Ignore it. This message is always displayed. It is fixed in B4J v4.0.
     
    lemonisdead likes this.
  6. jinyistudio

    jinyistudio Active Member Licensed User

    Hi

    How to(Or Could I) setting Multi-domain name for every APP when i running two or more B4J-APP in same VPS ? :(

    Eaxmple:
    a.com -> 192.168.1.1:8000 (APP1)
    b.com -> 192.168.1.1:8001 (APP2)
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this question.
     
  8. shashkiranr

    shashkiranr Active Member Licensed User

    Hi all,

    I started my rdc server on the vps running centos 6 successfully using the below post by martin

    http://www.basic4ppc.com/android/fo...ect-to-any-remote-db.31540/page-8#post-217480

    I opened the firewall port 51044 and confirmed it using the below code

    Code:
    sudo iptables -I INPUT -p tcp -m tcp --dport 51044 -j ACCEPT

    iptables -L -n
    When I enter the server ip to access the test handler to check the connection to db, i get 404 not found error. Am i missing something? Kindly let me know

    Code:
    http://serverip/test:51044
    Best,
    SK
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    Note that you should have started a new thread for this question.

    The port goes after the domain:
    Code:
    http://serverip:51044/test
    For further discussion please start a new thread.
     
  10. shashkiranr

    shashkiranr Active Member Licensed User

  11. JakeBullet70

    JakeBullet70 Well-Known Member Licensed User

    Will there be a problem with this log file growing?
     
  12. Erel

    Erel Administrator Staff Member Licensed User

    JakeBullet70 likes this.
  13. achtrade

    achtrade Active Member Licensed User

    I'm starting the server with this:

    nohup /home/user/RDC-Server/jdk1.7.0_79/bin/java /home/user/RDC-Server/jdbc_driver/mysql-connector-java-5.1.22-bin.jar > nohup.out &

    and I'm getting this error:

    Error: could not find or load main class .home.user.RDC-Server.jdbc_driver.mysql-connector-java-5.1.22-bin.jar

    what's wrong ?

    thanks.
     
  14. shashkiranr

    shashkiranr Active Member Licensed User

    add this line in the main class of B4J

    Code:
    #AdditionalJar: mysql-connector-java-5.1.38-bin
     
  15. achtrade

    achtrade Active Member Licensed User

    What do you mean ?, I'm not using my app yet, I'm trying to start my server in a Linux Centos VPS
     
  16. achtrade

    achtrade Active Member Licensed User

    After add the -jar parameter,
    nohup /home/user/RDC-Server/jdk1.7.0_79/bin/java -jar /home/user/RDC-Server/jdbc_driver/mysql-connector-java-5.1.22-bin.jar > nohup.out &

    now I'm getting this error:

    no main manifest attribute, in /home/user/RDC-Server/jdbc_driver/mysql-connector-java-5.1.22-bin.jar

    any idea?
     
  17. Erel

    Erel Administrator Staff Member Licensed User

    You need to start your application. mysql-connector-java-5.1.22-bin.jar is a library used by your application. It cannot be started.
     
  18. achtrade

    achtrade Active Member Licensed User

  19. Erel

    Erel Administrator Staff Member Licensed User

    Your question has nothing to do with this thread topic.
     
  20. victormedranop

    victormedranop Active Member Licensed User

    hi, I upload de Jar file run with nohup but I get an error in logs file.

    it said is looking for :51042/ws/demo HTTP/1.1" 302 0 "-" ws folder, I cant find it. it's just testing the demo apps.

    i'm using debian on a vps. Digital ocean. with java


    root@dev01:~# java -version
    java version "1.8.0_111"
    Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
    Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

    in windows works fine.

    regards,

    Victor
     
    Last edited: Jan 29, 2017
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice