Wednesday, September 17, 2014

How to Resolve java.lang.NegativeArraySizeException in Spring


When will you get this Exception?

I was getting this exception when I start my spring application. I was searching the web for any better solution but nothing worked out.
Later I was able to remember the mistake which I have done.

What mistake I have done?
I have defined a property in my class and defined the same in the bean definition file as well. I have copy pasted my bean file into the tomcat.
Later I have removed my property from the java class file and I have not removed the property entries from the bean definition XML file.

What is the reason for the error?
We will get this exception when we have defined a property for a Class later which we have removed those properties from the class.

Solution
Remove the unwanted property definition from the bean definition file and redeploy bean definition XML files.

Friday, September 12, 2014

How to Resolve java.net.BindException: Address already in use: JVM_Bind

I have encountered this issue when I was starting my tomcat.

Actual Exception Trace:

SEVERE: StandardServer.await: create[8005]:
java.net.BindException: Address already in use: JVM_Bind
at java.net.DualStackPlainSocketImpl.bind0(Native Method)
at java.net.DualStackPlainSocketImpl.socketBind(Unknown Source)

Reason:

The port 8005 is already binding by some other application and that is why we are not able to use it.

Solution:

Change the port number 8005 in tomcat server's server.xml file as below:
<Server port="8005" shutdown="SHUTDOWN"> into <Server port="8006" shutdown="SHUTDOWN">

Monday, September 8, 2014

How to unlock table in SQL

INTRODUCTION

Sometimes when multiple users perform operations like update/delete on a table, there is a chance for a table lock.

ISSUE

SQL table is locked.

SOLUTION

To unlock all the locked tables, need to login as an ADMIN user.

Step 1

Check if the Package or table are locked using the below query

SELECT b.object_name, a.session_id, a.oracle_username, a.os_user_name, a.process, a.locked_mode
FROM v$locked_object a, all_objects b
WHERE a.object_id = b.object_id;

Step 2

Get the serial number for the session based on the session id got from above query.
SELECT SID, serial#, ownerid, status, server, username, osuser, process, machine
FROM v$session
WHERE SID = 'Session id from above query';

Step 3

Kill the session below command.
ALTER SYSTEM KILL SESSION 'Sid from query, Serial# from Query 2';
Example:
1) SELECT SID, serial# FROM v$session WHERE SID in (select session_id from v$locked_object);
2) ALTER SYSTEM KILL SESSION '8,19087';

ALTERNATE SOLUTION

We can also unlock the table by below approach
select a.session_id,a.oracle_username, a.os_user_name, b.owner "OBJECT OWNER", b.object_name,b.object_type,a.locked_mode from
(select object_id, SESSION_ID, ORACLE_USERNAME, OS_USER_NAME, LOCKED_MODE from v$locked_object) a,
(select object_id, owner, object_name,object_type from dba_objects) b
where a.object_id=b.object_id;

--To check
SELECT object_id FROM dba_objects WHERE object_name=’MYOBJECT';
SELECT sid FROM v$lock WHERE id1=360254;
ALTER SYSTEM KILL SESSION '3434,92193' ;

Saturday, September 6, 2014

How to Configure Multiple Tomcat Server in Same Machine

INTRODUCTION

This post will help to us to configure multiple tomcat server into the same machine/server.

Sometimes there is a need for setting up multiple tomcat to debug the application.

I came across this situation I wanted to debug two different version of my application at same time and check the value for an object.

Following are the steps to achieve it.

Step 1

Install tomcat with two different names as below
  1. C:\Tomcat6.0-1 (with http port 8080)
  2. C:\Tomcat6.0-2 (with http port 8090)

Step 2

Open the C:\Tomcat 6.0-2\conf\server.xml and modify the below lines.
  1. Change  port="8006" on <Server port="8005" shutdown="SHUTDOWN">
  2. Change  port="8010" on <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

Step 3

Don't do any change on C:\Tomcat6.0-1. By default settings can be used.
  <Server port="8005" shutdown="SHUTDOWN">
  <Connector port="8080" protocol="HTTP/1.1" >
  <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

Now you can able to connect the application as below.
Now Tomcat-1 can be connected using URL: http://localhost:8080/<your-application>
and Tomcat-2 can be connected using URL: http://localhost:8090/<your-application>

Friday, September 5, 2014

[SOLVED] java.sql.SQLException: ORA-01658: unable to create INITIAL extent for segment in tablespace


ISSUE

ORA-01658: unable to create INITIAL extent for segment in tablespace USER_DATA

REASON

If there is no enough space in the tablespace (e.g: USER_DATA), it will throw this error.

SOLUTION

We are trying to extend the space using 'autoextend' instead of setting fixed size. Login as sys_dba user and follow the below steps.

STEP 1

Find the list of tablespaces already available by below query.
select 'alter database datafile '|| file_name|| ' '|| ' autoextend on maxsize unlimited;' from dba_data_files;

You will get the below results:
alter database datafile C:\ORACLEXE\APP\ORACLE\PRODUCT\11.2.0\SERVER\DATABASE\LOB_DATA  autoextend on maxsize unlimited;

alter database datafile C:\ORACLEXE\APP\ORACLE\PRODUCT\11.2.0\SERVER\DATABASE\USER_DATA  autoextend on maxsize unlimited;

alter database datafile C:\ORACLEXE\APP\ORACLE\PRODUCT\11.2.0\SERVER\DATABASE\INDEX_DATA  autoextend on maxsize unlimited;

STEP 2

Run the below query which will set the tablespace to autoextend whenever the actual space is filled.
alter database datafile 'C:\ORACLEXE\APP\ORACLE\PRODUCT\11.2.0\SERVER\DATABASE\LOB_DATA'  autoextend on maxsize unlimited;

alter database datafile 'C:\ORACLEXE\APP\ORACLE\PRODUCT\11.2.0\SERVER\DATABASE\USER_DATA'  autoextend on maxsize unlimited;

alter database datafile 'C:\ORACLEXE\APP\ORACLE\PRODUCT\11.2.0\SERVER\DATABASE\INDEX_DATA'  autoextend on maxsize unlimited;