Wednesday, October 09, 2013

Simple WS client using CXF for .NET WS server

A long time ago I figured out this incompatibility, the matter is than when consuming a SOAP web service produced by a .NET server, the following exception used to happen:

undefined element declaration 's:schema'

so, searching again a lot, I've found the solution; so using a CXF maven plugin to build the client, will simply look like this:


                        generate-sources
                        generate-sources
                        
                            
                                
                                    
                                        ../path/to/wsdl
                                    

                                    
                                        -b
                                        http://www.w3.org/2001/XMLSchema.xsd
                                        ... OTHER EXTRAARGS ...
                                    
                                
                            
                        
                        
                            wsdl2java
                        
                    

Simply add those two extraarg elements to the POM, and that's all. Of course using those same parameters when using CXF via command line will work fine.

Thursday, September 19, 2013

Making Work VirtualBox on Fedora 19

After many hours trying to solve a basic problem while installing Virtual Box on my recently installed Fedora 19, i found a very simple solution, which no one post has.

Problem.

I've got the following description:

Trying to register the VirtualBox kernel modules using DKMSError! echo
Your kernel headers for kernel 3.3.4-5.fc17.x86_64 cannot be found at
/lib/modules/3.9.5-301.fc19.x86_64/build or /lib/modules/3.9.5-301.fc19.x86_64/source.
[FAILED]
(Failed, trying without DKMS)
Recompiling VirtualBox kernel modules [FAILED]
(Look at /var/log/vbox-install.log to find out what went wrong)


Paying attention to the source of the problem, the directory /lib/modules/3.9.5-301.fc19.x86_64 doesn't exists, when I go to the path /lib/modules/, an making an LS, I got:

[root@localhost modules]# ls -al /lib/modules
total 48
drwxr-xr-x.  5 root root  4096 Sep 19 08:26 .
dr-xr-xr-x. 68 root root 32768 Sep 19 12:49 ..
drwxr-xr-x.  6 root root  4096 Sep 19 12:29 3.10.11-200.fc19.x86_64
drwxr-xr-x.  7 root root  4096 Sep 19 16:12 3.11.1-200.fc19.x86_64
drwxr-xr-x.  6 root root  4096 Sep 19 12:29 3.9.5-301.fc19.x86_64


It looks like there is the requiered directory, but checking it better, I realize that ...

$[miguel@localhost kernels]$ ll 3.9.5-301.fc19.x86_64/
lrwxrwxrwx.  1 root root     38 Jun 27 13:14 build -> /usr/src/kernels/3.9.5-301.fc19.x86_64
drwxr-xr-x.  5 root root   4096 Sep 19 12:29 extra
drwxr-xr-x. 12 root root   4096 Jun 27 13:14 kernel


And build sym link has an error, because the origin /usr/src/kernels, doesn't contains the 3.9.5-301.fc19.x86_64 directory.

$[miguel@localhost kernels]$ ls -al /usr/src/kernels/
total 16
drwxr-xr-x.  4 root root 4096 Sep 19 15:39 .
drwxr-xr-x.  4 root root 4096 Sep 19 12:49 ..
drwxr-xr-x. 22 root root 4096 Sep 18 01:57 3.10.11-200.fc19.x86_64
drwxr-xr-x. 22 root root 4096 Sep 19 12:05 3.11.1-200.fc19.x86_64


Actually, this is correct, such that directory doesn't exists.

Solution.

After many hours, trying to get the missing kernel headers, and so..............


I realized that making

[root@localhost modules]# uname -r
3.9.5-301.fc19.x86_64


Even when I updated the Kernel, the old kernel still was referenced, and so I decided to use that kernel in my next boot, so editing the /boot/grub2/grub.cfg file, solves the problem. Just add a new entry to grub referencing to the updated kernel, and reboot.

### BEGIN /etc/grub.d/10_linux ###

### The configuration to make work the new kernel version, this for fixing the VirtualBox problem
menuentry 'Fedora, with Linux 3.11.1-200.fc19.x86_64' --class fedora --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.11.1-200.fc19.x86_64-advanced-68e3207d-d9ac-41ee-8db8-2bcb2dc308a1' {
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos6'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6 --hint='hd0,msdos6'  63534bc2-5c8b-49a8-8156-8ba8bfe5d2df
    else
      search --no-floppy --fs-uuid --set=root 63534bc2-5c8b-49a8-8156-8ba8bfe5d2df
    fi
    linux    /vmlinuz-3.11.1-200.fc19.x86_64 root=UUID=68e3207d-d9ac-41ee-8db8-2bcb2dc308a1 ro rd.md=0 rd.lvm=0 rd.dm=0 vconsole.keymap=us acpi_backlight=vendor acpi_osi=Linux rd.luks=0 vconsole.font=latarcyrheb-sun16 rhgb quiet
    initrd    /initramfs-3.11.1-200.fc19.x86_64.img
}

###End of custom configuration

menuentry 'Fedora, with Linux 3.9.5-301.fc19.x86_64' --class fedora...


Ok, now in the start screen, the new entry appears, and use the new entry, try to use VirtualBox as usuarl, and everything goes ok.

I hope it would be helpful, have a nice day community...

Sunday, June 02, 2013

Put Android Maps V2 work on your Emulator

Last time i've been reading a lot about the new features of the Google Android Maps API v2., so after many hours of trying to make work these new features in my emulator, I've found such that solution in the following steps:

1. Need To create a new AVD WITHOUT GoogleApis, for example, the next picture shows my emulator for testing.
2. Next, start the emulator as usual, but this after the starting has been completed, we'll install TWO extra APK files. Those APK files are the following:

  1. The Google Services platform is the component of the OS, which provides of those new features, so the most important thing to remember is to ALWAYS INSTALL the latest version of this file, in my case I downloaded the following file com.google.android.gms-19032013.apk. Be careful to check the LATEST version, at the time of writing this post, this file was the latest one.
  2. I read many in many posts to download and install the following file "com.android.vending-1.apk", but those posts do not mention that this file is simply the Google Playstore APK, neither mention that need the LATEST version, so I downloaded as many files as you can imagine, trying to make the API work. Thus, the file we need is again the LATEST apk file of the Google Playstore, in my case I downloaded the "Playstore v4.0.27.apk" file.
This seems to be so easy when nobody is there to tell you what exactly need to do. I encountered many problems using the wrong file.

If you encounter with the (491 error) when trying to update the Google Play Services, or if you are installing some APK right to the /data/system/, maybe you searched for a solution a lot but I certainly can tell you that the answer is not in that way.

I will omit the steps about how to create and configure the API key for android applications, (but if you are interested, I've added some reference links for this) instead I will focus on the project configuration using the (not my favourite IDE) Eclipse; when the Android Studio gets stable, I will post a new entry (if necessary) about how to configure a project in that IDE.

Ok, let get back to what we want.

1. Create a project.

2. After you created the project, need to import the existing "google_play_services-lib" eclipse project, into the new project, by doing the following:

3. IF is the first tie you are attempting to use the API, then need to import the Google Play Services Lib into the workspace.

File > Import...

Then go to the android-sdk installation path and browse to: /SDK_HOME/extras/google/google_play_services/libproject/google-play-services_lib.


I read in many posts, that is NECESSARY to copy the project into the current workspace, this due to bugs in Eclipse IDE.

4. After this has been done download the source code and replace in your new project (the source code is at the end of the post), you'll notice that many classes couldn't be found.


Indeed, you need to add the new imported project which is marked as a Library into the Android settings of the project.

Right Click on Project > Properties > Android
And in the lower panel, press the "Add" button and choose the recently imported Library. Then press Ok.

5. One last thing to not forget is that Eclipse external libraries need to be copied into the "LIBS" folder of the project to make them available to the Build.

Then copy the "google-play-services.jar" file located in the "LIBS" directory of the "google-play-services_lib" imported project.

Also do not forget to add it to the compilation build path of the project, this for making those classes available for IDE.


6. OK, now configure the AndroidManifest.xml, and use the Google API key generated for your account.


7. Finally a very important step is to add the google-services.jar file into the APK, this to avoid exceptions like the following.

java.lang.NoClassDefFoundError: com.google.android.gms.maps.model.LatLng

So do the next steps:

Right clik project > Properties > Java Build Path.
Go to "Order and Export" tab.
 
Select the CheckBox of the "google-play-service.jar" file, the press OK.

8. Run thh project.

 VoilĂ !!!





The application works perfectly!!!



References:

About my search on web.

http://stackoverflow.com/questions/15894143/java-lang-noclassdeffounderror-com-google-android-gms-rstyleable-in-android
http://stackoverflow.com/questions/14372391/java-lang-noclassdeffounderror-com-google-android-gms-rstyleable
http://www.user.tu-berlin.de/hennroja/tutorial_fixing_java.lang.NoClassDefFoundError%20com.google.android.gms.R$styleable.html
http://stackoverflow.com/questions/13691943/this-app-wont-run-unless-you-update-google-play-services-via-bazaar
http://piotrbuda.eu/2012/05/installing-google-play-on-android-emulator.html

Files needed
Google Play Store, A.K.A (com.android.vending.apk)
Google Play Services, A.K.A. (com.google.android.gms.apk)

Google API

step by step guide 
NOTE, don't forget that you can use your OWN keystore to generate the KEY, but need to configure the Default debug store @Eclipse, Window> Preferences > Android > Build.


Source code

Wednesday, April 17, 2013

VMWare 8.0.6 issues fixed. Modules: vmmon, vmci

Recently I had some issues with VMWare 8, I've got Ubuntu 12.10. However, when I got the following errors, due to any reason:

"Failed to open device "/dev/vmci": No such file or directory Please make sure that the kernel module 'vmci' is loaded."

OR

"Failed to open device "/dev/vmmon": No such file or directory Please make sure that the kernel module 'vmci' is loaded."

I googled a lot, and there was not a good answer at all, after many hours and forums, I realized that the answer was as simple as:

sudo modprobe vmmon
sudo modprobe vmci

I hope this be helpful to anyone who cares.

By the way, I couldn't make work my version 9, due to a mismatch in vmmon versions 2.67 and 2.71, which many forums say to fix with a simply reboot of host machine.

"Version mismatch with vmmon module: expecting 271.0, got 267.0."

I'll see how to fix this issue, giving a real solution to it.

Tuesday, April 02, 2013

When UBUNTU terminal has no colors

You do not have problems with your terminal or terminal setting. Try this:
ls --color
It works, doesn't it?
Most likely, you have replaced your .bashrc. You can find the original .bashrc, which for example defines the alias ls='ls --color=auto' and also color promtpts in /etc/skel/.
Copy a new .bashrc with:
mv ~/.bashrc ~/.bashrc.old
cp /etc/skel/.bashrc ~/.bashrc

Wednesday, May 23, 2012

Some Useful Line Command Snippets

1. To Import data from a CSV file delimited with ',' into postgresql database, use the following command line:

cat population.csv | psql -U postgres -d geodata -c "COPY public.population(pop_adm0_name, pop_size) FROM STDIN WITH CSV HEADER;"

2. Filter fields from a JSON response resource:
curl --silent "https://maps.googleapis.com/maps/api/place/search/json?sensor=false&key=$GOOGLE_KEY&location=-16.493698,-68.134267&radius=300" | egrep \(name\|types\) | more # types

Others, coming soon...

Tuesday, May 24, 2011

Geotools MapRender 900913 Mercator

Back again to the Geotools, i decided to build my own tile builder using
specific cartography.
To achieve this I googled a lot, and few answers were useful. So to make this easier for anybody who intends to make it work, here's a little description of my problem.
"Need to render a map using the Spherical Mercator EPSG:900913 (EPSG:3857) using Geotools2.7.1"

1. first than all, let's use some existing data from Udig-data: http://udig.refractions.net/docs/data-v1_2.zip
2. I assume that already hav the Geotools2.7.1 API
3. Here's a code snippet to render a map: http://docs.geotools.org/latest/userguide/library/render/gtrenderer.html
4. Need to add some new parameters to support the correct reprojection of the map:

  1. Map rendererParams = new HashMap();

  2. rendererParams.put(StreamingRenderer.OPTIMIZED_DATA_LOADING_KEY, true);

  3. rendererParams.put(StreamingRenderer.LINE_WIDTH_OPTIMIZATION_KEY, isLineWidthOptimizationEnabled());

  4. //to support the mercator projection

  5. //turn on advanced projection handling

  6. rendererParams.put(StreamingRenderer.ADVANCED_PROJECTION_HANDLING_KEY, true);

  7. rendererParams.put(StreamingRenderer.CONTINUOUS_MAP_WRAPPING, true);

  8. //Add more parameters if needed

  9. renderer.setRendererHints(rendererParams);


5. It's very important to do what Andr
ea Aime says here: http://www.mail-archive.com/geotools-gt2-users@lists.sourceforge.net/msg04934.html.
"Check you feature source, if the default geometry in the feature type has no srs information set, no reprojection will occurr."
6. Finally the following code snippet will works perfectly to reproject from WGS84 to Spherical Mercator EPSG:900913:

  1. CoordinateReferenceSystem crs = CRS.decode("EPSG:900913");

  2. MapRenderer render = new StreamingMapRenderer(crs);

  3. render.setMapWidth(800);

  4. render.setMapHeight(800);

  5. render.setAreaOfInterest(new Envelope(-20037508,20037508,-20037508,20037508));

  6. DataStore ds = new ShapefileDataStore(new File("data/4326/countries.shp").toURI().toURL());

  7. render.addLayer(MapLayers.createStyledLayer(ds.getFeatureSource("countries")));

  8. RenderableWriter w = WriterFactory.findWriter("png");
  1. w.writeTo(new FileOutputStream("countries900913.png"), render);


RenderableWriter, WriterFactory, MapRenderer and StreamingRenderer are some interfaces and classes that does everything described above. StreamingRenderer is the most important and part of the code necessary to pr
oduce the reprojected image is listed at point 4.


Enjoy the result!!