Upload opencms project on real server - java

I'm working on an open source java cms that name is opencms .
it is war file that you deploy it with tomcat and when it's up you go to localhost:8080/opencms and start to configure it as you want.
my problem is that when I've done my all jobs and making a cms site with it, what I must do to upload it on a real server ?
do I have to make war file from it then upload it or just i upload it's deployed folder to server tomcat ?
and what i must do with it's database ? it's enough to export a .sql file from my local database and execute it on server database or i must do some other things ?
please help me
thanks

You need an opencms installation on your "real" server that fits the one you created your page with.
It should be possible to just copy the content of opencms webapp folder inside tomcat to the tomcat on the target machine and also transfer copies of the associated databases to the "real" server.
Personally I prefer performing a standard installation of opencms on the target machine and configuring it (remove example content, change passwords, etc.).
Then I would use the export functionality of opencms to export the content on the development machine and import it into the target opencms instance.
The complexity depends on how much changes you have applied to the default installation - if you have developed your own modules, then it might be a bit more difficult.

Related

How to deploy a JSP on to a server other than Tomcat

I am trying to deploy a JSP/servlet onto a server. Not tomcat but on a real web domain. This is my first time doing so and so far I exported it into a war file and placed the file onto the server. Nothing happened which is why I am here. All the google searches seem to concentrate on Tomcat which I have already ran the project on. Advice?
Ok, let's get really basic. You want to see the compiled JSP in a browser, through some public URL, right?
First, find a place to host your application. You can try Digital Ocean (starts at $5/mo), EATJ (free version available), Amazon AWS (free trial available), OpenShift (free gears available), your own computer with dynamic DNS, or many other options available through Google.
Next, you packed your compiled code to a war file. That war file needs to be unpacked (deployed) using some software.
There are numerous ways to handle this (Tomcat, Jetty, Glassfish, etc.). They all have their pros and cons. Pick one and learn the very basics. Tomcat doesn't require a separate web server but you can set one up with it if you like. At this stage, I would keep it simple and not do that yet.
Lastly, set up GoDaddy (or whomever you used to get your URL) to point to the IP address of that server. If your server is running and enough time has passed for the changes to propagate, you should see your page.
There are plenty other J2EE server for example, JBoss and Glassfish. Each one has it's own way to deploy your war files. For example, Glassfish is throught a web administration console (https://docs.oracle.com/cd/E19798-01/821-1757/6nmni99aj/index.html) and in JBoss you need to deploy the war file in a specific directory (http://docs.jboss.org/jbossweb/3.0.x/deployer-howto.html).
It depends on which J2EE server you are using.
Now if you want to get your own server and configure it:
Get the server or VPS
Install JAVA
Install Apache
Install a J2EE server (I prefer glassfish)
Configure glassfish with apache (http://www.codefactorycr.com/glassfish-behind-apache.html) to use apache in front of glassfish
You may want to block the ports 4848 and 8080 used by glassfish
Deploy your webapp
Have fun!!!
PS: I'm assuming you have root access to the server
Easy Apache Tomcat 7 install after,
Run Code via SSH:
/usr/local/cpanel/scripts/addservlets2 --domain=domain.com
For Linux.

deploying a php project

A newbie to php development looking for help in deploying a php project in Apache server.
I am wonering how to put the php project that is in MVC structure into my Apache server. Say suppose it's a java project then i would export the whole project (with libs, source files etc) as a war file and then deploy the war in the server. My question is, in what format should the php project be put in so that it is up and active running on the server.
Help on this would be really useful to have my project up and running for users. Thanks !
Short answer: Nothing such as WARs in Java or other kinds of "packaging" is needed for PHP scripts. Your server has a special directory set as document root for the web server, you simply place your files inside it (or a subdirectory in it) and you're done.
There are however multiple ways how to bring your files into that directory.
I would use GIT. Make an account to GitHub and create a repository. Look up tutorials on how to commit your files into GIT.
Git Tutorial (GitHub)
Then go to your server and set up GIT folder there and connect to your repository.
Then you will be able to do GIT PULL and update your PHP code within seconds.
OR you can do the annoying style and manually upload files one by one via FTP server.
The first option would be to use a repository, such as GitHub or Assembla. I've used both, and I'd recommend Assembla - but it depends on preferences and requirements. A repository will allow you to commit files to it on a regular basis, and keep all of your work synced together in one location. You can then set up your server to sync with your repository.
If you don't wish to have a repository, then you can simply send all of the files that construct your PHP project to a .zip file. That .zip file can then be uploaded to Apache server, unzipped, and you'll be good to go (providing you have your server configured correctly to match the needs and requirements of the application). You should only need to .zip if you're using cPanel/Plesk, for example.
Alternatively, upload via FTP using a client such as Filezilla.

Delete a jar locked by server

I have a web application build using j2ee and java , where user can upload the jar or delete the existing jar and upload a new one. Since server is running and the jars are locked by it, when user choose to delete the jar I am not able to delete it. Is there any way to achieve this ? When I googled I got information about hot deployment or using class loader to unload the jar and then delete it. Whats the good approach to do it ? Any help or suggestion will be really appreciated.
If the file is in use by the web server, the file system simply won't let you remove the file as it's locked by the web server. You have two options.
You could hot deploy a new copy of the jar, for instance if it's a war, say you have (for arguments sake assuming tomcat)...
ROOT.war, you can copy into the webapps directory ROOT#001.war and all traffic will be moved to this location. This new war could contain your new jars.
I personally only do this sparingly as I trust the web server to free resources better when it's restarted. Other than this, your only real option if you want to deploy jars on the fly safely would be to stop the web server, apply the jar, start again. If you want to have no down time you could look at clustering the environment but it really depends how business critical it is to you.

Web application cannot establish connection to database

My application, when running on Tomcat, is not able to connect to my database when deployed as a .war in the webapps folder, but it can connect when I am running it through Eclipse directly. The code is exactly the same in both cases. In addition, other apps in the webapps folder, which originally could connect to the database, can no longer do so. The jdbc code is correct as I have tested it with offline applications or when running it through eclipse, but not when I access it on, say, Chrome, using localhost. What has happened to my tomcat server?
Note: the JDBC driver is the MS Access one.
The code is exactly the same in both cases.
No it's not; if it were exactly the same you'd be connecting properly.
but it can connect when I am running it through Eclipse directly
Does this mean that you have a main method that drives the code that connects properly? The way you do it is usually different from a web app - you know that, right?
If you could post an exception or log message it would help a great deal.
I'm guessing it could be any one of the following; guessing is necessary because you haven't provided enough information for a solid answer:
The JDBC driver JAR is not available when you run under one configuration; you'll see a ClassNotFoundException in that case.
You haven't configured a JNDI data source properly in Tomcat.
You didn't put the JDBC driver JAR in the Tomcat /lib directory.
Could be other possibilities.
UPDATE:
Since you're using Access, and providing no other information, I'm guessing that you're using a relative file path to get to the Access .mdb file. Your command line app that runs successfully in Eclipse works because you give a relative file path that is correct relative to the project root. When you deploy to Tomcat, that relative path is no longer correct, so your application can't find the database anymore.
Sounds like you aren't printing the stack trace for errors, so you're losing out on information that might help you figure this out.
Microsoft Access is not a multi-user database. A web based application running on Tomcat is certainly multi-threaded. You should not be using Access for a web application. I'd consider switching to another database.
First, you need to verify the path to your database file. In fact, I believe it has to be an absolute path for tomcat to work correctly. The simplest thing to do is to put your database file in C:\data or similar and then hard code the path in your code. Of course, the file will be outside of your war and thus not portable (i.e., deployable to a remote server).
Second, you do need to make sure that the JDBC driver is available. If you use Class.forName in your code to load the driver, you will only need to make sure that the jar containing the driver is in the tomcat classpath (which would include the lib directory of your webapp). If you use the -Djdbc.drivers JVM flag approach, you will need to add it to the tomcat startup scripts.

How to put a eclipse web project onto a real world server?

I have never placed anything on a web server.
i have a dynamic web project built in eclipse using servlets (using tomcat 7) that connects to a mysql database that is on a computer that is on my college network.
How would i go about placing this project onto a Web Server so i can access it from anywhere. If you could explain the best and cheapest option that would be great
what would be the steps involved to make this project go live?
Amazon EC2 has free micro instance that will run tomcat+mysql! It's worth checking out!
613 MB of memory and 32-bit and 64-bit platform support
If you are independent vendor you have 2 possibilities.
First, take computer, connect it to network, install tomcat and mysql on it, deploy your web application, buy fixed IP, buy domain name and enjoy.
Second way is find hosting company that hosts java applications and provides mysql service. There are a lot of such companies. If you choose one you pay them money and they do everything for you. I believe that if you need java and mysql you will not find free hosting company. But try. Probably there are such companies that will provide service for free and add a couple of their banners to your site.
And yet another way is to buy virtual machine from for example Amazone cloud. You can buy the simplest linux machine. Install java+tomcat+mysql on it. Buy domain name and you are done. It is not free but it costs several cents an hour, so probably this will be the best way for you.
In order to deploy your war file, all you need to do is copy it to the apache-tomcat webapps directory. Tomcat will open it up for you automatically, and your application is up and running.
Do not forget to make your jdbc jar file available to tomcat.
Hosting starts at around $2.45 per month. We have had great experience with MochaHost.
You could host it yourself on a system, even if you only have a dynamic IP, using DynDNS.org, but keeping a server up 24/7/365 involves a lot of work.
Once you create the WAR file as Jeremy instructed, you will just drop it in the webapps folder of the Tomcat installation.
For your reference:
You can check out with http://www.hostjava.net they have pretty decent hosting plans with tomcat and mysql.
So that you can deploy your file, all you have to do is copy it for the apache-tomcat webapps directory. Tomcat will open it up in your case automatically, as well as your application is up and running.
Do not forget to build your jdbc jar file open to tomcat.
Hosting starts at about $3.95 per month. We now have had great experience with HostMyth.
You might host it yourself on something, in case you only have an engaged IP, using cloudflare, but keeping a server up 24/7/365 involves lots of work.

Categories