Monday, December 26, 2011

Error in JSP Tomcat 6, Java 6 javax.servlet.ServletException: java.lang.NoSuchFieldError: IS_SECURITY_ENABLED

javax.servlet.ServletException: java.lang.NoSuchFieldError: IS_SECURITY_ENABLED
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:275)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

java.lang.NoSuchFieldError: IS_SECURITY_ENABLED
org.apache.naming.resources.DirContextURLConnection.(DirContextURLConnection.java:67)
org.apache.naming.resources.DirContextURLStreamHandler.openConnection(DirContextURLStreamHandler.java:89)
java.net.URL.openConnection(URL.java:945)
org.apache.jasper.compiler.Compiler.isOutDated(Compiler.java:387)
org.apache.jasper.compiler.Compiler.isOutDated(Compiler.java:351)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:582)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


I am still looking for a Solution for the same, I will update once i have the solution..

Solution in My Scenario:
For me it is the issue with the JAR Conflicts. I was having naming-factory.jar in Tomcat/Lib was conflicting with some other JAR's.I Just removed it and the issue got resolved.

I am not sure in every case the same JAR, But it is always the JAR Conflict.


Thursday, August 11, 2011

How to enable JBoss access on network

While Starting the server use the following.
E:\Research\Softwares\jboss-5.1.0.GA\bin>run.bat -b 0.0.0.0

Saturday, August 6, 2011

Make Cheapest Data Card in India 2.5GB @ IRS 65 with Speed for Voice Chat.

We know we all are behind finding different ways of getting online always, or keep tweeting through mobiles, or you can simply say youth are Psycho/mad with simply checking the mails/Facebook updates, even they are aware that nothing important going to happen on facebook/GMails :).
Lets Discuss different ways of getting online in the Mobile word, Being the Android No.1 in Market, Now every one have a smart phone, I should say every student have it :), [They are the most, guys behind the Gadgets :) ]  . But here I am focussing on some kind of Programmers/Software Engineers they need Internet always, as earlier said to check mails and checking for Technology updates. Here the Mobile-Internet will not be a right option, I can make use of it, but the GPRS will be very slow and pathetic. Options are there with 3G and EDGE, But if i dont want to spent hundreds on Portable device with Internet connection, and I need pretty good speed for voice chat and Internet browsing, (I think we should not expect Video conference on these, Am I Right :)).Here we have different Data Cards Available in Indian Market. Now almost every telephone Companies provides the Data cards. Such as BSNL, Reliance, MTS , TATA Photon. Every one provides 3G Service too.   But the cost of very less speed internet data card cost 1500-1700 initial cost and 40-500 per month for 500MB to 2 GB Data, isnt costing very high on this Internet world.On discussion with other friends abroad, i came to know the 3G Modem, which is available in Indian Market too, But India have it , but integrated with any mobile operators SIM Card/ Data Card.Now lets come to the point, I did some adjustment with one Internet 3G Modem, I am able to browse on a wonderful speed provides better clarity on Voice chatting.How to make a Data Card costing IRS 50-60 and having Browsing limit to 2-3GB per month [Monthly Expense for Portable Device is IRS:50-65], is it Interesting to you.How I achieved it is I got a 3G Modem from one of My friend, I bought one TATA DOCOMO SIM Card for RS 70 (A good talk time with it.), Re Charged with IRS:65 for 2.5 GB GPRS.If you want to buy 3G Modem, it cost 900-1200 in Indian Market, you can get it in 
  1. Bangalore - SP Road, the best place to get electronic items very cheap.
  2. New Delhi - Nehru Place, The biggest Computer Market in India.
This device will have the default application inside to support Windows Operating System. Just you plug and start browsing by putting the SIM Card inside.

The settings can be done as follows.
Step 1The application GUI will looks same as this, may be different in colours, Because i saw in Idea Data Card, which have the same GUI with IDEA Yellow colour instead of this light blue screen :) :Step 2: Open the Tools--> Options, here you will get the following screen. Do the settings as given in image.Step 3:In the Text Message Screen you dont need to do any Changes, let it got with default settings.Step 4:In the Screen of Profile Management we have the settings for the GPRS/Internet. You can get these settings from customer cares as well.Step 5: The Network settings to be done as given in Image "Screen Networ 1" and "Screen Networ 2"

Screen Netwrok 1


Screen Network 2.


By Clicking New you can create a new Profile i created with Name "Docomo".Set the APN as static. and the APN for DOCOMO is "TATA.DOCOMO.INTERNET".Keep the username and password Blank. But the Access Number is *99# I think this is the number for all the providers.Once you are done with this click ok,Now you can see the profile in the Main Screen (As in Step 1.). Click on Connect. Now your system is in Internet, If you are facing any issues on connecting. Talk to customer Care and get the APN i mentioned and the Access Point Number (*99#) .Thank you Guys, Enjoy the Cheapest Data Card.Forgot to upload the Internet speed Graph I was getting.

Monday, August 1, 2011

How to lock Windows using Java Program

package com;

import java.io.IOException;

public class LockMachine {
 public static void main(String[] args) {
  String WINDOWS_LOCK_COMMAND="rundll32.exe user32.dll, LockWorkStation";
  Runtime rt = Runtime.getRuntime();

  try {
   rt.exec(WINDOWS_LOCK_COMMAND);

  } catch (IOException e1) {
   e1.printStackTrace();
  }
 }
}



Thursday, April 14, 2011

HR Session on Salary Restructure

Salary Restructure means confusing Employees, Only one question left with me
"Abey saala mujko kya deraha hai ?"

Friday, March 25, 2011

Insert LONGTEXT in Database using Hibernate

I would like to share my experience while inserting a Big XML file to the Database, The column dataType is LONGTEXT. The XML File sine is about 1.2MB, when i tried to insert in database using the following Hibernate Code i got the Exception as follows.
Code

Transaction transaction =  sessionFactory.getCurrentSession().beginTransaction();
transaction.begin();
sessionFactory.getCurrentSession().persist(xmlData);
transaction.commit();


Where xmlData is as follows

public class XMLData {
 private int id;
 private String xml;

 public int getId() {
  return id;
 }

 public void setId(int id) {
  this.id = id;
 }

 public String getXml() {
  return xml;
 }

 public void setXml(String xml) {
  this.xml = xml;
 }
}
I got the following Exception.

Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not insert: [org.cgi.model.Server]
 at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
 at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
 at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
 at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:40)
 at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2093)
 at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2573)
 at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:47)
 at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
 at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:290)
 at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:180)
 at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:108)
 at org.hibernate.event.def.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:131)
 at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:87)
 at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:38)
 at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:618)
 at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:592)
 at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:596)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
 at $Proxy0.persist(Unknown Source)
 at org.cgi.dao.manager.ServerDAO.persist(ServerDAO.java:44)
 at org.cgi.dao.manager.test.TestManager.main(TestManager.java:23)
Caused by: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1094608 > 177152). You can change this value on the server by setting the max_allowed_packet' variable.
 at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3285)
 at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1970)
 at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2150)
 at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2626)
 at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
 at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2415)
 at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2333)
 at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2318)
 at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:73)
 at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33)
 ... 21 more

Solution:
As it is mentioned in the Exception we need to increase the max_allowed_packet variable of MySQL server.
By Default MySQL provides the size of 1 MB. you can read the value by the following Command in MySQL Command Prompt.

show variables like '%max_allowed_packet';
Now you can Set the Value by using the following Command.
set global max_allowed_packet=16777216;

For Reference
The maximum allowed packet size is 1GB.



Monday, March 7, 2011

Create Executable JAR File Using Eclipse

We all are aware of the main part of an Executable JAR file is keeping the MANIFEST.MF in META-INF Folder. Also inside the MANIFEST.MF we need to provide the following Details.

Manifest-Version: 1.0
  Main-Class: com.example.Example
  Class-Path: dependent.jar
Classpath will be required in case you have more dependent jars are there, also we create the Same jar using the JAR Command provided by Java as follows.
jar cvfm myFile.jar myManifestFile *.class
I found that some of the executable jars will through ClassNotFound Exception.
Hence i recommend to follow the Eclipse Jar Export Option.

The test Project i am going through have a Sample Java file to open a Window using the Java Swing.
Once I execute the project the Output is as Follows.
Now lets Create the JAR to run the Application.
Step 1: Right Click on the Project and Select Export.
Step 2: Select teh Export Destination as Runnable JAR File, and click Next.
Step 3: Select the Class with main method, which need to be executed initially and teh Destination Folder where the Jar need to be saved. Here i selected "C:\test.jar"
Step 4: Click Finish, Now your Executable Jar is ready @ C:\test.jar.
Hope you enjoyed the work through.

Wednesday, January 19, 2011

Best Tutorial for SVN Installation on Windows

http://www.codinghorror.com/blog/2008/04/setting-up-subversion-on-windows.html

This is the best Tutorial I found on the Net For Installing SVN on Windows.
The following Link help you to Download SVN svn-1.4.6-setup.

Once you have Installed in Program files it provides the Tutorials, Which resolves most of u r concerns.

How to Configure SVN Server as a Windows Service: Best Article

    Configuring svnserve to Run as a Windows Service


http://svn.spears.at/ : The complete Tutorials.

Thursday, January 6, 2011

Conversion between Array and java.util.List

While dealing with Autogenerated Classes Like JAXB or any other framework we need to convert from Array to List or vice versa..

Object[] --> java.util.List
or
java.util.List --> Object[].

Array to List
    public static void main(String[] args) {
           String[] names= {"Name 1","Name 3","Name 4"};
           List nameList=Arrays.asList(names);
           System.out.println("List Size is :"+nameList.size());
           System.out.println("Names are :"+nameList);
    }
It will give the Output as
   List Size is :3
   Names are :[Name 1, Name 3, Name 4]

We know how to insert the data in some position in List, But the insertion will not be allowed in the List provided by Arrays.asList,

It throws the following Exception when we do
   nameList.add(2,"Name 2");
   or 
   nameList.add("Name 2");

   Exception in thread "main" java.lang.UnsupportedOperationException
           at java.util.AbstractList.add(AbstractList.java:151)
           at java.util.AbstractList.add(AbstractList.java:89)
           at org.work.corejava.collection.ArrayToList.main(ArrayToList.java:12)
Reason: Reference
Arrays.asList Returns a fixed-size list backed by the specified array. (Changes to the returned list "write through" to the array.) This method acts as bridge between array-based and collection-based APIs, in combination with Collection.toArray.

But as the array supported
    names[1] ="Name 2";
    The same functionality will be supported by List also , as follows.
    nameList.set(1,"Name 2");
List to Array

List to Array can be done using the following Code.
String[] namesArray = nameList.toArray(new String[0]);
      in JDK 1.4 we need to do teh following type casting.
      String[] namesArray = (String[])nameList.toArray(new String[0]);

Monday, January 3, 2011

How you can stop Rumors, a Simple way is here....

Here is something which I thought is an Excellent Stuff to share...



QUOTE

In India around 350 BC in Magadh, Chanakya was widely lauded for his wisdom.

One day an acquaintance ran up to him excitedly and said, "Chanakya ji, do you know what I just heard about Pandit Haridas?"

"Wait a moment," Chanakya replied, "Before you tell me I'd like you to pass a little test. It's called the Triple Filter Test."

'Triple filter?" asked the acquaintance.

"That's right," Chanakya continued, "Before you talk to me about Pandit Haridas, let's take a moment to filter what you're going to say. The first filter is Truth. Have you made absolutely sure that what you are about to tell me is true?"

"No," the man said, "Actually I just heard about it."

"All right," said Chanakya, "So you don't really know if it's true or not. Now let's try the second filter, the filter of Goodness. Is what you are about to tell me about Pandit Haridas something good?"

"No, on the contrary..."

"So," Chanakya continued, "You want to tell me something about Pandit Haridas that may be bad, even though you're not certain it's true?"

The man shrugged, a little embarrassed. Chanakya continued, "You may still pass the test though, because there is a third filter, the filter of Usefulness. Is what you want to tell me about Pandit Haridas going to be useful to me?"

"No, not really."

"Well," concluded Chanakya, "If what you want to tell me is neither True nor Good nor even useful, why tell it to me or anyone at all?"

The man was bewildered and ashamed. This is an example of why Chanakya was a great politician and held in such high esteem.