28 Aralık 2010 Salı

revisited: migration from open esb + glassfish to apache tomcat + ode

please see http://hilaltarakci.blogspot.com/2010/03/migration-from-open-esb-glassfish-to.html for prior knowledge about the topic..
i have to migrate our processes from glassfish+open esb to apache tomcat+apache ode..
in this post, i simply note down differences or additions to the above prior post.
first of all, this time, i used latest versions:
  • apache ode : 1.3.4 instead of 1.3.3
  • apache tomcat: 7.0.5 instead of 6.0.24
  • metro: 2.0.1 instead of 2.0
CATALINA_HOME, JAVA_HOME and JRE_HOME environment variables are defined properly.

While installing metro on tomcat, i used the command
ant -f metro-on-tomcat.xml install
and there is luckily no problems due to version changes..

the correct arrangement of web.xml and creation of sun-jaxws.xml under project-home/web/WEB-INF is not straightforward this time, since there is a number of web services deployed in the same .war file. so, i want to explain the details..
here some links:

a small tip: after rewriting web.xml and sun-jaxws.xml, in order to prepare the .war file under dist folder, right click and build the project in netbeans ide.. choosing clean and build results in wiping out sun-jaxws.xml and overwriting web.xml..

a sample web.xml
<?xml version="1.0" encoding="UTF-8"?>

<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<description>Balistika2010Ws</description>
<display-name>Balistika2010Ws</display-name>
<listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>
<servlet>
<description>JAX-WS endpoint - Service1</description>
<display-name>Service1</display-name>
<servlet-name>Service1</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Service1</servlet-name>
<url-pattern>/ode/processes/Service1</url-pattern>
</servlet-mapping>
<servlet>
<description>JAX-WS endpoint - Service2</description>
<display-name>Service2</display-name>
<servlet-name>Service2</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Service2</servlet-name>
<url-pattern>/ode/processes/Service2</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

a sample corresponding sun-jaxws.xml
<?xml version="1.0" encoding="UTF-8"?>

<endpoints xmlns='http://java.sun.com/xml/ns/jax-ws/ri/runtime' version='2.0'>
<endpoint
name='Service1'
implementation='tr.gov.tubitak.service.Service1'
url-pattern='/ode/processes/Service1'/>
<endpoint
name='Service2'
implementation='tr.gov.tubitak.service.Service2'
url-pattern='/ode/processes/Service2'/>
</endpoints>

The url-pattern attributes in web.xml and sun-jaxws.xml should match.

The implementation attribute is the web service itself..

However, tomcat throws the following error:
SEVERE: WSSERVLET11: failed to parse runtime descriptor: javax.xml.ws.WebServiceException: Unable to create JAXBContext
javax.xml.ws.WebServiceException: Unable to create JAXBContext
at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:166)
...
Caused by: java.security.PrivilegedActionException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
javax.persistence.EntityManager is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at javax.persistence.EntityManager
at public javax.persistence.EntityManager tr.gov.tubitak.uzay.balistika2010.sas.service.series.jaxws.MergeAbsEvidGrpsInCase.arg1
at tr.gov.tubitak.uzay.balistika2010.sas.service.series.jaxws.MergeAbsEvidGrpsInCase
javax.persistence.EntityManager does not have a no-arg default constructor.

The error is due to the fact that i pass EntityManager between (public) method calls in order to preserve my transactions.. see this for details: http://hilaltarakci.blogspot.com/2010/12/persistence-using-jpa.html

so, how to fix this? for now, i redesigned the code in such a way that EntityManager passing methods are all defined as private..

in fact, defining problematic methods as private solved some other weird errors as well.. i do not record them, since i did not understand their nature!!

at this point, web services are all deployed successfully and i can see wsdl s..

now the bpel part.. if you do not bind all partner links that is used in mentioned process in deploy.xml, you get the following error:
16:52:58,729 ERROR [NStateLatch] Latch error, was releasing for state 1 but actually in -1
16:52:58,731 WARN [ProcessStoreImpl] Deployment failed within the engine, store undeploying process.
java.lang.IllegalArgumentException: SecurityPL must be bound to an endpoint in deploy.xml
at org.apache.ode.bpel.engine.BpelProcess.setRoles(BpelProcess.java:519)

deploy.xml of ode-home/examples/DynPartner is a good sample..

now, it is time to test deployed processes from a java client.. i created client side artifacts from manually written wsdl in the deployed bpel module, not from the endpoint itself..

when i called the process from the client, i got the following error:

SEVERE: org.objectweb.asm.ClassWriter.(I)V
java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.(I)V
at net.sf.cglib.core.DebuggingClassWriter.(DebuggingClassWriter.java:47)
...
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
at tr.gov.tubitak.uzay.balistika2010.sas.dao.base.BlsEntityManager.getEm(BlsEntityManager.java:20)
at tr.gov.tubitak.service.Service1.method1(Service1.java:116)

no need to say, the process calls a web service which persists data inside a transaction.. according to http://www.myeclipseide.com/PNphpBB2-viewtopic-t-24287.html, the error was due to conflicting asm.jar s around.. actually, i faced the same problem before in a different environment: http://hilaltarakci.blogspot.com/2010/02/javalangnosuchmethoderror.html
in deployed web services library, asm.jar was of version 1.5.3; upgrading it to version 3.3.1 solved the mentioned error..

last update on 29.12.2010, 11:30..

22 Aralık 2010 Çarşamba

using blob field with jpa and web services

In the project, client side has to store local machine specific data in the cenral database and this field has to be binary large object (blob).. Jpa with hibernate is used as orm tool..Unfortunately, according to http://opensource.atlassian.com/projects/hibernate/browse/JPA-8 jpa does not support java.sql.Blob.. Indeed, the following error shows up when i tried to do so:
// bean
import java.sql.Blob;
import javax.persistence.Lob;

class MyClass{
@Lob
@Column(name = "FLD_BLOB")
private Blob myBlob;
...
}

// the error when deployed on Glassfish (jaxws is used for web services)
javax.xml.ws.WebServiceException: Unable to create JAXBContext ...
Caused by: java.security.PrivilegedActionException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
java.sql.Blob is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at java.sql.Blob
at public java.sql.Blob
...
java.sql.Blob does not have a no-arg default constructor.
...
java.sql.Blob is an interface, and JAXB can't handle interfaces.
...

So, use byte [] instead of java.sql.Blob

Web service using the bean with blob field is succesfully deployed and in the wsdl, the blob field is like this:
< xs:element name= " myBlob " type= " xs:base64Binary " minoccurs= " 0 " >
Moreover, when client side stubs are generated, the field is again generated as byte []..

Testing the blob field:
I used the code at http://www.java-tips.org/java-se-tips/java.io/reading-a-file-into-a-byte-array.html in order to prepare test data from a file and the following lines to write back the read bytes into a file to test correctness:

FileOutputStream fos = new FileOutputStream( "blobDataReadFromDB.png");
fos.write(myBean.getMyBlob());

The test data is a 5.4 MB-mp3.

Two test cases are considered.
In the first test case, the web services are treated as applications and tested without deployment. The blob field is successfully persisted and retrieved from database in this case..
In the second test case, web services are deployed and then tested.. The blob data is persisted successfully, but, the following error shows up when trying to retreive the data: (the underlying database is postgresql..)
ERROR org.hibernate.util.JDBCExceptionReporter - Large Objects may not be used in auto-commit mode.
...
sun-org.hibernate.exception.GenericJDBCException: could not execute query at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
....
Caused by: org.postgresql.util.PSQLException: Large Objects may not be used in auto-commit mode.
at org.postgresql.largeobject.LargeObjectManager.open(LargeObjectManager.java:200)

Here is someone in a similar situation: https://forum.hibernate.org/viewtopic.php?f=1&t=994742&start=0 The following answer in this link, worked for me:

You might need to put your DB operations into a transaction:
session.beginTransaction();
...
session.getTransaction().commit();

Normally, retrieve operations do not require a transaction since they leave the database unchanged.. You only use transactions for create, update and delete operations since they change database state.. However, retrieval of blob field require transaction as well, maybe due to paging..

I also used and tested the blob field through a bpel process.. Again, persistence and retrieval is successful..

21 Aralık 2010 Salı

parsing an xml portion (without dom)

My problem is trying to parse an xml portion stored as a string. In trivial case, this is pretty easy by using indexOf() and lastIndexOf() methods, however, when the namespace is dynamic, the problem becomes a little tricky. For instance, when looking for foo, the data may come between
<foo>foo data < /foo> or
<ns1:foo>foo data< /ns1:foo> or
<ns2:foo>foo data< /ns2:foo> and so on..

In my case, i used such a simple solution:

String upToFooPre = fullMessage.substring(0,fullMessage.lastIndexOf("foo&gt ;"));
String upToFoo = upToFooPre.substring(0, upToFooPre.lastIndexOf("&lt ;"));
String foo = upToFoo.substring(upToFoo.lastIndexOf(("&gt ;")) + 4 );



15 Aralık 2010 Çarşamba

changing hibernate log level

In this link, hibernate log level is changed programmatically:
http://stackoverflow.com/questions/847041/how-do-i-change-hibernate-logging-level

I adopted this way..

Logger.getLogger("org.hibernate").setLevel(Level.ERROR);

However, as the link says, this solution makes you dependent on the logger implementation.

14 Aralık 2010 Salı

How to generate JAX-WS Client classes that implement the Serializable interface

The serializable interface vanishes when client side stubs are generated using jax ws..

Here is a solution to keep serializable interface:

There is also a plugin solution:

However, the binding file i previously used for XMLGregorian Calendar vs Date issue worked for that, too.. So, i stick to it:
For details, please see the previous post:

a correction may require in wsdl files if this error comes up:
[ERROR] XPath evaluation of "wsdl:definitions/wsdl:types/xsd:schema" results in too many (8) target nodes

<xsd:schema>
<xsd:import namespace="http://..." schemaLocation="http://...Service?xsd=1"></xsd:import>
</xsd:schema>
<xsd:schema>
<xsd:import namespace="http://..." schemaLocation="http://...Service?xsd=2"></xsd:import>
</xsd:schema>
<xsd:schema>
<xsd:import namespace="http://..." schemaLocation="http://...Service?xsd=2"></xsd:import>
</xsd:schema>

edit as follows, so it contains exactly one xsd:schema element:

<xsd:schema>
<xsd:import namespace="http://..." schemaLocation="http://...Service?xsd=1"></xsd:import>
<xsd:import namespace="http://..." schemaLocation="http://...Service?xsd=2"></xsd:import>
<xsd:import namespace="http://..." schemaLocation="http://...Service?xsd=2"></xsd:import>
</xsd:schema>

13 Aralık 2010 Pazartesi

persistence using jpa

I have one database, but the atomicity of transactions is large. In other words, many entities must be manipulated in one transaction. Therefore, the design is something like that:
  • a general superclass entity that holds shared stuff amongst all other entities that are subject to be persisted.
  • an entity manager class that is responsible for creation of emf and em.
  • a general dao for the superclass mentioned above, to accomplish shared, general persistence tasks (crud operations - create, retrieve, update, delete ). The entity class type and an entity manager is injected to this dao.
  • specific dao classes for entities that needs operations other than crud. Something to note down is that since transaction management must be done in an upper layer in this case, no begin, commit or rollback transaction operation appear at dao (persistence) layer.
// general superclass
@MappedSuperclass
public class MyBean implements Serializable {

@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private Long id = -1L;
// ...
}

//////////////////////////////////////////////////////////////
// a specific class
public class SpecificBean extends MyBean {
// ...
}

//////////////////////////////////////////////////////////////
// entity manager class
public class MyEntityManager {

private static final String PERSISTENCE_UNIT = "MyPU";

@PersistenceUnit(unitName = PERSISTENCE_UNIT)
private EntityManagerFactory emf;

public EntityManager getEm() {
if (emf == null) {
emf = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT);
}
return emf.createEntityManager();
}
}

//////////////////////////////////////////////////////////////
// general dao for superclass MyBean
public class MyBeanDao {

private Class clazz;
protected EntityManager em;

public MyBeanDao(Class clazz, EntityManager em) {
this.clazz = clazz;
this.em = em;
}

public void create(MyBean bean) {
em.persist(bean);
}

public MyBean retrieve(Long id) {
return (MyBean) em.find(this.clazz, id);
}

public void remove(Long id) {
MyBean bean = retrieve(id);
if (bean != null) {
em.remove(bean);
}
}

public MyBean update(MyBean bean) {
MyBean updated = em.merge(bean);
return updated;
}

public void closeEm() {
em.close();
}

public void initTransaction() {
em.getTransaction().begin();
}

public void finishTransaction() {
em.getTransaction().commit();
}

public void rollbackTransaction() {
em.getTransaction().rollback();
}
}

//////////////////////////////////////////////////////////////
// specific dao classes
public class SpecificDao extends MyBeanDao {

public SpecificDao (EntityManager em) {
super(SpecificBean.class, em);
}
// extra methods
}

//////////////////////////////////////////////////////////////
// sample call

MyEntityManager mem = new MyEntityManager ();
EntityManager em = mem.getEm();

SpecificDao dao = new SpecificDao (em);

dao.initTransaction();
// do something
// ....
dao.finishTransaction();



more effective solutions may exist.. this is just a sample design..

11 Aralık 2010 Cumartesi

object cloning in java

java objects are manipulated via reference variables, there is no way to copy an object in java directly.. clone() method of Object class is used to provide a standard copying mechanism. clone() returns an Object, so dont forget to recast..
There is also the shallow copy - deep copy issue to deal with.. In shallow copy only the surface portion of the object is copied, as in the case of Arraylist s overrided clone().
A property of shallow copies is that fields that refer to other objects will point to the same objects in both the original and the clone. (http://javatechniques.com/blog/faster-deep-copies-of-java-objects/)
Copying the object entirely is the deep copy..
In order to make a class with the ability of deep copying itself:
  • default clone() implementation throws CloneNotSupportedException (if class is not implementing Cloneable interface)
  • implement Cloneable interface
  • make overrided clone() implementation public and do super.clone() (as in all Collections clone() methods)
  • Object s clone() only makes shallow copy, so write your implementation for a deep copy..

  • public class SampleClass implements Cloneable {
    ...
    public Object clone() throws CloneNotSupportedException {
    return super.clone();
    }
    }

    Serializing and reconstructing when the object is extremely complex, is also a solution to deep copying problem.. Besides, in http://javatechniques.com/blog/faster-deep-copies-of-java-objects/, the code presents a faster way of making deep copy..

    http://www.go4expert.com/forums/showthread.php?t=5424
    http://www.jguru.com/faq/view.jsp?EID=20435 (this is the solution i used, since i have complex serializable objects..)

    7 Aralık 2010 Salı

    WS-SecureConversation and WS-Atomic Transaction

    In our project, we needed a way to provide security in an efficient way and WS-Security is a bit heavy and inefficient.
    We have found a great WSIT tutorial and decided to use WS-SecureConversation which is almost twice faster than WS-Security according to our tests (tests carried out calling a simple web service 10000 times).
    The link to tutor: http://download.oracle.com/docs/cd/E17802_01/webservices/webservices/reference/tutorials/wsit/doc/index.html
    and pdf version is at http://download.oracle.com/docs/cd/E17802_01/webservices/webservices/reference/tutorials/wsit/doc/WSITTutorial.pdf

    We also need to manage transactions and worked on WS-AT by using the sample at http://wiki.open-esb.java.net/Wiki.jsp?page=HTTPBCWSAtomicTransaction which is linked from http://wiki.open-esb.java.net/Wiki.jsp?page=UsingWSTransaction

    However, our client is not a j2ee, so WS-AT is not appropriate for such an environment (http://java.net/jira/browse/WSIT-526)

    Now, our direction is to handle transactions in bpel processes themselves.. i will write about it, when we discover something.. a starting point : http://wikis.sun.com/display/JavaCAPS/Transactionality+-+BPEL2.0+SE
    And, a summary of the wsit tutorial i mentioned above, will be one of the next posts..

    25 Ekim 2010 Pazartesi

    error: PSQLException: FATAL: sorry, too many clients already

    the error is:

    aused by: org.hibernate.exception.GenericJDBCException: Cannot open connection
    at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
    at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:426)
    at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
    at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:119)
    at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
    at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
    at org.hibernate.ejb.TransactionImpl.begin(TransactionImpl.java:38)
    ... 64 more
    Caused by: org.postgresql.util.PSQLException: FATAL: sorry, too many clients already
    at org.postgresql.core.v3.ConnectionFactoryImpl.readStartupMessages(ConnectionFactoryImpl.java:464)
    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:112)
    at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
    at org.postgresql.jdbc2.AbstractJdbc2Connection.(AbstractJdbc2Connection.java:125)
    at org.postgresql.jdbc3.AbstractJdbc3Connection.(AbstractJdbc3Connection.java:30)
    at org.postgresql.jdbc3g.AbstractJdbc3gConnection.(AbstractJdbc3gConnection.java:22)
    at org.postgresql.jdbc4.AbstractJdbc4Connection.(AbstractJdbc4Connection.java:30)
    at org.postgresql.jdbc4.Jdbc4Connection.(Jdbc4Connection.java:24)
    at org.postgresql.Driver.makeConnection(Driver.java:393)
    at org.postgresql.Driver.connect(Driver.java:267)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:154)
    at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
    at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
    ... 69 more


    see http://stackoverflow.com/questions/220374/do-i-have-to-close-every-entitymanager

    13 Ekim 2010 Çarşamba

    22 Temmuz 2010 Perşembe

    logging in java apps

    for starter, lets begin with java.util.logging..

    http://www.java-tips.org/java-se-tips/java.util.logging/how-to-use-logger.html
    http://www.rgagnon.com/javadetails/java-0501.html
    http://www.roseindia.net/java/example/java/util/quintessential-logging-program.shtml

    and log4j..
    http://logging.apache.org/log4j/1.2/manual.html
    http://www.basilv.com/psd/blog/2006/tips-for-using-log4j
    http://homepage.mac.com/kelleherk/iblog/C1837526061/E2136921646/index.html

    the interface:

    package org.apache.log4j;

    public class Logger {

    // Creation & retrieval methods:
    public static Logger getRootLogger();
    public static Logger getLogger(String name);

    // printing methods:
    public void trace(Object message);
    public void debug(Object message);
    public void info(Object message);
    public void warn(Object message);
    public void error(Object message);
    public void fatal(Object message);

    // generic printing method:
    public void log(Level l, Object message);
    }

    23 Haziran 2010 Çarşamba

    Error : Java Web service. Unable to create JAXBContext

    if you get the following error while deploying the web service:

    Exception occured in the wsgen process javax.xml.ws.
    WebServiceException: Unable to create JAXBContext build-impl.xml

    it is probably because of a class with both publicly accessable members and getters/ setters..
    If you make the members privately accessable or delete getter/setter methods, the error will be fixed:
    see this: http://stackoverflow.com/questions/1198462/problem-with-java-web-service-unable-to-create-jaxbcontext

    19 Nisan 2010 Pazartesi

    a paper on owl

    please see http://hilaltarakci.blogspot.com/2010/04/protege.html
    link to a related paper: http://www.co-ode.org/resources/papers/ekaw2004.pdf
    nice exercises: http://dig.csail.mit.edu/2010/LinkedData/Presentations/Session3-ontology.pdf

    12 Nisan 2010 Pazartesi

    protege

    For prior basic information see http://hilaltarakci.blogspot.com/2010/04/introduction-to-ontology-development.html...
    Protege 4.1
    can be downloaded from http://protege.stanford.edu/download/registered.html or http://www.co-ode.org/downloads/protege-x/ .
    OWL plugins for protege 4.0 are at http://www.co-ode.org/downloads/protege-x/plugins/ .
    And an extended tutorial to follow can be found at http://owl.cs.manchester.ac.uk/tutorials/protegeowltutorial/resources/ProtegeOWLTutorialP4_v1_2.pdf .

    Installing OWL plugins is just copying the plugin jar under Protege4.1-Home/plugins folder.

    In this post, i aim to note down some basic issues from the tutorial i linked above.

    The terminology mapping between protege frames and owl ontologies is as follows:

    protege frame :
    instances, slots, classes
    owl ontology : individuals, properties, classes

    individuals: represents objects in domain, instances of classes.
    properties: binary relations on individuals. They can have inverses (for example hasOwner and isOwnedBy are inverse properties to each other). There are two main types of properties: Object properties and Datatype properties. In owl, there is also Annotation properties. The following figure is taken from the tutorial linked above:

    Properties also form a taxonomy. In other words, properties form a hierarchy, some properties are subproperties (or superproperties) of some other properties (hasMother is a subproperty of hasParent object property). However, it is not possible to create a hierarchy between different types of properties ( for example an object property can not be subproperty(or superproperty) of a datatype property.)

    Properties can have various characteristics:

    Functional Properties (Features):
    In a functional property, there can be only one individual that can be related to the individual via the property. In the tutorial, there is a good example:

    Inverse Functional Properties: The inverse property is functional.

    Transitive
    Properties: If individual a is related to individual b and individual b is related to individual c via property P, then it can be inferred that individual a is related to individual c via property P.

    Inverse property of a transitive property is also transitive.
    Transitive property can not be functional.

    Symmetric Properties: If individual a is related to individual b via property P, then it can be inferred that individual b is related to individual a via property P.



    OWL-DL does not allow data type properties to be transitive, symmetric or has inverse properties.

    Anti-Symmetric Properties: If individual a is related to individual b via property P, then it can be inferred that individual b can not be related to individual a via property P.


    Reflexive Properties: Property P relates individual a to itself.


    Irreflexive Properties: Property P can not relate individual a to itself.


    Properties may have domains and ranges. They attach individuals from the domain to individuals from range.



    In OWL, domains and ranges are not constraints. On the contrary, when an individual which is not explicitly stated to be in the range is linked via the property, then that individual is inferred to be a subclass of the range.


    data type properties: link an individual to an XMLSchema Data type value or an rdf literal. In other words, they describe relationships between an individual and data values.


    classes: interpreted as sets that contain individuals. Classes may be
    organised into a superclass-subclass hierarchy forming a taxonomy (for example Animal is superclass of Cat). In order to relate two classes in a hierarchy, subclass must be a kind of (or is-a) superclass. In the Animal-Cat example, Cat is a kind of (or is-a) Animal, therefore the hierarchy is correct.


    restrictions: The definition of restriction is:



    .. and some restriction examples are:


    Owl restrictions are:
    • Quantifier Restrictions (existential, universal)
    • Cardinality Restrictions
    • hasValue Restrictions
    Existential Restrictions (someValuesFrom Restrictions (protege keyword is some))):An existential restriction describes a class of individuals that have at least one (some) relationship along a specified property to an individual that is a member of a specified class.




    Universal Restrictions (AllValuesFrom Restrictions- (protege keyword is only)):They constrain the relationships along a given property to individuals that are members of a specific class. For example the universal restriction ForAll hasTopping MozzarellaTopping describes the individuals all of whose hasTopping relationships are to members of the class MozzarellaTopping— the individuals do not have a hasTopping relationships to individuals that are not members of the class MozzarellaTopping.


    Following the tutorial, i created a sample Pizza ontology by opening protege and selecting Create New OWL Ontology option.

    Active Ontology Tab: In this tab, the metadata about the ontology itself is defined. For instance, i added a comment about the ontology under Annotations frame.



    Classes Tab: In this tab, classes can be added to the ontology and the taxonomy is formed while adding classes via Add Subclass and Add Sibling buttons. Besides, some relationships between classes are also formed: for instance disjoint classes can be marked.

    In the sample Pizza ontology, there exist three sibling classes: Pizza, PizzaTopping and PizzaBase which are all disjoint classes. In other words, an individual can only belong to one of these classes. It is enough to specify disjoint classes on one of the classes, the others will be automatically defined.

    Also, using Tools/Create class hierarchy is an easy way to create a class hierarchy and making them disjoint. It is also possible to define a common prefix or suffix for the classes entered via this tool. Hierarchy can be represented with a tab as follows:



    After class definitions, the taxonomy seems as follows:



    In this tab, it is also possible to define restrictions by selecting the class, adding a superclass by using class expression editor. This is just one possible way.. The editor luckily has auto-complete property. Edit/Duplicate selected classes is an efficient way to clone the selected class.





    Object/Data Properties Tab: In this tab, the object/data properties, their domains and ranges and the relationship between them can be modeled.





    Individuals Tab:


    Reasoners (Classifiers): Ontologies described with OWL-DL can be processed by reasoners. A reasoner can generate an inferred ontology from an asserted ontology(the originally given ontology) and decides if the ontology is consistent. If any class in the ontology could not take any instances, this means inconsistency. There are a variety of reasoners: Hermit, Fact++, Pellet and so on..
    Running reasoner on the asserted ontology is known as classifying the ontology. Prior to classifying the ontology a probe class is defined as subclasses of disjoint classes in order to check the inconsistency.


    Necessary Conditions (Superclasses):If something is a member of the class then it is necessary to fulfil its necessary conditions. The reverse may not be correct (The members that fulfil the necessary conditions may not belong to that class).
    Necessary and Suffucient Conditions(Equivalent Classes):If something is a member of this class then it is necessary and sufficient to fulfil these conditions. The reverse is also correct (All members that fulfil the necessary and sufficient conditions belong to that class).
    Primitive Class: A class that only has necessary conditions.

    Defined Class: A class that has at least one set of necessary and sufficient conditions.

    In protege a primitive class can be converted to a defined class by Edit/Convert to defined class..

    Defined classes are preferrable whereever you can, since reasoners can reason over them.




    Open World Assumption (OWA):


    Closure Axiom: A closure axiom on a property consists of a universal restriction that acts along the property to say that it can only be filled by the specified fillers. The restriction has a filler that is the union of the fillers that occur in the existential restrictions for the property.



    Value Partition: This has nothing to do with OWL, it is a desig pattern. The steps are as follows:

    Covering Axiom:


    Cardinality Restrictions:

    Complement Class: A complement class contains all of the individuals that are not contained in the class that it is the complement to. If NonVegetarianPizza is created as a subclass of Pizza and made the complement of VegetarianPizza, it should contain all of the Pizza s that are not membersof VegetarianPizza.

    Enumerated Classes:




    Note: Usage of OWLViz plugin requires installation of GraphViz.OWLViz plugin come bundled with Protege 4.. After installing GraphViz, the dot file under GraphViz-home/bin/dot.exe should be set from File/Preferences/OWLViz tab in Protege. http://protegewiki.stanford.edu/wiki/OWLViz#Installation

    Note: Everything in this post, every figure, definition and etc. is taken from the document at
    http://owl.cs.manchester.ac.uk/tutorials/protegeowltutorial/resources/ProtegeOWLTutorialP4_v1_2.pdf .
    I just aimed to give a compact summary of that tutorial.

    Last update on 16/4/2010 10:57

    9 Nisan 2010 Cuma

    introduction to ontology development

    At work, during preperation of a conference paper related to semantic web, i luckily had a chance to use protege for ontology development.. Protege (http://protege.stanford.edu/) is an ontology editor and knowledge acquisition system. In this series of posts, i write down my experience of using protege as an ontology editor..
    The paper at http://protege.stanford.edu/publications/ontology_development/ontology101.html proposes a methodology for developing an ontology. According to that paper, the domain and scope of the ontology should be defined properly before the design phase. After that, ontologies that have been developed so far in that domain should be checked. Using previous ontologies provides compatibility with applications using that ontology. Then the next step is writing down all the terms you can think of related to the concerned domain. Those terms are than examined and determined if they are classes or not. The terms that are decided to be classes are organized in a hierarchy with one of top-down, bottom-up approaches or a combination of them. Then, the slots are determined by using the generated class hierarchy and previously written and marked as not-class terms. The slots have domains and ranges and facets(restriction) can be defined on them. Afterwards, instances are created and the knowledge base is so close to be complete. However, ontology development is an iterative work and some of these steps should be carried out over and over in order to catch the balance: the developed ontology should be neither too generic nor too specific.
    I will continue with new posts focusing on more specific issues and usage of protege.

    6 Mart 2010 Cumartesi

    migration from open esb + glassfish to apache tomcat + ode

    In our project, we develop web services using jax-ws and deploy them to glassfish v2 coming with netbeans 6.5 ide. btw, we installed netbeans 6.5 with open esb selected, since we use it for our bpel s. Bpels are also deployed to the same glassfish as web services. Development and deployment are quite easy and fast. However, when we ran all the bpels one after the other during unit tests, the server seems to be very slow and after a few runs out of memory error comes up.. we tried to configure glassfish, but it did not work as we expected.. (the database is postgresql, but currently this is irrelevant.)

    So, now i want to deploy web services and bpels to apache-tomcat-6.0.24 + apache-ode-war-1.3.3 just to see what happens.. (in order to deploy ode to tomcat, just download the zip files, extract them and copy ode.war under webapps folder of tomcat and start tomcat..)
    Now, lets follow the migration step by step..

    The first step is deploying war of web services generated by netbeans (under dist folder of the project) to tomcat. So, i just copied the war file under tomcat-home/webapps and restarted the server. As i expected, the deployment seemed successful in terms of a regular web application, however it can not process the web services since no wsit runtime is installed on tomcat. (in other words, i can not see the wsdl..) In order to fix this, we have to install metro on tomcat.. a helpful link is http://blog.theunical.com/webservers/tomcat/installation-and-configuration-of-jax-ws-metro-on-tomcat-6/
    following the link,
    • i downloaded and unzipped metro 2.0,
    • edited tomcat-home/conf/catalina.properties by replacing shared.loader= line with shared.loader=metro-home/lib/*.jar,
    • set CATALINA_HOME environment variable with the command export CATALINA_HOME=path to tomcat-home and chech with echo $CATALINA_HOME
    • run the command ant -f metro-on-tomcat.xml from metro-home
    changes in web service project (generated in netbeans ide as netbeans project):
    we have to modify web.xml and add sun-jaxws.xml under project-home/web/WEB-INF in netbeans project. actually, i got help from fromjava example of metro samples package for figuring out how to change the configuration files.
    • in web.xml, add servlet definitions and in sun-jaxws.xml modify endpoint definitions accordingly..
    • build the project in netbeans and copy the war under project-home/dist folder to tomcat-home/webapps folder for deployment.
    now, you should see the wsdl at the endpoint you specified in sun-jaxws.xml.

    At this point, we have deployed web services successfully, and now is the time to deploy the bpels..

    Bpel files and the corresponding wsdl are collected under a bpel module of netbeans ide.
    The major necessity is a deploy.xml. Get one from ode-home/examples folder and copy under bpel-module-home. i used the one from sample HelloWorld2.
    here is some info about ode deployment descriptor: http://ode.apache.org/creating-a-process.html

    After modifying deploy.xml, clean and build the netbeans bpel module.
    Before deploying your actual bpel module under tomcat-home/webapps/ode/WEB-INF/processes folder, you may want to try one of the samples coming with ode package just to see if it is working on its own samples.. It is good to note that the bpels i am about to deploy are using the above deployed web services..

    Now, lets try to note down what i have to change:
    • some minor namespace errors come up, but they were easy to solve, just read the error log in tomcat-come/logs/catalina.out file.
    • the major restriction is it forced all endpoint addreses to format http://hostname:port/ode/processes/myProcessEndpointName for example http://localhost:8080/Balistika2010Ws/ode/processes/SeriesServiceService?wsdl and http://localhost:8080/ode/processes/AddParameter?wsdl are both valid endpoints..
    now, build the bpel module in netbeans and make sure thedeploy.xml is under build folder, if it is not, copy it manually and copy the build folder under tomcat-home/webapps/ode/processes . you may want to rename the folder build with a more meaningful name.
    now, check http://localhost:8080/ode/processes.html. If successful, the process must be seen at that address..
    An important point is the wsdls for bpels are generated with axis2 anymore because of ode, not jaxws..

    Some errors due to the differtence between bpel engines might arise.. For instance i got the following error from my previosly working bpel:

    javax.xml.ws.soap.SOAPFaultException: axis2ns62:selectionFailure
    at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)
    at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:111)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
    at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107)
    at $Proxy33.lightLoginWsdlOperation(Unknown Source)
    at odebpelclient.Main.main(Main.java:28)

    Here is a discussion about the problem: http://mail-archives.apache.org/mod_mbox/ode-user/200810.mbox/%3Cfbdc6a970810200738i75692ac6qb47d3263e9aefe1c@mail.gmail.com%3E
    Ode does not automatically initialize the variables, since this is not part of the standard.. This might be an extension provided by Open Esb.. So, lets initialize all the variables and redeploy..

    i end this post here, i think the point is clear..

    Note: btw, x-home in italics means the location where x is installed.

    Edit on 8/3/2010, 14:08:
    i get the following error when i called one of the bpels from client:

    from server log:
    DEBUG - GeronimoLog.debug(66) | Fault response message: {http://docs.oasis-open.org/wsbpel/2.0/process/executable}uninitializedPartnerRole

    from client log:
    javax.xml.ws.soap.SOAPFaultException: axis2ns6:uninitializedPartnerRole
    at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)
    at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:111)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
    at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107)
    at $Proxy33.lightLoginWsdlOperation(Unknown Source)
    at odebpelclient.Main.main(Main.java:28)

    himm, that error was due to a mistake in deploy.xml of bpels.. i had to use keyword invoke instead of provide for invoked web services. So, for writing deploy.xml file, ode-home/examples/DynPartner maybe a better example than HelloWorld2.
    and besides, check the existence of initializePartnerRole=yes attribute, when partnerRole exists in partner link.
    That solution worked for me :)

    Edit on 10/3/2010, 11:37:
    in our case, we want to write bpel s that works both with ode and open esb. Here is an example variable initialization that works with both:

    <copy>
    <from>
    <literal>
    <ns1:authorizeUserResponse>
    <ns1:return> </ns1:return>
    </ns1:authorizeUserResponse>
    </literal>
    </from>
    <to variable="AuthorizeUserOut" part="parameters"/>
    </copy>

    btw, the empty string between returns is necessary..