javax.xml.bind.JAXBElement unmarshal error

By W.ZH Apr 2011


When I use JAXB 2.0 to unmarshal an XML to a java Object, I get an error that :

java.lang.ClassCastException: javax.xml.bind.JAXBElement cannot be cast to

the code is sth like this :

JAXBContext jc = JAXBContext.newInstance(“”);

Unmarshaller u = jc.createUnmarshaller();

MyJavaObj jo = (MyJavaObj) u.unmarshal(new StreamSource(new StringReader(“myxml.xml”)));


In infct when i run this kind of code when using jaxb 1.0 , i do not get any error, but later when i update my XML xsd schema and try to generate a set of new JAVA obj by new xsd, I use the JAXB 2 to do that, so my unmarshal get this error, reason is that JAXBElement  in fact contain the obj in its value, i need a layer more to convert this XML to Java Obj.


JAXBContext jc = JAXBContext.newInstance(“”);

Unmarshaller u = jc.createUnmarshaller();

MyJavaObj jo = (MyJavaObj) ((
JAXBElement) u.unmarshal(new StreamSource(new StringReader(“myxml.xml”)))).getValue()

Important Business Rule Tips – 11g

By W.ZH Apr 2011After palying with Business Rules of SOA Suite for several weeks and consulting with SOA team people, I think there are some very important notes I must write down for the future usages,  at least to the current latest version – version SOA Suite.

1. You can create a SOA composite application (from Jdev) and use the Decision Component to insert a Business Rule into your BPEL process, and in this design time, you can create ruleset and rule. the link point of the BPEL to this Decision Component, in fact is to invoke the Decision Function in the Business Rule. I call the rules here as the “Rules in SOA space”,

2. You can also use jdeveloper to create a pure Business Rule without sitting in any SOA composite applications. Then you can deploy this rule (sitting in a web app) , into weblogic server, I call this rule as “Rule in Normal space”. There is abit sample tutorials from oracle show how to do this. (like the Grades sample)

3. To mange the runtime things for the “Rules in SOA space”, Oracle has a SOA Composer web UI deployed with SOA Suite to let you can do this. you can open any rules of “Rules in SOA space” and change its runtime info. (Such as ruleset, rules and facts. ) But this SOA Composer can not open any “Rule in Normal space”.

4. For “Rule in Normal space”, in fact after deployed, in some extent, you can not see them. You can use Business Rule JAVA API to access them, open and run them. By this way, you can  call the “Rule in Normal space” from a servlet or from any java program. but this set of Business Rule JAVA API can not open “Rules in SOA space”. This point is very very important.

5. For “Rule in Normal space”, after it can run, if you want to have a UI to change the runtime for them, you can use the taskflow to do that. But you need to build by your self, oracle in fact supply several taskflow to let you can build the SOA composer by yourself , in the SOA dev guide. But these taskflow still can not open the “Rules in SOA space”, as taskflow  internally still use the Business Rule JAVA API.

6. Rule dictionaries are deployed to the MDS partition specified when the application is deployed.
If you export the MDS (Can be done from EM console), unzip it , you will see the rule dictionary located in different domain for the “Rule in Normal space” and “Rules in SOA space”. This can help undertand more clearly of point 4 and 5.

7. For “Rules in SOA space”, you can monitor the SOA/BPEL instances from EM web UI of weblogic, you also can check each  Business Rule ‘s instanes from SOA infrastructure. to see which ruleset is triggered, and to see what input and out put that rule interact with the BPEL who calls the Rule.

8. For “Rule in Normal space”, you can not monitor their instances from EM, So need to take a look the Business Rule JAVA API, it has some API for status and instances check, based on that I think you can develop some web UI by self, to do some basic monitoring for the “Rule in Normal space”.