Posts

Reading Files From JAR - Maven Project

ClassLoader loader = getClass().getClassLoader(); in = loader.getResourceAsStream("templates/"+templateType.getValue()+".xml"); where the template is stored in a maven project as in Src--> main--> resources-->templates-->template.xml

Unsupported major.minor version For Jar

This is Usually caused by the Build version Conflicts. Check if the jar build and consumed JDK are same.

programmatically check thread lock in Multi Threaded Environment.

This Code below can check for thread locks in a concurrent environment. this code needs to be executed by a Deamon or Timer task.                 ThreadMXBean tmx = ManagementFactory.getThreadMXBean(); long[] ids = tmx.findDeadlockedThreads(); if (ids != null)                  { ThreadInfo[] infos = tmx.getThreadInfo(ids, true, true); LOG.fatal("********************************************The following threads                          are deadlocked:**************************************"); for (ThreadInfo ti : infos)                         { LOG.fatal(ti); } LOG.fatal("************************************************************                        ********************************...

Jaxb not adding the @XMLRoot element.

There are those cases where you are trying to build an object Model from XSD and sees that there is no @XMLRootElement tag added to the root element in the stub and your unmarshelling starts failing. The    basic idea is that if we can statistically guarantee that a complex type won't be used by multiple different tag names, XJC put @XmlRootElement.  Try for the basic schema  http://www.w3schools.com/schema/  here. You see the root element gets generated. The issue happens when you have something like this <schema>   <element name = "Employee" type = "inc:CTEmployee" />   <complexType name = "CTEmployee" /> </schema>   You see the Employee element is not tagged with the @XMlRootElement in the stub. The Assumption that XJC does is  that  "your schema might be used by other schema's that XJC isn't compiling right now" . So basic fix is avoid doing the Complex type defined ou...

IE6 and IE7 Specific CSS

#element { color : #999 ; /* shows in all browsers */ * color : #999 ; /* notice the * before the property - shows in IE7 and below */ _ color : #999 ; /* notice the _ before the property - shows in IE6 and below */ }

JSF Composite Component

"cc" is a predefined variable and stands for Composite Component.It Reffers to the Top Level Component in component file UINaming Container. Main Property is " attrs " contains a Map of all the properties.Some of the other attributes parents children clientId  Use the “type” attribute of composite:attribute to hook the element(s) to bean properties       <composite:attribute name="value" required="true" type="coreservlets.Nameable"/> To Create the Backing Bean for the Custom Component Following Steps are important 1. Define the @FacesComponent("full class name") - This Defines the component which is newly created. 2. If Input Component UIInput must be extended and "NamingContainer" should be implemented. 3. Override getFamilyMethod as                            public String getFamily()                         ...

XML Schema Demistyfied

DTD's have limited namespace support so they are not used for webservice schema. Xml Schema is used to implement webservices. The Elements of XML Schema --------------------------- <xs:schema> the schema element is the root element.It can contain more attributes. Eg:  <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com" elementFormDefault="qualified"> ... ... </xs:schema> xmlns:xs="http://www.w3.org/2001/XMLSchema" this specifies that the elements and datatypes are coming from "http://www.w3.org/2001/XMLSchema"name space and also these elements and datatypes must have a prefix xs. This need not be xmlns:xs alone it can be xmlns:xsd or any name. targetNamespace="http://www.w3schools.com" indicates that the elements defined by this schema comes from the namesp...