Posts

Showing posts from 2015

java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver - Jdeveloper

If anyone experiencing below issue with Jdeveloper. First go and check whether Oracle JDBC jar is added to your class path or not. java.lang.ClassNotFoundException: oracle.jdbc.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:305)  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)  at java.lang.ClassLoader.loadClass(ClassLoader.java:246)  at java.lang.Class.forName0(Native Method)  at java.lang.Class.forName(Class.java:169)  at webserviceproducer.WebServiceProducer.getConnection(WebServiceProducer.java:34)  at webserviceproducer.WebServiceProducer.main(WebServiceProducer.java:29) I have added 'Oracle JDBC' jar to the project class path and issue got resolved. Thanks for visiting this blog.

Remove duplicates from array without using java utils.

public class RemoveDuplicates { public static void main(String[] args) { Integer arr[] = {1,4,2,1,7,5,0,7,7,1,1,5,4,9,4,1,5,4,9,7,6,1,7,7,8,9,9,0,4}; for(int i=0;i<arr.length-1;i++){ for(int j=i+1;j<arr.length-1;j++){ if(arr[i] == arr[j]){ for(int k = j; k<arr.length-1;k++){ arr[k] = arr[k+1]; }                                         //copy array to remove last element. Integer copy[] = new Integer[arr.length-1]; System.arraycopy(arr, 0, copy, 0, arr.length-1); arr = copy;                                        //decrease j value in case match found to not miss repeated values. j--; } } } for(int z=0; z<arr.length;z++) System.out.print(arr[z]); } }

Test Web Service using SOAP UI

Image
In this example I would like explain how to use SOAP UI to test web services. To demo this I have used the Web Service that I have created in my previous blog http://dileepkumarrongali.blogspot.com/2015/10/creating-web-service-using-jdeveloper.html File -->  New SOAP Project. Give project name and WSDL. And click OK.  SOAP project will be created. Now click on Request 1 file. Fill the required parameters in the left hand pane and click Alt + Enter or green play button. Response we get on the right hand side.  Thank you :)

Creating Web Service using JDeveloper.

Image
In the below example I would like to explain how to expose simple java class as web service. Steps to Create WebService Using Jdeveloper (version used 11.1.1.7.0) File -->  New -->  Generic Application  Provide Application Name and click Next Give Project Name and select project technologies Java and Web Services. And click Finish.  Create Java class in the project. Below is Sample Java code I have written.   Right click on java class and select ‘Create Web Service’ Select JAX-WS Annotations platform Leave Default Web Service Name and Port Name. And rest we can take default and click finish. We can see @WebService annotation added to our class.  And web.xml entry will be created and adds our web service class as servlet entry there.  To test this webservice, right click on webservice class and select Test Web service. In Http Analyzer, we can test our web service. We can access this w

Generate PDF Reports using iText

Image
Hi, In this blog I would like to show how to create PDF report using iText API. Below is working code to generate PDF. import com.itextpdf.text.BadElementException; import com.itextpdf.text.BaseColor; import com.itextpdf.text.Document; import com.itextpdf.text.DocumentException; import com.itextpdf.text.Element; import com.itextpdf.text.Font; import com.itextpdf.text.Font.FontFamily; import com.itextpdf.text.Image; import com.itextpdf.text.PageSize; import com.itextpdf.text.Paragraph; import com.itextpdf.text.Phrase; import com.itextpdf.text.Rectangle; import com.itextpdf.text.pdf.PdfPCell; import com.itextpdf.text.pdf.PdfPTable; import com.itextpdf.text.pdf.PdfPageEventHelper; import com.itextpdf.text.pdf.PdfWriter; import java.io.FileOutputStream; import java.io.IOException; import java.net.MalformedURLException; public class PDFReportGeneration {     public PDFReportGeneration() {         super();     }     public static void main(String[] args) {  

javax.xml.ws.WebServiceException: javax.xml.ws.WebServiceException: java.lang.InstantiationException: weblogic.wsee.jaxws.client.async.AsyncTransportProvider

javax.xml.ws.WebServiceException: javax.xml.ws.WebServiceException: java.lang.InstantiationException: weblogic.wsee.jaxws.client.async.AsyncTransportProvider I got below error while deploying my webCenter project to the integrated weblogic server. Reason: Due to unwanted jars in the project Library and classpath. Solution: Remove unwanted jar from the libraries and classpath. In my case weblogic.jar is present. javax.xml.ws.WebServiceException: javax.xml.ws.WebServiceException: java.lang.InstantiationException: weblogic.wsee.jaxws.client.async.AsyncTransportProvider        at weblogic.wsee.jaxws.WLSInstanceResolver.getSingleton(WLSInstanceResolver.java:36)        at weblogic.wsee.jaxws.WLSInstanceResolver.start(WLSInstanceResolver.java:55)        at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.start(WLSInstanceResolver.java:82)        at com.sun.xml.ws.server.InvokerTube.setEndpoint(InvokerTube.java:85)        at weblogic.wsee.jaxws.EndpointAwareLa

Failed to load weblogic client internal deployment descriptor. java.io.IOException.

Failed to load weblogic client internal deployment descriptor. java.io.IOException. If you are getting above error while making web service call in your java code. The cause might be with missing classes in your project path. In my case, I am trying to make web service call through java class and I got the above issue. To fix the issue, I have added wseeclient.jar to the project class path. I am using IDE JDeveloper to run my main java class. And this jar will be present in below path in my case. C:\Oracle\Middleware\wlserver_10.3\server\lib 

Send email from java code.

This blog will explain how to send email from java code. In order to send email from java code, we need to set properties of mail server and protocol. In my example I have set the authentication to false. So no authentication required before sending the email. Below is the working java code to send email. import java.util.Properties; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; public class SendEmail {     public SendEmail() {         super();     }     public static void main(String[] args) {         SendEmail sendEmail = new SendEmail();         //here you can set array size more to send mail to more users.         String to[] = new String[1];         to[0] = "kumar@gmail.com";         sendEmail.sendEmail("dileep@gmail.com", to, "rongali@gmail.com