Monday, July 29, 2013

Connect with RestTemplate via Proxy Server

If you try to connect to Rest Url, and if you are using a Proxy Server and try to connect with RestTemplate Client you will have an error like this:

"407 Proxy Authentication required"

You will have to configure your RestTemplate by the following steps:

After of that, you should be put httpclient jar in your classpath, download it from http://hc.apache.org/httpclient-3.x/

If you try to connect again with a UnitTest that will fix your problem.

Best Regards,

Monday, July 22, 2013

Quartz executes twice on Weblogic (Spring 3.2 + Quartz 1.8.6 + Weblogic 10.3g)

If you are developing some jobs with quartz probably you will figure out if your application will be well received by Weblogic, after a few hours some unittest I have the problem that quartz execute twice the method cointained in the job, If you try to debug the application on Weblogic you will be thinking alot of theories my solution was the following steps:

1. Create Quartz Database for clustering, this is at: 

../quartz-1.8.6/docs/dbTables

After executing the script in the database you will have to configure the quartz.properties:


This property file should be included in classpath, to charge this file you will have to add the following lines in applicationContext.xml:



Having this configuration will be loaded the ClusterManager, and you job executes only one time.

Best Regards,

Sunday, July 21, 2013

Bug: JDeveloper, File Delete Files

JDeveloper is good tool for development perhaps if it is only being unified with ADF development and more JSF standard it should be a perfect IDE. This error happens with the following scenario:

1. Oracle Linux 5
2. Subversion 1.8
3. Jdeveloper 11.1.2.3 & Jdeveloper 11.1.2.4

In my Check Out workspace I create a new project without include in the subversion repository, After some hours of development a try to DELETE  a file using [Supr] key so the following error appears:


Unable to delete files. "The following files and/or directories cannot be deleted (likely sources include permission violations, use v}by another program and source control state violations). You will need to delete these items directly from the file system" 


This is not a common error dialog, suddenly other thing happen, If you go to workspace in you file system every code file was deleted, JDeveloper delete all the files of your projects including the file it should be deleted. After spending some minutes trying to find my code the only backup I find is in deploment folder.

Wrote Enterprise Application Module: /root/jdeveloper/system11.1.2.3.39.62.76.1/o.j2ee/drs/Project

I remember this happen with a old version Visual Studio Express Edition before.

Best Regards,

Thursday, July 18, 2013

Exception: OptimisticLockingFailureException, Spring Batch 2.1.7

Probably this is not a non common exception on Spring Batch 2.1.7, if you are doing UnitTest this error will not appear, but if you are going to deploy your application on WebLogic 10g, spring batch breaks on ItemWriter, so the first thought is something like having break with a database transaction, well this is the answer:

If you have a configuration like this:


This will be break with the following exception on your Weblogic:



This is because some id and version are having a bad update in your spring batch table, to fix this problem you will have to create a Database with the full tables defined in your spring batch jar file:


If you unzip the jar file you will find a 'schema-drop-'%DATABASE%'.sql'  in "org/springframework/batch/core", you have to execute that script and re-deploy your application context with the folling configuration:


Finally, this error will be fixed.

Best Regards,

Wednesday, July 17, 2013

Exception: NoSuchMethodError, org.springframework.beans.factory.annotation.InjectionMetadata

If you are doing Unit Test with Spring Framework you will have to keeping the correct configuration of jar files that you have in you repository, sometimes if you dont have all the jar´s in you classpath exceptions will occur like this one:

java.lang.NoSuchMethodError: org.springframework.beans.factory.annotation.InjectionMetadata.<init>(Ljava/lang/Class,

With a stacktrace like this one...

It is said that you dont have the correct jar with the request method, after the first line of the above stack you can follow the method of the request jar, in this is case you see: "org.springframework.orm", finally you only need to add spring-orm dependency or jar file to your classpath.

 
Best Regards,

Monday, July 15, 2013

Note: Change the position of a Dialog in Primefaces from javascript

If you are working with primefaces you will figure out that this framework implemented with JQuery library, this a good behaviour for jsf pages, if you try to do something with javascript, you have to keep in mind reading primefaces css to understand how get that component you need.

1. First Step should be declare the libraries in head part of JSF:
2. Second step is to declare a position.js in your WEB-INF folder and write a function like this:
3. Finally declare the above function in your button
And that is it, you can take the control of any primefaces component rendered in the JSF page, using JQuery. 

Best Regards,

Sunday, July 14, 2013

Create a Web Service Client using GSoap Toolkit over HP-UX Server

This article was previously posted in CodeProject, I like very much this web site since my college days so this is the url: Create-a-Web-Service-Client-using-GSoap-Toolkit-over-HPUX , I hope this article will be helpful to you.

Sometimes in our daily lives as developers we have to integrate technology with different qualities sometimes this products are expensive or some relative close to the business lines, for example how to use a enterprise service overall the communication with legacy systems that is tough question, so the first possibility to resolve this problem is using message queue or web service or any other component there are many ways but the result should be measured and quantifiable for getting an approximation.

I want to emphasize a scenario where you are using a HP-UX server you want to integrate a legacy business process with enterprise service bus, so typically you have an interface from your ESB that could be a WSDL, this legacy system can execute a library, by now the common solution is doing some message queue put a message and wait that MDB get the message and you will be waiting the response, by this way is a very fast solution but  if you want to use XML on web service scenario well one advantage of ESB is that you could do eventually with the broker a transformation where you put a XML message in queue and the ESB literally will do the transformation this is a nice solution but I can give another one 'webservice vs legacy program' instance you should be thinking use a language like C (ANSI) or Python or cURL.
If you have using web service client generator like axis2 or wsdl.exe you should be familiarized with this toolkit is called GSoap is really fast and reliable in many aspects, if you search on internet you will get something like:
"gSOAP is an open source C and C++ software development toolkit for SOAP/XML Web services and generic XML data bindings. ", Wikipedia
The interesting part of the toolkit is that you will get C ANSI code generated on your stub, essencially all gcc compilers will translate his code The interesting part of the toolkit is that you will get C ANSI code
generated on your stub, essencially all gcc compilers will translate his code.

Using the code   


1. Download GSOAP Toolkit
The first step is download GSoap Toolkit from following site: http://sourceforge.net/projects/gsoap2/files/
Second Step should be install GSoap Toolkit , unzip gsoap_2.7.15.tar in a root directory for execution.
Example:  C:/SOAP/ gsoap_2.7.15
There are two executable files that allow us to generate libraries for connecting to the Web Service:1. wsdl2h.exe
2. soapcpp2.exe 
a.1 Run wsdl2h.exe 

a.2 Run soapcpp2.exe 
 





 2. Get WSDL file from Web Service Endpoint
 Here is an WSDL Example that you can see the xml structure.

GSoap can process the WSDL from the Web Service Endpoint only if the sitio does not have any kind of authetication that prevent direct access to web service. The most recommended option is directly get wsdl file from a web browser, taking care downloading the xsd files and change it form schemaLocation tag.

3. Generate Header File for the Stub

Generate the Header File 'SaleService.wsdl' thats has the necessary structures and procedures to generate the stub, it is important to note that the file will guide us to implement a web service client.
Example:

If we open the file containing struct SalesService.h notice that they are related to the input parameters and return variables.
Example:  
Another important point is that we handle struct for C (ansi), if we had used the-c parameter in wsdlh.exe, would have generated code in C + +, and this does not benefit us in the HP-UX terminals
 
4. Generate the Stub
With SalesService.h  header file we can use the following executable

If we observe the command line, are generated 4 files extension *.c

Files Generated need the following: 




Archivo
Definición
1.
soapH.h
Main Header File
2.
soapC.c
File with Data Structures.
3.
soapClient.c 
File with the implementation of the methods in C Web Service. 
4.
SalesService Soap12Binding.nsmap
SalesServiceSoap11Binding.nsmap  
Struct with corresponding namespaces Soap versions 1.1 and 1.2, this according to the version you wish to use

 5. Header file for the library 
We continue to write the library in first generating Header File (SalesServiceWS.h) 

  This file contains the public firm library SL / DLL


6. Main file with the implementation of the library 

We continue to write the call to the Web Service method according to this signature on file SaleService.h:



 
7. Compilation Shell 

The next thing is to compile the component on a HP-UX Terminal, so we need to ask the following fact:

When HP-UX compile our programs must be generated in 64bit for other programs running on the server can open the library and their corresponding links, as is the case for Progress Program 9, the common misconception regarding compilation this program is on the library dld.sl. 

Finally this is shell you could run on HP-UX Terminal, the reason is to compile all your source and get a library with *.sl extension

 
An important point during compilation is to include operating system libraries needed for compilation as in the case of lxnet, lnsl, ldl, lpthread.  

Monday, July 8, 2013

Create a JMS Destination Key on Weblogic 11g using WSLT

UPDATE: 13/04/2014
The article had been published on CodeProject.

http://www.codeproject.com/Tips/748377/Create-a-JMS-Configuration-on-Oracle-Weblogic-g-us
-------------------------------------------------------------------------------------------

There is another method to create a Server Configuration on Weblogic if you are not using the console, if you want to execute a script with all of your configuration you must know about WSLT.

This model solve problems like deployment on others enviroments like Quality Assurance and Production were you should dont have any permision to access to this console, only the deployer will run the script and install any executable on the server. You should follow the next steps:

1. First go to you Weblogic Home, for example the location of my weblogic installation is:


1:  [root@USER25 bin]# cd /root/Oracle/Middleware/11.1.2.4.0/   

2. Go to the next folder...


1:  [root@USER25 bin]# cd /root/Oracle/Middleware/11.1.2.4.0/wlserver_10.3/server/bin  

3. Open a console and keep in mind you should have running weblogic and the execute:


1:  [root@USER25 bin]# ./setWLSEnv.sh  

4. Running the above command you will have the opportunity to run script on Python and IronPython on your weblogic running, I will show you an script example runs several tasks to create a JMS Server, JMS Module, Queue, Dead Letter Queue and DESTINATION QUEUE that is the object we need for this tutorial, so this the code...

The segment of code we  carry on the next ...


1:    def createDestinationKey(dkname):  
2:        print "createDestinationKey() START"    
3:        cd('/JMSSystemResources/'+moduleName+'/JMSResource/'+moduleName)  
4:        dk1 = create(dkname, "DestinationKey")  
5:        dk1.setProperty("JMSPriority")  
6:        dk1.setKeyType("String")  
7:        dk1.setSortOrder("Descending")  
8:        print "createDestinationKey() END"  

Here we define a part of the XML that is deployed on the server, we pass the property, keytype and sortorder that should be published on Weblogic, this procedure can be executed as a transaction as python script. 


1:            ...  
2:          cd('/JMSSystemResources/'+moduleName+'/JMSResource/'+moduleName)                    
3:            cd('/JMSSystemResources/'+moduleName+'/JMSResource/'+moduleName+'/Queues/'+qname)  
4:            set('DestinationKeys',jarray.array([String(dkName)],String))  
5:          ...  


If you follow the script you will get a declaration of an array on XML, that because if you check Weblogic documentation a Destination Key is an Array of String, so in Python you have to declare your DeclarationKeys as String[], keep in mind that note.
  
5. The comand we need to execute on terminal is:


1:  [root@USER25 bin]# java weblogic.WLST createJmsServer.py  

6. Finally we will see the trace of execution, and veryfing with the Weblogic Console all the script will be create all configuration declarated on python file, this is so much powerfull of course you can create a JNDI or any task that we do over console.

UPDATE 29/05/2016
You could found script uploaded to github on the next link:
https://github.com/osanchezh/weblogicjmsclustered-module  

Best Regards,