Friday, May 29, 2015

Cannot change version of project facet Dynamic Web Module to 2.5

  • Deselect the Dynamic Web Module in your project facets. Right click the Project -> preferences -> Project Facets
  • Then run Maven -> Update Project again.

Monday, May 18, 2015

Forgotten PostgreSQL Windows password

I have used net user postgres postgres to reset the password for my database but instead of a success message I am getting "System error 5 has occurred. Access is denied."
You've reset (or tried to reset) the service account password. PostgreSQL won't run as Administrator for security reasons and the installer generally sets it up with a "postgres" user account in PostgreSQL 9.1 and older1. On Windows you can't start a service as a user without saving the password of the user in the registry, so that's what the installer does.
If you change the password for the Windows user account postgres, the PostgreSQL service can no longer start. So don't do that, you'll have to fix the service configuration to store the updated password.
Thankfully I think another mistake prevented you from doing that. It looks like you're probably running your command prompt without using "Run as Administrator" on an unprivileged Windows user account or a machine with UAC, so it isn't running with the access permissions required to change the password for the postgres user.
Before you try to change that password, make sure it's really what you want to do. What's the problem you're trying to solve here? Are you attempting to install a database update or something else that's asking for the password for the postgres Windows user?
Most likely you're just trying to log in to the database. For that, you use the (unfortunately completely unrelated) password stored in the database its self. Since you've lost/forgotten it you'll have to reset it:
  • Find your pg_hba.conf, usually in C:\Program Files\PostgreSQL\9.1\data\pg_hba.conf
  • If necessary, set the permissions on it so that you can modify it; your user account might not be able to do so until you use the security tab in the properties dialog to give yourself that right by using an admin override. Alternately, find notepad / notepad++ in your start menu, right click, choose "Run as administrator", then use File->Open to open pg_hba.conf that way.
  • Edit it to set the "host" line for user "postgres" on host "127.0.0.1/32" to "trust". You can add the line if it isn't there; just insert:
    host all postgres 127.0.0.1/32 trust
    before any other lines. (You can ignore comments, lines beginning with #).
  • Restart the PostgreSQL service from the Services control panel (start->run->services.msc)
  • connect using psql or PgAdmin-III or whatever you prefer
  • ALTER USER postgres PASSWORD 'postgres'
  • remove the line you added to pg_hba.conf or change it back
  • restart PostgreSQL again.

Thursday, May 7, 2015

How to Create VirtualHost in Tomcat 7/8

Source : http://tecadmin.net/create-virtualhost-in-tomcat/

Why VirtualHost ?

Virtual Hosting provides us to host multiple domains (websites) on single server. It is an concept of resource sharing between multiple hosting account. The best use of Virtual hosting is shared hosting servers, where multiple users can host multiple websites on single server.

Setup Details:

We have created a Linux server with ip 192.168.1.100 for Tomcat hosting services only. Soinstall Tomcat 8 and configured to run on port 80. After than we have deployed two java web applications on tomcat using Tomcat Admin panel. Now both applications are running on following urls
http://192.168.1.100/myapp
http://192.168.1.100/myapp2
Now we want to run both web applications on main domains ( example.com & mydomain.org ). So that end users can access web application by using main domain name.

Create Virtual Hosts:

To create virtual hosts in Tomcat, first navigate to Tomcat installation directory and edit config/server.xml file in favorite editor. Add following host entries in configuration file.
 
<Host name="example.com"  appBase="webapps" unpackWARs="true" autoDeploy="true">
 www.example.com
 
 example_access_log
" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> /opt/tomcat8/webapps/myapp" debug="0" reloadable="true"/> </Host> <Host name="mydomain.org" appBase="webapps" unpackWARs="true" autoDeploy="true"> www.mydomain.org mydomain_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> /opt/tomcat8/webapps/myapp2" debug="0" reloadable="true"/> </Host>

Restart Tomcat Service

After adding virtualhost in Tomcat, we need to restart Tomcat service. Use tomcat init service to restart it or if you don’t have init service for tomcat, execute following commands from tomcat installation directory.
# ./bin/shutdown.sh
# ./bin/startup.sh

Tuesday, May 5, 2015

For killing a process linux


For killing a process that is associated with multiple processes, you need to kill that by using process id associated with that process.

To get the process id of that java process run

ps -A |grep java
output of this command will give the list of java processes running on your system. Note down Process ID (PID) of that process whom you want to kill and run

kill -9 PID

private methods on Interface

  Private methods can be used on interface from java 9.   This will help in     Avoiding code duplication.     Ensuring code re-usab...