Friday, February 14, 2014

Failure in loading native library db2jcct2, java.lang.UnsatisfiedLinkError: no db2jcct2 in java.library.path: ERRORCODE=-4472, SQLSTATE=null

com.ibm.db2.jcc.a.SqlException: [jcc][10389][12245][4.3.111] Failure in loading native library db2jcct2, java.lang.UnsatisfiedLinkError: no db2jcct2 in java.library.path:  ERRORCODE=-4472, SQLSTATE=null
at com.ibm.db2.jcc.a.dd.a(dd.java:660)
at com.ibm.db2.jcc.a.dd.a(dd.java:60)
at com.ibm.db2.jcc.a.dd.a(dd.java:94)
at com.ibm.db2.jcc.t2.a.a(a.java:37)
at com.ibm.db2.jcc.t2.T2Configuration.(T2Configuration.java:94)
at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:188)
at org.apache.tomcat.dbcp.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
at org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:524)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:588)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:617)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:625)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:657)
at com.hewitt.hro.ssb.dao.jdbc.JdbcBuildTypeDao.getBuildType(JdbcBuildTypeDao.java:100)
at com.hewitt.hro.ssb.dao.jdbc.JdbcBuildTypeDao.getBuildTypeWithArguments(JdbcBuildTypeDao.java:110)
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.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:299)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:139)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy4.getBuildTypeWithArguments(Unknown Source)
at com.hewitt.hro.ssb.admin.LinkedBuildTypeLocator.init(LinkedBuildTypeLocator.java:136)
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.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1185)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1147)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1110)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:431)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:254)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:144)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:251)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:271)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:128)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1047)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:843)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:254)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:144)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:251)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)
at org.directwebremoting.spring.SpringContainer.getBean(SpringContainer.java:105)
at org.directwebremoting.impl.ContainerMap.init(ContainerMap.java:53)
at org.directwebremoting.impl.ContainerMap.entrySet(ContainerMap.java:78)
at org.directwebremoting.spring.DwrController.afterPropertiesSet(DwrController.java:198)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1143)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1110)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:431)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:254)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:144)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:251)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:683)
at org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:248)
at org.springframework.web.servlet.handler.SimpleUrlHandlerMapping.registerHandlers(SimpleUrlHandlerMapping.java:125)
at org.springframework.web.servlet.handler.SimpleUrlHandlerMapping.initApplicationContext(SimpleUrlHandlerMapping.java:103)
at org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:73)
at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:86)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:304)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:431)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:254)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:144)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:251)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:284)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:311)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:258)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:229)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:115)
at javax.servlet.GenericServlet.init(GenericServlet.java:160)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1189)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1103)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1010)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4915)
at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5242)
at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5237)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)

If you get the above error try adding DB2 bin folder in the library path as shown in the below figure

Example - C:\Program Files (x86)\IBM\SQLLIB_01\BIN 

MyEclipse Servers -< (server) -> Configure Server Connector -> (Preferences pop up) -> MyEclipse -> Servers -> Tomcat -> Tomcat 7.x -> Paths -> Add DIR


Add the BIN directory and Click Apply/OK


nested exception is org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.ibm.db2.jcc.DB2Driver'

SEVERE: StandardWrapper.Throwable
Invocation of init method failed; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.ibm.db2.jcc.DB2Driver'
Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.ibm.db2.jcc.DB2Driver'
Caused by: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.ibm.db2.jcc.DB2Driver'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1429)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:329)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:405)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:413)
at org.springframework.jdbc.core.simple.SimpleJdbcTemplate.query(SimpleJdbcTemplate.java:107)
at com.hewitt.hro.dcd.modb.dao.jdbc.JdbcUserDao.preloadCache(Unknown Source)
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)

To get rid of above error you may need to add db2jcc4.jar or db2jcc.jar  in your applications classpath. To download Jar files : Click here.

Tuesday, February 11, 2014

Handling Suspicious Email Messages

There has been significant increase in the circulation of spam and malicious emails in the recent past. In this article we will discuss how to handel suspicious email messages. It is very important for you to identify the spam and take steps to safeguard yourself against potential threats.


How to identify spam without opening the message?

A malicious email can infect your system immediately. Downloading a file from a suspicious email is enough to infect your system, including a PDF. Do not open suspicious or unsolicited emails.

It is recommended :


  • Do not open suspicious emails
  • Try to identify a message as spam by looking at the 'From' field and the 'Subject' line. If the sender and the domain (@company.com) does not relate to the subject, the message is probably spam
  • Never trust emails that are trying to sell you something or unknown clients. Ask yourself, does the sender identify you by your name? If the answer is no, the message is spam. 


You can identify spam emails by looking at the 'From' field, if :


  • You get any email with your name in as the sender (which you may not have sent) 
  • The 'From' field is blank or generic (example: friend, try this, etc.)
  • The mail has strange name or all numbers – 9222594_1970@tst-inc.com 
  • Has scrambled, random-appearing addresses – X12YT853@yahoo.com 
  • Is from someone you do not recognize or from a domains like yahoo.com, gmail.com, msn.com, hotmail.com. Attackers use these domains to send spam 
  • If the message is from another country, especially, if you do not work regularly with them (Example - m5wangzhi@wahaha.com.cn – here CN means the domain is China) 


You can identify spam emails by looking at the 'Subject' field, if :


  • The subject is unrelated to your work profile or domain (example: Do you want to get rich?) 
  • There are strange characters in the subject (example: best m0rtgage qu0te!s") 
  • There are obvious spelling errors (Example: buy yourself Bacheelor/MasteerMBA/Doctoraate dip1omas)
  • The subject is outrageous or doesn't make any sense (Example: BREAKING NEWS: Nuts! Jackson Backs Neutering Stray Politicians)
  • The subject appears to be an order of confirmation for something you did not order (Example: Your Tracking # 77328515")
  • Your email address is in the subject line, this is usually done to gain your interest to open the email
  • The subject line indicates an important notification ("Install update for Microsoft Outlook"), and the message appears to be from the vendor (for example, Microsoft). Remember, Patches can be installed by clicking on Start -> Control Panel -> Windows Update


Friday, February 7, 2014

Exception in thread "main" javax.xml.ws.WebServiceException

Exception in thread "main" javax.xml.ws.WebServiceException: Failed to access the WSDL at: http://localhost:8080/SOAPWebservice/HelloWorldPort?wsdl. It failed with: 
Connection refused: connect.
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:162)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:144)
at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:263)
at com.sun.xml.ws.client.WSServiceDelegate.(WSServiceDelegate.java:226)
at com.sun.xml.ws.client.WSServiceDelegate.(WSServiceDelegate.java:174)
at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:104)
at javax.xml.ws.Service.(Service.java:56)
at com.hewitt.ws.HelloWorldImplService.(HelloWorldImplService.java:55)
at com.hewitt.ws.TestClient.main(TestClient.java:7)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at java.net.Socket.connect(Socket.java:469)
at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
at sun.net.www.http.HttpClient.(HttpClient.java:233)
at sun.net.www.http.HttpClient.New(HttpClient.java:306)
at sun.net.www.http.HttpClient.New(HttpClient.java:323)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:852)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:793)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:718)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1041)
at java.net.URL.openStream(URL.java:1009)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.createReader(RuntimeWSDLParser.java:805)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.resolveWSDL(RuntimeWSDLParser.java:262)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:129)
... 7 more

If you get above error, please check if the wsdl url is working fine. Just hit the URL in a browser and see if you get response. If not check with your service provider.

Example -
http://localhost:8080/SOAPWebservice/HelloWorldPort?wsdl

javax.xml.bind.MarshalException

javax.xml.bind.MarshalException
 - with linked exception:
[com.sun.istack.SAXException2: unable to marshal type "com.javaxp.Employee" as an element because it is missing an @XmlRootElement annotation]
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:331)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:257)
at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:96)
at com.hewitt.ws.Test.marshalIt(Test.java:74)
at com.hewitt.ws.Test.displayEmpl(Test.java:58)
at com.hewitt.ws.Test.main(Test.java:28)
Caused by: com.sun.istack.SAXException2: unable to marshal type "com.hewitt.ws.Employee" as an element because it is missing an @XmlRootElement annotation
at com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:244)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:303)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:490)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:328)
... 5 more

The process of convesrting a Java object to XML is known as Marshalling.

If you get above error, check for annotation @XmlRootElement in the class for which you are trying to do Marshalling. To know more, please see the example - JAXB marshalling and unmarshalling Hello World Example

Example - 

@XmlRootElement
public class Employee {
...
}

Thursday, February 6, 2014

java.lang.NoClassDefFoundError: com/sun/istack/localization/Localizable

java.lang.NoClassDefFoundError: com/sun/istack/localization/Localizable
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1148)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1643)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1148)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1643)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.newInstance0(Class.java:326)
at java.lang.Class.newInstance(Class.java:308)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:119)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4618)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5184)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5179)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)


If you get above error, you may need to add jaxb-core.jar in your applications classpath. You can download the file (example - jaxws-ri-2.2.8.zip file) from https://jax-ws.java.net/

Friday, January 31, 2014

Implementation of Restful Webservice with image

In Java EE 6, JAX-RS provides the functionality for Representational State Transfer (RESTful) web services. REST is well suited for basic, ad hoc integration scenarios. RESTful web services, often better integrated with HTTP than SOAP-based services are, do not require XML messages or WSDL service–API definitions. Before proceeding please read this article, Developing RESTful Web Services with JAX-RS.

Also please have look at the tutorial about "JAXB marshalling and unmarshalling", as it would be helpful to understand Restful Webservice.

For running this example, below mentioned particulars are used.
  • Tomcat 7.0.11
  • JDK 1.5
  • MyEclipse 8.6.1
1. Create a new Web Service Project, File -> New -> Web Service Project


Wednesday, January 29, 2014

Java program to download file from url

Below is the java program to download a file from url.


Java code to send meeting request using iCal4j

iCalendar is a computer file format which allows Internet users to send meeting requests and tasks to other Internet users, via email, or sharing files with an extension of .ics. Recipients of the iCalendar data file (with supporting software, such as an email client or calendar application) can respond to the sender easily or counter propose another meeting date/time.

iCalendar is used and supported by a large number of products, including Google Calendar, Apple iCal,IBM Lotus Notes,Yahoo Calendar, Microsoft Outlook etc

iCal4j is an API which is used to modifying existing iCalendar data or creating new iCalendar data. To know more about iCal4j, click here.

About the example 

This example is straight forward, we will create a calendar (net.fortuna.ical4j.model.Calendar) object and add a Meeting event to it. You can set various properties to the event like subject, location, description etc. Obviously you can customize it according to your requirement. This example will generate a .ics file (TestCalendar.ics). You can send this generated file via email to interested parties. Please see the below self explanatory java program.

For running below example you will need to add below mentioned JAR files in your classpath.
  • ical4j-1.0.3.jar
  • backport-util-concurrent-3.1.jar
  • commons-logging-1.1.1.jar
  • commons-lang-2.6.jar
To download the above JAR file, click here.

Java program to send email with attachments

Note: To run below example u need to add JavaMail jar files in your classpath

Java program to read csv file

Below is the java program to read a csv file.

Lets assume we have a below csv file.

Country.csv

"Country","Capital","President"
"India","Delhi","Pranab Mukherjee"
"United Kingdom","London","David Cameron"
"China","Beijing","Hu Jintao"
"United States","Washington","Barack Obama"

CSVReader.java


Output

"Country" "Capital" "President"
"India" "Delhi" "Pranab Mukherjee"
"United Kingdom" "London" "David Cameron"
"China" "Beijing" "Hu Jintao"
"United States" "Washington" "Barack Obama" 

Tuesday, January 28, 2014

Java program to reverse a string using array


Output

Original string : Hello World

Reversed string : dlroW olleH

Java program to reverse a string without using string function

Below is the java program to reverse a string using recursive algorithm.


Java program to reverse a string word by word



Output :

Original String : How are you

Words reversed : you are How

Java program to reverse a string using recursion

Below is the java program to reverse a string using recursive algorithm.


Java program to find prime numbers

A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself i.e it is divisible by one and itself. As of January 2014, the largest known prime number is 257,885,161 -1, a number with 17,425,170 digits. Below is the simple java program which will print the prime numbers upto the limit provided.


Monday, January 27, 2014

Java program to create an Icons of A-Z

Output

    etc

Java program to print a-z, A-Z sequentially

// PrintAlphabets.java

public class PrintAlphabets {

public static void main(String[] args) {

for (char alphabet = 'a'; alphabet <= 'z'; alphabet++) {
System.out.print(alphabet + " ");
}

System.out.println();

for (char alphabet = 'A'; alphabet <= 'Z'; alphabet++) {
System.out.print(alphabet + " ");
}
}

}

Output

a b c d e f g h i j k l m n o p q r s t u v w x y z
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 

Java program to create an image using Graphics2D

Please see the self explanatory java code below
Output


Eclipse : Caused by: java.lang.ClassNotFoundException / Exception in thread "main"

java.lang.NoClassDefFoundError: com/javaxp/test
Caused by: java.lang.ClassNotFoundException: com.javaxp.Test
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Exception in thread "main" 


There could be a couple of reasons for the above error

1. .class files not created properly

Try
Project -> Clean -> Clean all projects / Clean project selected below -> OK

2. JVM is not able to pick the classpath

Try
right click on the project -> Properties -> Java Compiler -> unclick the first box saying 'Enable project specific settings' -> Apply -> OK

3. A missing JAR file in the classpath

Try
right click on the project -> Properties -> Java Build Path -> Libraries -> (Remove unwanted missing jar files if any) -> OK

Hope this helps in most of the cases.

Wednesday, January 22, 2014

DB2 Equivalant for Rownum of Oracle - ROW_NUMBER() OVER()

Syntax - Select ROW_NUMBER() OVER(), column_name1 from table

SQL0803N / SQLSTATE=23505

Error during Execute
 23505(-803)[IBM][CLI Driver][DB2] SQL0803N  One or more values in the INSERT statement, UPDATE statement, or foreign key update caused by a DELETE statement are not valid because the primary key, unique constraint or unique index identified by "" constrains table "" from having duplicate values for the index key.  SQLSTATE=23505



Probably you are trying to insert a value in primary key / unique key which is already present and thus violating primary key, unique key constraints. Please make sure you are not entering duplicate values in primary key / unique key.

Tuesday, January 21, 2014

A parent row cannot be deleted because the relationship "R_1" restricts the deletion

Error during Execute
 23504(-532)[IBM][CLI Driver][DB2] SQL0532N  A parent row cannot be deleted because the relationship "R_1" restricts the deletion.  SQLSTATE=23504


You are trying to delete a specified row in the parent table which has dependencies on child table(s). First delete the record in the child table(s) and then try to delete the record in the parent table.

Thursday, December 19, 2013

Unix/Linux - Shell script to find and replace a text from the list of files

Below is the automated shell script which will find a text and replace it with the given string. It will also keep a backup of existing file. It can also be used for global search and replace string from a text file. Please see the self-explanatory shell script below -

replace.sh

#!/bin/bash

#find string
searchString="text1"

#replace with
replaceWith="text2"

echo "searching "$searchString" ..."
grep -l $searchString * >foundIn.txt
chmod 777 foundIn.txt

echo "replacing "$replaceWith" ..."
count=0
while read x
do
  if [ $x != replace.sh ]
  then
          (cat  $x) >$x"_bkp"
          sed "s/${searchString}/${replaceWith}/g" $x"_bkp" >  $x
          count=$(($count+1))
          echo "Found in... "$x
  fi
done <foundIn.txt

echo $count "occurences have been replaced."

Linux/Unix - Shell script to read a text file

Method 1 - By iterating each line using while loop

#!/bin/bash

#Name of the text file
txtFile=myFile.txt

echo "Reading text file "$txtFile" ..."

while read x
do
echo $x
done <$txtFile


Method 2 - By using cat (concatenate and display files) command

#!/bin/bash

#Name of the text file
txtFile=myFile.txt

echo "Reading text file "$txtFile" ..."

cat $txtFile

Wednesday, December 18, 2013

keytool error: java.io.FileNotFoundException: cacerts (Permission denied)

I got the error when trying to install a certificate into my keystore

Command -
keytool -import -alias aliasName -file fileName.cer -keystore cacerts
keytool -list -keystore cacerts

Solutions

Windows -
This could happen if you are not running the command prompt in administrator mode. Login with the user who has administrator privilege.

For Windows 7 and above - Go to run, type cmd and hit Ctrl+Shift+enter. This will open the command prompt in administrator mode.

For others windows -  Go to start -> all programs -> accessories -> right click command prompt and say run as administrator.

Linux -
First check the write permissions on the keystore. Also if needed login with root user and try the command.

Wednesday, November 13, 2013

How to use scp command without prompting for password

You may need to write a shell script in which you want to copy a file from one server to another. OfCouse you can easily achieve it with SCP command however when you automate the shell script using crontab it will get stuck because of password prompt. To avoid this you want SCP command to work without prompting for password.

Secure Copy (SCP) allows files to be copied to, from, or between different hosts

Let’s assume you want to copy a file from host server (HOST) to destination server (DEST).

1. On HOST server run below command

$ ssh-keygen -t rsa

First it will prompt for "Enter file in which to save the key" just keep it blank by pressing enter. Then it will prompt for passphrase, again keep it blank by pressing enter. It will generate a public key (id_rsa.pub) and a private key (id_rsa) in the folder <your_home_dir>/.ssh

Output -

$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/.ssh/id_rsa.
Your public key has been saved in /home/.ssh/id_rsa.pub.
The key fingerprint is:
1a:7b:3b:d7:5c:f0:6d:f1:01:75:0f:b1:71:6a:15:be user@HOST

2. Share the public key (id_rsa.pub) with DEST server

Copy the file id_rsa.pub from HOST to <your_home_dir>/.ssh folder of DEST. You can use scp or ftp anyway you are comfortable with.

3. Copy the contents of id_rsa.pub to <your_home_dir>/.ssh/authorized_keys2 in DEST server

Below command will append the content of id_rsa.pub to authorized_keys2. Note - you may even copy to authorized_keys whichever file exits on <your_home_dir>/.ssh in DEST server

$ cat id_rsa.pub >> authorized_keys2

Now if you use SCP command to transfer a file from HOST to DEST it won’t prompt for password. I hope it helped you.

Java program to play an audio sound

These are the following ways in which you play a sound in Java.

Toolkit - If you just want a beep or quick alert you can use beep() finction of class java.awt.Toolkit. It Emits an audio beep.
AudioClip - The AudioClip interface is a simple abstraction for playing a sound clip.
Clip - The Java Sound API provides functionality for the capture, processing, and playback of sampled audio data & the sequencing and synthesis of MIDI data.
MIDI Sequences - The javax.sound.midi package provides an interfaces and classes for I/O, sequencing, and synthesis of MIDI (Musical Instrument Digital Interface) data.

Please see the sample code of each type


Wednesday, November 6, 2013

Example using Java.awt.Robot class

Java.awt.Robot class is used to take the control of mouse and keyboard. In this example we will open a notepad and type a message. Please see the self explanatory code below.

Tuesday, November 5, 2013

Top 5 Popular jQuery Plugins


Author Bio: Danica loves technology and she constantly advises people on the best web hosting platforms for using jQuery as well as a host of other coding libraries. She is an expert at using PHP and hopes to start her own development company in the future.

jQuery is one of the most popular libraries available to webmasters and developers, and a big reason for that is the large number of high quality plugins that are available. These help novice webmasters and developers to create professional looking websites filled with different features, while those with experience can use jQuery to add the finishing touches to what is already an exceptional platform.

That said, one of the worst things for a developer to do online is to overuse plugins, widgets, and various other things that are available in order to enhance the user experience of a website. With that in mind, we have looked at five of the best and most popular jQuery plugins you could use on your website.

Cycle 2

If static images are a big part of your website, then the Cycle 2 jQuery plugin is a great way to take your imagery to the next level and create exciting slideshows on your web pages. What makes this plugin a winner is that it is so easy to use; all you need to do is include the plugin and mark-up to your code, and everything else is done for you. Although this is the perfect plugin for new webmasters or bloggers, it is also loved by those with great knowledge of web development owing to its ability to work within responsive design themes.

FitVids

While many people fret about how having video content on their website will slow down loading times, some struggle to even get video onto their pages at all. Those who want to make video a feature of their site should consider using FitVids, especially if they are embedding video content that is already featured on sites like YouTube.

Even though modern HTML5 coding makes it easy to embed your own videos from your disk or device, it is still worth using a plugin like FitVids so you can be flexible with the video content on your site.

Tuesday, October 29, 2013

Java program to take screen shots of your desktop

This example is used to take screen shots of your desktop and save the file in specific format in your machine. This example uses java.awt.Robot class to capture the screen pixels and returns a BufferedImage. Java.awt.Robot class is used to take the control of mouse and keyboard, see API for more options. Once you get the control, you can do any type of operation related to mouse and keyboard through your java code.

Please see the self explanatory java code below. This example takes screen shot of your desktop after an interval of every 5 second, you can customize it as per your requirement.

Friday, October 25, 2013

The Pros And Cons Of The ZK Framework For Java

By Adam Shrum, IT Manager and analyst at Dynamic CAFM, a Texas based facilities management software provider.

When tackling a new software development project there are many things to consider. First, what is the scope of the project? Second, what language should be used to develop the project. And Finally, what tools will be needed to complete the project efficiently. I manage a team of developers in Pearland, TX and we have had to answer all three of these questions at one time or another. Before we use any tool we always come up with a pros vs. cons analysis to evaluate the tool beforehand. One of the Java tools we use quite frequently is ZK or ZKoss, an Ajax + Mobile enterprise framework that incorporates Spring, JPA, Hibernate, JavaEE, Grails, and Scala. I like to think of ZK as a front end tool that keeps you from having to create a UI from scratch. Like any other front end tool there are pros and cons of using a framework like ZK.

The number one pro of ZK is that it’s Open Source. Because it’s an open source product there is a community of developers that support it via the ZK Forums. It’s important to also note that the documentation for ZK is very good, and there have been few times when we have even needed to go to the forums for help. Another pro is that Big Name Companies use ZK which is always a positive. Companies such as Sony, Deutsche Bank, Sun Microsystems, IBM, Toyota, and Adobe are ZK users and to me one of the biggest red flags of a software tool is that nobody is using it. With ZK you know you’re dealing with a proven product that actually works. ZK has a Rich Modular UI which is made up of many different components you can call out without having to code from scratch. They have thought of almost everything out of the box, but additional components are included with the PE and EE paid versions of the product.
Oh yeah, I forgot to mention that ZK is a Free Product when you use the community edition. Because it’s free there is no upfront cost which is another positive, and there is no cost for a user license as well. If you are working with a legacy system and have decided to utilize ZK in an update to that legacy system you will experience much more control over the system than you had before.

Saturday, October 19, 2013

Telephone Hacking

Everyone has come to know what phone hacking is after the parents of murdered schoolgirl; MillyDowler had their voicemail hacked into. But, it didn’t end there, it has subsequently been exposed that numerous celebrities have had their telephone hacked into by the British media. One more victim of the telephone hacking outrage has been the Royals. A phone hacker can be defined as somebody who listens to your voicemails without your consensus. However, to become a victim of phone hacking you don’t need to be a celeb.

Your telephone bill can upsurge by thousands of quid if you come to be the victim of telephone hacking. Impostors will hack into your phone system in a process known as phreaking. Phonehacking is least possible to be uncovered during holiday times and evenings, consequently that is when it is almost certainly to happen. You might have become a victim of telephone hacking if your phone bill has unexplainably enlarged dramatically.

Hacking into a telephone system can make the offenders a lot of money. There are websites that are dedicated to this activity; this is where the offenders are learning to do this. So you don’t need to be an internet geek to do this. However, it’s not until the damage has been done that many people realise what’s happened. Just like the anti-virus software for your computer, you need to secure your telephone.

Friday, October 18, 2013

Top Five Suggestions to Grow Twitter Followers Online

In terms of social networking, Twitter’s recent activity and progress is currently as huge as Facebook. Making a Twitter account and posting information is straightforward, since it merely requires a couple of minutes to have things going. Even so, it will necessitate a considerable amount of time for you to begin noticing results. Building an interesting following may be the most difficult part.


This can be still tricky for those already with accounts. For first timers to Twitter, this is a daunting aspect to accomplish. The buzzword “engagement” is normal to all folks, but how do you make that come about? To boost your Twitter presence online, check out Followersboosts.com and adopt these 5 suggestions.

1. Tweet and tweet regularly, but give room for responses 

Depending on how active you are or how active your Twitter profile is, anybody is quite likely to discover you on Twitter as well as become your follower. The more dynamic you are, the larger your chances of someone finding you and vice versa. The Twitter public timeline is where your tweets appear. You increase your probability of appearing there more often by increasing your number of tweets.

Nonetheless, tweeting on a regular basis and of nothing worthy sets you vulnerable to losing followers. By talking too much and about everything, you deny your followers room to respond. You ought to leave room between your topics of dialogue to permit others to communicate. You should therefore attempt to discuss one subject at a time.

Thursday, October 3, 2013

Error occurred during initialization of VM / Could not reserve enough space for object heap

If you are getting below error while running a java program, possible reason could be JVM is running in another bit mode (32 bit OR 64 bit)

Error occurred during initialization of VM
Could not reserve enough space for object heap

Solution - Check out in which bit mode your JVM is running. you can use below command to find out in which bit mode your JVM is running.

java -d32 -version OR java -d64 -version

Find the line that executes the java command and add correct bit mode. For example ' -d64 ' to the java command line. This is a flag that forces the Java virtual machine to run in 64 bit mode.

Saturday, September 21, 2013

Java program to check IP address range

This is a simple java program to check IP address range. Here we provide a IP address to check whether it lies between start and end IP address.

Please see the self explanatory java code below. Just provide the IP address and see the output.


Saturday, September 14, 2013

Is Outdated Java Lurking in Your System?

In January of 2013, Oracle announced plans to reevaluate and strengthen its security protocols. The announcement came after serious vulnerabilities were found in Java 6, coupled with widespread criticism of the company’s rigid patch release schedule.

Throughout the next six months, Oracle did, indeed, take steps to tighten their security, surprising some detractors with their commitment to the issue. Most, if not all, security improvements, however, centeron the latest version of Java, Java 7.

Unfortunately, as a recent report by security firm Bit9 makes clear, many organizations continue to use Java 6, forwhichOracle stopped providing public security updates in April of 2013. Even worse, many endpoint systems run multiple versions of Java, which allows hackers to capitalize on older vulnerabilities.

Java Usage and Version Statistics

Bit9 surveyed over 400 organizations, representing a total of over 1 million distinct endpoint systems. The survey discovered Java 6 on over 80 percent of systems. Matters got worse. The most commonly installed version of Java 6 was Java 6 Update 20, which includes a staggering 215 security issues. How far behind is this update? The last version of the software was Java 6 Update 45.

Any system using outdated versions of Java 6 is at risk of serious vulnerabilities. Whether you’re selling 1994 mustang parts or offering online cloud hosting, outdated versions of Java, or indeed any program, represents significant risk of security breaches.

Only 15 percent of endpoint systems surveyed used Java 7, and even then, were rarely up-to-date. Only 3 percent were running Java 7 Update 21, the most recent update at the time of the survey.

Javascript - Password strength meter

Password Strength Algorithm

Password Length:
5 Points: Less than 4 characters
10 Points: 5 to 7 characters
25 Points: 8 or more

Letters:
0 Points: No letters
10 Points: Letters are all lower case
20 Points: Letters are upper case and lower case

Numbers:
0 Points: No numbers
10 Points: 1 number
20 Points: 3 or more numbers

Characters:
0 Points: No characters
10 Points: 1 character
25 Points: More than 1 character

Bonus:
2 Points: Letters and numbers
3 Points: Letters, numbers, and characters
5 Points: Mixed case letters, numbers, and characters

Password Text Range:

>= 90: Very Strong
>= 70: Strong
>= 50: Good
>= 30: Weak
>=  0: Very Weak

Thursday, July 4, 2013

Access restriction: The type BASE64Decoder is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_25\jre\lib\rt.jar

Error :

You may get below compile error in eclipse while using BASE64Decoder or BASE64Encoder.

Access restriction: The type BASE64Decoder is not accessible due to restriction on required library C:\Program Files\Java\jdk1.6.0_25\jre\lib\rt.jar

Using sun.* package should be avoided, Please see the link.

Solution :

Still if you need to access sun.misc.BASE64Encoder, in Eclipse, right click on the project, properties -> Java compiler –> Errors/Warnings –> Enable project specific settings -> Deprecated and restricted API –> Forbidden reference (access rules), change the default "Error" to "Warning". Now, your code should be able to compile, but with some warning messages.



The above solution is not recommended, you should replace sun.misc.BASE64Encoder with other BASE64 class like org.apache.commons.codec.binary.Base64; Apache common codec

Caused by: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

Exception in thread "main" java.lang.Exception: Error Initializing Context: oracle.jdbc.driver.OracleDriver
at com.hewitt.appinv.sdc.db.LocalContextFactory.createLocalContext(LocalContextFactory.java:28)
at com.hewitt.appinv.sdc.db.TestJNDI.main(TestJNDI.java:14)
Caused by: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.hewitt.appinv.sdc.db.LocalContextFactory.createLocalContext(LocalContextFactory.java:23)
... 1 more

If you see above error, Please add classes12.jar  in your applications classpath. Download it from here. classes12.jar  

Wednesday, July 3, 2013

What You Need to Know About The Recent Java Patches

The latest round of Java patches, which were released in mid-June, call attention to some issues that all Java programmers should be concerned about. Oracle enabled online certificate revocation checking by default in the move, and it dealt with 40 security issues in Java. Of course, it’s hardly unusual for Oracle to issue a large number of patches at once, but it’s critical that programmers understand what the issues were, whether they maintain sites about British history or alcoholrecovery centers.

Who and What Was Impacted

According to Oracle, 34 of the patches in the Java 7 Update 25 (Java 7u25) affected only client developments of Java. Client and server deployments were affected by four other vulnerabilities, while one dealt with the Java installer and another with the Javadoc tool employed to make HTML documentation files.
Here’s an alarming development: The client-only vulnerabilities, which accounted for the aforementioned 34 patches, were extreme. Oracle graded them highly on its vulnerability severity scale. That’s because they might be used to trick users into loading malicious Java applets onto remote servers, a big problem indeed.


javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Error :

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1649)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:241)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:235)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1206)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:136)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:593)
at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:529)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:893)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1138)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1165)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1149)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:434)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:166)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1172)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234)
at com.hewitt.appinv.sdc.URLReader.readURL(URLReader.java:18)
at com.hewitt.appinv.sdc.URLReader.main(URLReader.java:38)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:323)
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:217)
at sun.security.validator.Validator.validate(Validator.java:218)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:126)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:209)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:249)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1185)
... 13 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:174)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:238)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:318)
... 19 more


Monday, May 20, 2013

Java - Read excel file with blank cells

If you use normal cellIterator to iterate through excel cells it will skip blank cells. If you need to read blank cells as well you can use below method -