Tuesday, January 28, 2014

com.sun.tools.javac.Main is not on the classpath.

BUILD FAILED
C:\Documents and Settings\Sjoerd\workspace\PPath\resources\build.xml:107: The following error occurred while executing this line:
C:\Documents and Settings\Sjoerd\workspace\PPath\resources\build.xml:141: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "C:\Program Files\Java\jre6"


Solution:


              1) In Eclipse click Run->External Tools->External Tools Configurations
2) Click JRE tab
3) Click Installed JREs... button
4) Click Add button (select Standard VM, where applicable)
5) Click Directory Button
6) Browse to your JDK version (not JRE) of your installed Java (eg: C:\Program Files\Java\jdk1.7.0_04)
7) Click Finish.
8) Re-run Ant script - have fun!

Sunday, January 26, 2014

Why are Java applications blocked by your security settings with the latest Java?

SYMPTOMS 

Trying to run the Java applications with Java version 7 Update 51, generates messages that says 
Java applications are blocked by your security settings.
Missing Application-Name manifest attribute
Missing required Permissions manifest attribute in main jar


CAUSE 

Starting with Java 7 Update 51, Java has enhanced security model to make user system less vulnerable to the external exploits. The new version of Java does not allow users to run the applications that are not signed (Unsigned), Self signed (not signed by trusted authority) and the applications that are missing permission attributes.

Risks involved in running each kind of applications:

  • Unsigned applications:
    An application without a certificate (i.e. unsigned apps), or missing application Name and Publisher information are blocked by default. Running this kind of application is potentially unsafe and present higher level of risk. 
  • Self signed application (Certificate not from trusted authority):
    An application with self-signed certificate is blocked by default. Applications of this type present the highest level of risk because publisher is not identified and the application may be granted access to personal data on your computer.
  • Jar file missing Permission Attribute:
    Permissions Attribute verifies that the application requests the permission level that developer specified. If this attribute is not present, it might be possible for an attacker to exploit a user by re-deploying an application that is signed with original certificate and running the application at a different privilege level.

SOLUTION 

The application that you are running is blocked because the developer has not met with the security guidelines implemented in Java 7 Update51.
It is in your best interest to contact developer or publisher of this application and let them know about the application being blocked. Also provide developers with these links that gives details about implementing secure practices in the code for the application.


WORKAROUND 

It is highly recommended not to run these kind of applications, however if you still want to run, run only if you understand risk and implications involved. 
As a workaround, the user can use Exception Site list feature to run the applications blocked by security settings. By adding the URL of the blocked application to the Exception Site list allows it to run with some warnings.

Steps to Add URL to the Exception Site list:


  • Go to the Java Control Panel (On Windows Click Start and then Configure Java)
  • Click on the Security tab
  • Click on the Edit Site List button
  • Click the Add in the Exception Site List window
    Add url to Exception Site list
  • Click in the empty field under Location field to enter the URL
    Example: http://www.example.com
    ( URL should begin with http:// or https://)

    If the URL where the applet is hosted is different than the URL for the page on which the applet is called you need to add both the URL for the applet.
    Example: For Yahoo games Checkers (This is just an example the host url can be different for depending on which host is serving the game), enter:
    1. http://www.games.yahoo.com and (This is the url for Yahoo games domain)
    2. http://yog36.games.sp2.yahoo.com (This is the url where game is the hosted and is shown in the dialog box for blocked application)
  • Click OK to save the URL that you entered.
  • Click Continue on the Security Warning dialog

Your security setting have blocked a self-signed application from running

ERROR: 'Your security settings have blocked an application from running with an insecure or expired jre.'
Description
Description
The following error occurs when using Webview in Internet Explorer because you have an out of date Java version and are trying to run unsigned or self-signed Java applications. You will see a windows error screen stating:
Application Blocked
Application blocked by Security Settings.
Your security settings have blocked an application from running with an insecure or expired jre.
Error Message
Resolution
  1. Simply update Java to the latest version and the application should run.
  2. If for some reason you can't update and absolutely need to run the application you can temporarily reduce the Java security level. This is not recommended, but if you fully trust all Java applications that you use on the system, lowering the security level will allow the application to run
  • Open Control Panel > Java
  • Switch to Security tab
  • Reduce Security Level from High to Medium

Wednesday, January 22, 2014

Install PostgreSQL 9.3 & psycopg2 on CentOS 6.4

Install yum in the PostgreSQL 9.3 on CentOS 6.4, is a Python binding psycopg2 note of procedures for installing the pip.

Installation of PostgreSQL

I use the RPM that the developer of PostgreSQL provides

Configure your YUM repository

Modification of the YUM repository
I will be out of the jurisdiction from PostgreSQL YUM repository of default
/etc/yum.repos.d/CentOS-Base.repo Add the following to the section of the [updates] and [base]
exclude=postgresql*

Install PostgreSQL Global Development Group of (PGDG)

By installing the PGDG, RPM packages of the following are available for installation
  • postgresql-libs:. The postgresql-libs package provides the essential shared libraries for any PostgreSQL client program or interface You will need to install this package to use any other PostgreSQL package or any clients that need to connect to a PostgreSQL server.
  • postgresql:. ​​If you want to manipulate a PostgreSQL database on a local or remote PostgreSQL server, you need this package You also need to install this package if you're installing the postgresql-server package.
  • postgresql-contrib: The postgresql-contrib package contains contributed packages that are included in the PostgreSQL distribution.
  • postgresql-devel:. The postgresql-devel package contains the header files and libraries needed to compile C or C + + applications which will directly interact with a PostgreSQL database management server and the ecpg Embedded C Postgres preprocessor You need to install this package if you want to develop applications which will interact with a PostgreSQL server.
  • postgresql-docs:. The postgresql-docs package includes the SGML source for the documentation as well as the documentation in PDF format and some extra documentation Install this package if you want to help with the PostgreSQL documentation project, or if you want to generate printed documentation.
  • postgresql-server:. The postgresql-server package includes the programs needed to create and run a PostgreSQL server, which will in turn allow you to create and maintain PostgreSQL databases You should install postgresql-server if you want to create and maintain your own PostgreSQL databases and / or your own PostgreSQL server. You also need to install the postgresql package and its requirements.
  • postgresql-tcl: The postgresql-tcl package contains the Pgtcl client library and its documentation.
  • postgresql-jdbc:. The postgresql-jdbc package includes the jar files needed for Java programs to access a PostgreSQL database.
  • postgresql-pl:. The postgresql-pl package contains the the PL / Perl, and PL / Python procedural languages ​​for the backend PL / Pgsql is part of the core server package.
  • postgresql-python: The postgresql-python package includes a module for developers to use when writing Python code for accessing a PostgreSQL database.
  • postgresql-test: The postgresql-test package includes the sources and pre-built binaries of various tests for the PostgreSQL database management system, including regression tests and benchmarks.
PGDG are present in the version / distribution / architecture each of PostgreSQL, this is to download and install what they want from the following pages.
The following assumed that you are installing on x86_64 of the 6 CentOS PostgreSQL9.3.
$ curl -O http://yum.postgresql.org/9.3/redhat/rhel-6.4-x86_64/pgdg-centos93-9.3-1.noarch.rpm
$ sudo rpm -ivh pgdg-centos93-9.3-1.noarch.rpm
warning: pgdg-centos93-9.3-1.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Preparing...                ########################################### [100%]
   1:pgdg-centos93          ########################################### [100%]

$ yum list postgres*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
base                                                                                                                       | 3.7 kB     00:00
extras                                                                                                                     | 3.4 kB     00:00
pgdg93                                                                                                                     | 2.8 kB     00:00
pgdg93/primary_db                                                                                                          |  61 kB     00:00
updates                                                                                                                    | 3.4 kB     00:00
Available Packages
postgresql93.x86_64                                                         9.3.0-1PGDG.rhel6                                               pgdg93
postgresql93-contrib.x86_64                                                 9.3.0-1PGDG.rhel6                                               pgdg93
postgresql93-debuginfo.x86_64                                               9.3.0-1PGDG.rhel6                                               pgdg93
postgresql93-devel.x86_64                                                   9.3.0-1PGDG.rhel6                                               pgdg93
postgresql93-docs.x86_64                                                    9.3.0-1PGDG.rhel6                                               pgdg93
postgresql93-libs.x86_64                                                    9.3.0-1PGDG.rhel6                                               pgdg93
postgresql93-plperl.x86_64                                                  9.3.0-1PGDG.rhel6                                               pgdg93
postgresql93-plpython.x86_64                                                9.3.0-1PGDG.rhel6                                               pgdg93
postgresql93-pltcl.x86_64                                                   9.3.0-1PGDG.rhel6                                               pgdg93
postgresql93-server.x86_64                                                  9.3.0-1PGDG.rhel6                                               pgdg93
postgresql93-test.x86_64                                                    9.3.0-1PGDG.rhel6                                               pgdg93
postgresql_autodoc.noarch                                                   1.41-1.rhel6                                                    pgdg93

$ sudo yum install postgresql93 postgresql93-contrib postgresql93-devel postgresql93-libs postgresql93-server
Program /usr/pgsql-9.3/bin/ is installed below. The PGDATA is /var/lib/pgsql/9.3/data is set to.

Launch configuration

To auto-start chkconfig Set
$ sudo /sbin/chkconfig --list postgresql-9.3
postgresql-9.3  0:off   1:off   2:off   3:off   4:off   5:off   6:off
$ sudo /sbin/chkconfig postgresql-9.3 on
$ sudo /sbin/chkconfig --list postgresql-9.3
postgresql-9.3  0:off   1:off   2:on    3:on    4:on    5:on    6:off

$ sudo service postgresql-9.3 initdb
Initializing database:                                     [  OK  ]
$ sudo service postgresql-9.3 start
Starting postgresql-9.3 service:                           [  OK  ]
(You can create a user After $ createuser --interactive -W ), pg_hba.conf You can play around with the file.

Installation of psycopg2

Is a Python bindings for PostgreSQL psycopg2 the pip install.
First installation of pip
$ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | sudo python
$ sudo easy_install pip
psycopg2 is extensible module and C, I put the development package of Python
$ sudo yum install python-devel
The build of psycopg2 pg_config it is necessary to execute the command.
/usr/pgsql-9.3/bin because it is installed in the path of irregular, environment variable PATH to adjust.
sudo When used in a environment variable for security PATH for is not taken over , run to become root.
$ sudo su
# export PATH=/usr/pgsql-9.3/bin:$PATH
#  pip install psycopg2
...
Successfully installed psycopg2
Cleaning up...

About pg_config package

pg_config package postgresql93-devel is installed in. pg_config If you can not be found, an error message similar to the following is displayed.
Error: pg_config executable not found.

Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:

    python setup.py build_ext --pg-config /path/to/pg_config build ...

or with the pg_config option in 'setup.cfg'.

References

How To Install Tomcat 7 Server on CentOS & RedHat 5/6

Apache Tomcat is an opensource webserver product of Apache Foundation like Apache HTTP server. It is used to deploying Java Servlet and JSP applications. To deploy any application in Tomcat we can simply create a war file and deploy them. For more details about you can visit apache official sitehttp://tomcat.apache.org/ .
This article will help you to install Apache tomcat on CentOS/RHEL servers. We are using CentOS 6.3 andinstalling Apache tomcat 7.
Step 1: Check JAVA
JAVA is the first requirement of tomcat installation. Use following command to check if you have javainstalled already on your system.
# java -version
If you do not have java installed, Use this guide to install Java.
Step 2: Download and Extract Tomcat Archive
Download Apache tomcat archive file from Apache tomcat official site using below download url
Download URL: http://tomcat.apache.org/download-70.cgi
# cd /opt
# wget ftp://apache.mirrors.pair.com/tomcat/tomcat-7/v7.0.42/bin/apache-tomcat-7.0.42.tar.gz
After competed download extract archive file in /opt directory. You may change this location as per your setup.
# tar xzf apache-tomcat-7.0.42.tar.gz
Step 3: Start Tomcat Service
Tomcat is very easy to use, There are no need to compile its source. You simple extract the archive and start the tomcat server. Tomcat by default start on port 8080, So make sure no other application using the same port.
# cd apache-tomcat-7.0.42
# ./bin/startup.sh
[Sample Output]
Using CATALINA_BASE:   /opt/apache-tomcat-7.0.42
Using CATALINA_HOME:   /opt/apache-tomcat-7.0.42
Using CATALINA_TMPDIR: /opt/apache-tomcat-7.0.42/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /opt/apache-tomcat-7.0.42/bin/bootstrap.jar:/opt/apache-tomcat-7.0.42/bin/tomcat-juli.jar
Step 4: Access Tomcat in Browser
Tomcat server works on port 8080 default. Access tomcat on web browser by connecting your server on port 8080.
http://svr2.tecadmin.net:8080  
install Tomcat
Step 5: Setup User Accounts
Finally we need to create user accounts to secure and access admin/manager pages. Edit conf/tomcat-users.xml file in your editor and paste inside <tomcat-users> </tomcat-users> tags.
# user manager can access only manager section.
<role rolename="manager-gui" />
<user username="manager" password="_SECRET_PASSWORD_" roles="manager-gui" />

# user admin can access manager and admin section both.
<role rolename="admin-gui" />
<user username="admin" password="_SECRET_PASSWORD_" roles="manager-gui,admin-gui" />
I hope above steps will help you to setup tomcat on your server.
Thanks

Thursday, January 16, 2014

Java: Application blocked by Security Setting

Ok, so the application we are running if we stay running @ an older version it is working now b/c I completely uninstalled and then reinstall and rebooted so I'm good, thank you!

Tuesday, January 14, 2014

Replication recovery after a prolonged shutdown slave Posgtgresql

t is possible that the slave will not receive data from the master after a prolonged shutdown of the slave 
Slave will return errors: 
  1. 2011-04-15 15:22:49 UTC FATAL: could not receive data from WAL stream: FATAL: requested WAL segment 0000000100000002000000C5 has already been removed

This is due to the fact that the master file is already fully recorded 0000000100000002000000C5 and moved it from the folder / var/lib/postgresql/9.0/main/pg_xlog in folder / var/lib/postgresql/9.0/main/archive. 

Required Actions: 

master 
  1. sudo-u postgres psql-c "SELECT pg_start_backup ('label', true)"
  2. cd / var/lib/postgresql/9.0/main
  3. tar cvzf ~ / archive.tgz archive
  4. sudo-u postgres psql-c "SELECT pg_stop_backup ()"
  5. scp-P 1022-r ~ / archive.tgz * @ *
  6. sudo-u postgres psql-c "SELECT pg_current_xlog_location ()"

slave 
  1. / Etc / init.d / postgresql stop
  2. tar xvzf ~ / archive.tgz-C / var/lib/postgresql/9.0/main
  3. chown-R postgres: postgres / var/lib/postgresql/9.0/main/archive
  4. / Etc / init.d / postgresql start
  5. sudo-u postgres psql-c "SELECT pg_last_xlog_replay_location ()"

Friday, January 10, 2014

Postgres.app FATAL: sorry, too many clients already

Basically, you have to modify
/Users/XXXX/Library/Application Support/Postgres/var/postgresql.conf
Change the following lines:
max_connections = 50
and

shared_buffers = 300kB

Thursday, January 9, 2014

Database ACID (Atomicity, Consistency, Isolation, Durability) Properties

There are a set of properties that guarantee that database transactions are processed reliably, referred to as ACID (Atomicity, Consistency, Isolation, Durability).

Atomicity

Atomicity refers to the ability of the database to guarantee that either all of the tasks of a transaction are performed or none of them are. Database modifications must follow an all or nothing rule. Each transaction is said to be atomic if when one part of the transaction fails, the entire transaction fails.

Consistency

The consistency property ensures that the database remains in a consistent state before the start of the transaction and after the transaction is over (whether successful or not). For example, in a storefront there is an inconsistent view of what is truly available for purchase if inventory is allowed to fall below 0, making it impossible to provide more than an intent to complete a transaction at checkout time. An example in a double-entry accounting system illustrates the concept of a true transaction. Every debit requires an associated credit. Both of these happen or neither happen.
A distributed data system is either strongly consistent or has some form of weak consistency. Once again, using the storefront example, a database needs to provide consistency and isolation, so that when one customer is reducing an item in stock and in parallel is increasing the basket by one, this is isolated from another customer who will have to wait while the data store catches up. At the other end of the spectrum is BASE (Basically Available Soft-state Eventual consistency).
Weak consistency is sometimes referred to as eventual consistency, the database eventually reaches a consistent state. Weak consistency systems are usually ones where data is replicated; the latest version is sitting somewhere in the cluster, older versions are still out there. Eventually all nodes will see the latest version.

Isolation

Isolation refers to the requirement that other operations cannot access or see the data in an intermediate state during a transaction. This constraint is required to maintain the performance as well as the consistency between transactions in a database. Thus, each transaction is unaware of another transactions executing concurrently in the system.

Durability

Durability refers to the guarantee that once the user has been notified of success, the transaction will persist, and not be undone. This means it will survive system failure, and that the database system has checked the integrity constraints and won't need to abort the transaction. Many databases implement durability by writing all transactions into a transaction log that can be played back to recreate the system state right before a failure. A transaction can only be deemed committed after it is safely in the log.
Durability does not imply a permanent state of the database. Another transaction may overwrite any changes made by the current transaction without hindering durability.

Thursday, January 2, 2014

PostgreSQL – ERROR: operator does not exist: smallint = character varying (Solution)

Today i hit a weird error, actually my company is plan to migrate existing j2ee web application from PostgreSQL 8.2 to latest PostgreSQL 9.3. But after i set up PostgreSQL 9.3 properly, and start web application, i keep hiting following error

org.postgresql.util.PSQLException: ERROR: operator does not exist: smallint = character varying

It’s seem like data type mismatch error, funny is it working fine at 
PostgreSQL 8.2 but PostgreSQL 8.3? I googling few hours and find out, 
it’s probably has to do with the changes to implicit casting done in 
8.3. It’s seem like PostgreSQL 8.3 put a lot effort to enchance and 
check data type.
This will delibrate a lot side effect, because we set string in valuelist to compare any coloums, and let PostgreSQL to do the casting automatically. This is no longer support in PostgreSQL 8.3 (i guess). Here i provide two solution to solve above error.
Solution ————— 1) use setInt or setLong to cast to the appropriate data type before send statement to PostgreSQL
2) use explicit casting like ::smallint
for example
SELECT * FROM score WHERE scordid =?::SMALLINT

If you are using valuelist like me, you need to wrap statementBuilder to
 override StandardStatamentBuilder to your appropriate data type.

 <property name="statementBuilder">
     <bean id="xx" class="net.mlw.vlh.adapter.jdbc.util.StandardStatementBuilder">
 <property name="setters">
   <map>
   <entry key="sourceId">
    <ref local="intSetter"/>
   </entry>
 
  </map>
 </property>
     </bean>
  </property>