california Canada conference Conferences database db db2 DB2 pureXML development eclipse fall flickr google ibm Internet it java jdbc Joomla Linux mapping Open Source Other perl Personal Photography Portugal programming purexml rails rogers ruby shipment Software software-testing sql sqlj Tech toronto tpmg Travel twiki USA xml yahoo

Persisting XML with OpenJPA

Tags: , , , , , , , , , ,

I’ve been looking at JPA – Java Persistence Architecture and decided to play a bit with OpenJPA using DB2 as the back-end. My goal: to persist and query XML data in DB2, making use of DB2’s pureXML capabilities to query the XML data using SQL/XML’s XMLQUERY() function.

However, while OpenJPA has an extensive documentation, the examples are not always complete and there isn’t a lot of information on the web regarding OpenJPA error determination and solving. So, here are some recommendations for some of the problems I have encountered. The class xml.Address is the one to be persisted as XML in the database using JPA and it is stored as the field shipAddress of the Order objects.

 [java] Exception in thread "main" <openjpa-1.0.0-r420667:568756 fatal user error>
org.apache.openjpa.persistence.ArgumentException:
Type "class xml.Address" does not have persistence metadata. 

Suggestion: Remove the reference to xml.Address from persistence.xml

[java] Exception in thread "main" <openjpa-1.0.0-r420667:568756 nonfatal user error>
org.apache.openjpa.persistence.InvalidStateException:
Encountered unmanaged object "xml.Address@9b2a51" in
persistent field "xml.Order.shipAddress" of managed object "xml.Order@12b3349"
during flush.  However, this field does not allow cascade persist. 
You cannot flush unmanaged objects.
  [java] FailedObject: xml.Address@9b2a51

Suggestion: Make sure you have no @Entity or @Embeddable annotations in xml.Address. The main annotation is @XmlRootElement.

 [java] Exception in thread "main" <openjpa-1.0.0-r420667:568756 fatal general error>
org.apache.openjpa.persistence.PersistenceException:
"xml" doesnt contain ObjectFactory.class or jaxb.index

Suggestion: add a file jaxb.index into your xml package containing all the classes to be persisted as XML: a file containing Address in our case.

VN:F [1.8.1_1037]
Rating: 0.0/10 (0 votes cast)
VN:F [1.8.1_1037]
Rating: 0 (from 0 votes)

Popularity: 19% [?]

3 Comments »

Photoshop filters on GIMP

Tags: ,

For the GIMP users that, like me, keep complaining that Photoshop has so much more filters to do some fancy effects, the agony is over :-)

I just found this today, but it dates back to 2004. There is a GIMP plugin that handles Photoshop plugins. It is called PSPI and it works like a charm on the filters I have tested so far.

Here are the instructions on how to get it working on Windows:

  1. download the binary package from here.
  2. copy the plugin file to “C:\Program Files\GIMP-2.0\lib\gimp\2.0\plug-ins”
  3. start GIMP
  4. click on Menu Xtns -> Photoshop Plug-in Settings
  5. add the folders where you have your photoshop plugins (.exe or .8bf files)
  6. restart GIMP
  7. all the compatible plugins in the folders you specified in step 5 will show up under the Filters menu (*)

This was a new for me, and I’m quite happy as there was a couple of photoshop filters that I like to play with sometimes (just for fun, but still).

(*) For some odd reason, all my plugins appear under the sub-menu “Flaming Pear”, the creators of the first photoshop plugin I loaded into GIMP.

VN:F [1.8.1_1037]
Rating: 0.0/10 (0 votes cast)
VN:F [1.8.1_1037]
Rating: 0 (from 0 votes)

Popularity: 18% [?]

7 Comments »

DB2 on Rails update

Tags: , , , , , , , , , , ,

I’m back to fiddling around with my Ruby on Rails experiments(1)(2). I was able to create a very useful 2-way mapping between Ruby objects and xml data stored in DB2 pureXML. Basically, trying to replicate some of ActiveRecord’s functionality but for XML data. I still find it odd, though, that both ROXML and xml-mapping haven’t had much activity as of late. I’m wondering if there is any new OXM library around that I don’t know of.

Also on the same topic:

  • the main DB2 on Rails website is up and running again, with a revamped design and now using wordpress instead of typo.
  • a new version of the ibm_db driver was also released, containing several bugfixes. Update it through gems (gem update ibm_db) or from here: http://rubyforge.org/projects/rubyibm/ 
VN:F [1.8.1_1037]
Rating: 0.0/10 (0 votes cast)
VN:F [1.8.1_1037]
Rating: 0 (from 0 votes)

Popularity: 17% [?]

No Comments »

DB2 Student Ambassador

Tags: , , ,

After reading Alcides Fonseca’s post regarding is opportunity to become an MSP and asking whether other companies have similar programs, I would like to introduce two programs related with DB2 that are targeted for university students: DB2 On Campus and DB2 Student Ambassador.

DB2 on Campus: The DB2 on Campus Program is a project designed to promote the use of DB2 in universities. The logistics and delivery of the program is performed between the DB2 Express-C team, and the local IBM Academic Initiative representative. The program consists of the following items and activities:

  1. A speech titled “The role of DB2 Express-C in the Information on Demand World”. This speech explains DB2 9 technology, with an emphasis on pureXML™, and encourages students to use DB2 Express-C, create university DB2 user groups, participate in the DB2 forums, and write documents about DB2. All of these activities can help them to advance their future careers.
  2. Introductory DB2 courses to obtain DBA and developer skills.
  3. Free DB2 books donated to the university library
  4. Free DB2 certification exams offered to the students

I will be at University of Minho on September 19th doing the speech for the DB2 on Campus program. There was not enough time to prepare the full-day event, but if you or someone at your university is interested in having this full-day event happening at your university, please feel free to email me and I’ll put you in contact with the program’s manager in order to schedule the event (my email is vrodrig at us.ibm.com).

There is a DB2 On Campus Facebook group. Follow these instructions to join. 

Subscribe to the DB2 Express-C blog to keep updated on news regarding this free to develop, deploy and distribute database(1). 

DB2 Student Ambassador: This is a program for individual students that want to promote the use of DB2 at their education institutions. Though the program is voluntary, it gives students a chance to learn more about DB2, develop presentation skills and marketing skills. All of these skills will be valuable in their careers. At the end of the program, the student will receive a letter of recommendation from IBM including all the details of the activities performed. The more activities performed, the better the letter of recommendation! We hope this will help the student get a job more easily in the future.

I consider this to be an excellent opportunity to get involved and interact with developers from a huge project like DB2, distributed across Toronto and Silicon Valley laboratories.

More information  about this program can be found here: http://www-306.ibm.com/software/data/db2/express/students_programs.html#ambassador

 

Although I’m only familiar with the DB2 programs, for the ones interested, there is also an IBM Academic Initiative program, focused on Open Standars, Open Source and IBM resources for the academic world.

The opportunities are out there, so just grab the one you like and boost your career :-)

(1) Yes, it is the fully loaded version available for free, with one limitation: it can only use up to 4GB of RAM :-)  

 

VN:F [1.8.1_1037]
Rating: 0.0/10 (0 votes cast)
VN:F [1.8.1_1037]
Rating: 0 (from 0 votes)

Popularity: 11% [?]

1 Comment »

XML Mapping in Ruby

Tags: , , , , , , , ,

Dear lazy web…

I’ve been playing with Ruby and XML lately, and one of the key features I need to use is XML mapping from XML to Ruby objects and vice versa. However, both ROXML and XML::Mapping do not seem to be very active at the moment. Both forums contain un-replied questions  several months old, and I can’t find any examples that are not a couple of years old.

Is there any XML Mapping library for Ruby that is currently active(*)? XML::Mapping was serving me good enough, until the moment that I needed some of the documented features and found that they are not supported in the current release :-(

 (*) by active I don’t mean it needs to be in exclusively in code development, but at least with some recent activity in forums, documentation, examples, etc..

VN:F [1.8.1_1037]
Rating: 0.0/10 (0 votes cast)
VN:F [1.8.1_1037]
Rating: 0 (from 0 votes)

Popularity: 10% [?]

4 Comments »

Ruby libxml annoyances

Tags: ,

>> doc.find('/*').first.name
doc.find('/*').first.name
=> "Customer"
>> doc.find('/Customer').first.name
doc.find('/Customer').first.name
NoMethodError: You have a nil object when you didn't expect it!
The error occurred while evaluating nil.name
	from (irb):52

Something is wrong with Ruby’s libxml xpath evaluator. I’m only able to use the wildcard * to select elements and not the element’s name. After doing some research on the project’s page, there are 2 comments about the problem, complaining that libxml’s support of XPath is just too limited and it has lots of problems when dealing with namespaces. Default namespaces are not parsed, namespace wildcards are not supported and namespace prefixes won’t work all the time. What’s the advantage of announcing a 300x faster xpath speed than rexml when it doesn’t work and valid xpath expressions return syntax error?

>> doc.find('/*:Customer').first.name
doc.find('/*:Customer').first.name
XML::XPath::InvalidPath: Invalid XPath expression
	from (irb):73:in `find'
	from (irb):73

It’s time to go back to the slower but working rexml.

VN:F [1.8.1_1037]
Rating: 0.0/10 (0 votes cast)
VN:F [1.8.1_1037]
Rating: 0 (from 0 votes)

Popularity: 9% [?]

2 Comments »