How to open ADOC (*.adoc) file?

On July 1, 2014, in Uncategorized, by Kishore Chintoju

ADOC format represents file format called Ascii Doc.

It’s similar to humar readable editable markup formats such as Markdown.

More information at

http://www.methods.co.nz/asciidoc/userguide.html

Online viewer and editor at

http://www.compileonline.com/try_asciidoc_online.php

 

Ever seen this. This usually happens when the db column in question is not a BLOB.

In my case, the column was a CLOB. You wouldn’t think it should work, but it doesn’t.


Caused by: java.sql.SQLException: Invalid column type: getBLOB not implemented for class oracle.jdbc.driver.T4CClobAccessor
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:113) ~[ojdbc14-10.2.0.5.0.jar:Oracle JDBC Driver version - "10.2.0.5.0"]
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:147) ~[ojdbc14-10.2.0.5.0.jar:Oracle JDBC Driver version - "10.2.0.5.0"]
at oracle.jdbc.driver.Accessor.unimpl(Accessor.java:359) ~[ojdbc14-10.2.0.5.0.jar:Oracle JDBC Driver version - "10.2.0.5.0"]
at oracle.jdbc.driver.Accessor.getBLOB(Accessor.java:1301) ~[ojdbc14-10.2.0.5.0.jar:Oracle JDBC Driver version - "10.2.0.5.0"]
at oracle.jdbc.driver.OracleResultSetImpl.getBLOB(OracleResultSetImpl.java:1281) ~[ojdbc14-10.2.0.5.0.jar:Oracle JDBC Driver version - "10.2.0.5.0"]
at oracle.jdbc.driver.OracleResultSetImpl.getBlob(OracleResultSetImpl.java:1467) ~[ojdbc14-10.2.0.5.0.jar:Oracle JDBC Driver version - "10.2.0.5.0"]
at oracle.jdbc.driver.OracleResultSet.getBlob(OracleResultSet.java:1979) ~[ojdbc14-10.2.0.5.0.jar:Oracle JDBC Driver version - "10.2.0.5.0"]
at org.apache.commons.dbcp.DelegatingResultSet.getBlob(DelegatingResultSet.java:565) ~[commons-dbcp-1.4.jar:1.4]
at org.apache.commons.dbcp.DelegatingResultSet.getBlob(DelegatingResultSet.java:565) ~[commons-dbcp-1.4.jar:1.4]
at org.hibernate.type.descriptor.sql.BlobTypeDescriptor$5.doExtract(BlobTypeDescriptor.java:115) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:254) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:250) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:230) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:331) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2283) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1527) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1455) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
at org.hibernate.loader.Loader.getRow(Loader.java:1355) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:611) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
at org.hibernate.loader.Loader.doQuery(Loader.java:829) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
at org.hibernate.loader.Loader.loadEntity(Loader.java:2037) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
... 17 common frames omitted

 
java.lang.IllegalStateException: No active session context
at org.jboss.seam.security.Identity.instance(Identity.java:157)

Have you ever seen this error while trying to use seam services from within an MDB. This is because MDB invocations do not have any seam contexts or session initialised as these requests are initiated by the server and are not coming through Seam/Identity filters.

A quick solution for this would be have an EJB interceptor which would take care setting up Seam for you. This would intialize seam context before your onMessage call and end it after it.

package com.example.security.mdb;

import java.util.HashMap;
import java.util.Map;

import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;
import javax.jms.Message;
import javax.jms.ObjectMessage;
import javax.security.auth.login.LoginException;

import org.jboss.seam.Component;
import org.jboss.seam.contexts.Lifecycle;
import org.jboss.seam.log.Log;
import org.jboss.seam.log.Logging;

import com.hrx.rasp.ejb.signon.RaspIdentity;
import com.hrx.rasp.security.RaspSessionServiceLocal;

public class MDBSeamSecurityInterceptor
{
	private Log logger = Logging.getLog(MDBSeamSecurityInterceptor.class);

	@AroundInvoke
	public Object onMessageInterceptor(InvocationContext ctx) throws Exception
	{
		Map<String, Object> session = new HashMap<String, Object>();
		Map<String, Object> appCtx = new HashMap<String, Object>();
		try
		{
			Lifecycle.beginSession(session, appCtx);
			Lifecycle.beginCall();

			if (ctx.getMethod().getName().equals("onMessage"))
			{
				logger.debug("onMessage method intercepted");

                                //e.g. optional seam identiy initialisation
                                RaspIdentity identity = RaspIdentity.getInstance();
               			identity.setSessionId(sessionId);
		        	identity.getCredentials().setUsername("dummy");
			        identity.getCredentials().setPassword("dummy");
	        		identity.authenticate();

			}

			return ctx.proceed();
		}
		catch (Exception e)
		{
			logger.fatal("failing to authenticate MDB with seam identity", e);
			throw new RuntimeException(e);
		}
		finally
		{
			Lifecycle.endCall();
		}

	}

}

 

Exception starting filter Seam Filter java.lang.ClassCastException: org.jboss.seam.servlet.SeamFilter cannot be cast to javax.servlet.Filter

Ever notice this error when deploying your application with Seam.

This usually happens due to two reasons.

  • You have duplicate seam jars in your application (e.g. EAR/lib and WAR/WEB-INF/classes/lib)
  • or
  • You have a servlet-api jar bundled as part of your app, which you never should as your web server has it (tomcat/jboss/geronimo etc)

Hope this helps someone.. coz I’ve stumbled into this and solved it couple of times.

Tagged with:
 

If you see this error in your logs, it just means that your JDK has not been able to locate the trustStore.

Fix this in your user profile (JDK fix)

Caused by: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
	at java.security.cert.PKIXParameters.setTrustAnchors(PKIXParameters.java:183)
	at java.security.cert.PKIXParameters.(PKIXParameters.java:103)
	at java.security.cert.PKIXBuilderParameters.(PKIXBuilderParameters.java:87)
	at sun.security.validator.PKIXValidator.(PKIXValidator.java:55)

You can verify this by typing this into console (command prompt in windows)

C:\>keytool -list
keytool error: java.lang.Exception: Keystore file does not exist: C:\Users\John.Doe\.keystore

A simple fix for this can be to copy your default keystore supplied by java into your profile.

C:\>copy %JAVA_HOME%\jre\lib\security\cacerts %USERPROFILE%\.keystore
1 file(s) copied.

This should put a default keystore into your profile, which you can play around with.

This by no means is the solution you should be using in server environments. There you are various ways to handle this at server level.

See below links for more info.

http://docs.oracle.com/javase/6/docs/technotes/guides/security/jsse/JSSERefGuide.html#Features

http://www.herongyang.com/PKI/HTTPS-Java-Programs-Communicate-with-HTTPS-Server.html

http://www.oracle.com/technetwork/java/javase/tech/index-jsp-136007.html

Fix this for a java application (e.g. Application Server like JBoss)

Set the trust store location and password on the java executable using JVM arguments.

Arguments:

-Djavax.net.ssl.trustStore=<TRUST_STORE_LOCATION>
-Djavax.net.ssl.trustStorePassword=<TRUST_STORE_PASSWORD> (default is 'changeit')

You can do this for Jboss by adding as similar instruction mentioned below to your /bin/run.bat

After placing my keystore in \server\\conf, I added this line to my run.bat.

set "JAVA_OPTS=%JAVA_OPTS% -Djavax.net.ssl.trustStore=%JBOSS_HOME%\server\<JBOSS_PROFILE>\conf\.keystore -Djavax.net.ssl.trustStorePassword=changeit"
Tagged with:
 

Deploy to Artifactory (remote repository) using Maven

On December 3, 2012, in java, maven, by Kishore Chintoju

Overview

Deploy to artifactory using maven.

Configuration

Add your repository server configuration to maven settings.xml

This needs to be done only once. If the repository is already configured in your user settings.xml, skip this step.

Add below configuration to your settings.xml

Below configuration can be obtained from your artifactory

<server>
  <id>{repo-id}</id>
  <username>{repo-username}</username>
  <password>{password/encrypted password}</password>
</server>

More info here

Add maven-deploy-plugin to your pom

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-deploy-plugin</artifactId>
  <version>2.7</version>
</plugin>

More info http://maven.apache.org/plugins/maven-deploy-plugin/plugin-info.html

Add remote (artifactory) repository to your POM

<distributionManagement>
  <repository>
    <id>{repo-id}</id>
    <name>{repo-id}</name>
    <url>http://{repo-host-name}/artifactory/{repo-url}</url>
  </repository>
</distributionManagement>

More info at

Deploy Using Maven

Running below command would deploy it to the default repository

1.mvn deploy

In case of multiple repositories in pom, specify repository id.

1.mvn deploy -DrepositoryId

More info at http://maven.apache.org/plugins/maven-deploy-plugin/usage.html

Tagged with:
 

We were able to complete this telugu copy of Saibaba 9 Thursday’s Vratam due to the grace of baba during our vrat. This book is a result of a huge effort from my wife.

Please download/read/correct/distribute as you see fit.

Tagged with:
 

Stop two words from combining in telugu font

On May 3, 2012, in fun, web development, by Kishore Chintoju

Sometimes in Telugu font if you put two words next to each other without a space they combine.
e.g. మహేష్ + తొ = మహేష్తొ
But what we want is మహేష్​తొ

In such cases use a zero width space or invisible space in my words to stop them from combining.

  1. Type మహేష్
  2. Type zero width space using “Alt+8023″ for MS word and unicode &#8023; for web
  3. Then type తొ

This trick even works in word.

Tagged with:
 

LinkageError in server logs due to duplicate xml api jars

On April 5, 2012, in java, jboss, maven, by Kishore Chintoju

Ever seen this  linkage error. This is caused by various reasons of duplicate jars containing xml-apis.

I had this issue when I included Apache POI jars (poi-ooxml-schemas) which in turn included stax-api jars (geronimo-stax-api_1.0_spec.jar, stax-api.jar) and xml-api’s (xml-api.jar, xmlbeans.jar).

Excluding them from your dependency would solve the issue.

Exclude Example

<exclusions>
	<exclusion>
		<artifactId>stax-api</artifactId>
		<groupId>stax</groupId>
	</exclusion>
	<exclusion>
		<artifactId>geronimo-stax-api_1.0_spec</artifactId>
		<groupId>org.apache.geronimo.specs</groupId>
	</exclusion>
	<exclusion>
		<artifactId>xml-apis</artifactId>
		<groupId>xml-apis</groupId>
	</exclusion>
	<exclusion>
		<artifactId>dom4j</artifactId>
		<groupId>dom4j</groupId>
	</exclusion>
</exclusions>

LinkageError Stack Trace

java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "com.sun.xml.bind.DatatypeConverterImpl.parseQName(Ljava/lang/String;Ljavax/xml/namespace/NamespaceContext;)Ljavax/xml/namespace/QName;" the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) of the current class, com/sun/xml/bind/DatatypeConverterImpl, and the class loader (instance of ) for interface javax/xml/bind/DatatypeConverterInterface have different Class objects for the type javax/xml/namespace/QName used in the signature
	at com.sun.xml.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:227)
	at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:84)
	at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:66)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:214)
	at javax.xml.bind.ContextFinder.find(ContextFinder.java:375)
	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
	at org.jboss.ws.core.jaxws.CustomizableJAXBContextFactory.createContext(CustomizableJAXBContextFactory.java:90)
	at org.jboss.ws.core.jaxws.JAXBDeserializer.getJAXBContext(JAXBDeserializer.java:96)
	at org.jboss.ws.core.jaxws.JAXBDeserializer.deserialize(JAXBDeserializer.java:66)
	at org.jboss.ws.core.binding.DeserializerSupport.deserialize(DeserializerSupport.java:61)
	at org.jboss.ws.core.soap.XMLContent.unmarshallObjectContents(XMLContent.java:179)
	at org.jboss.ws.core.soap.XMLContent.transitionTo(XMLContent.java:96)
	at org.jboss.ws.core.soap.SOAPContentElement.transitionTo(SOAPContentElement.java:140)
	at org.jboss.ws.core.soap.SOAPBodyElementDoc.transitionTo(SOAPBodyElementDoc.java:85)
	at org.jboss.ws.core.soap.SOAPContentElement.getObjectValue(SOAPContentElement.java:172)
	at org.jboss.ws.core.EndpointInvocation.transformPayloadValue(EndpointInvocation.java:273)
	at org.jboss.ws.core.EndpointInvocation.getRequestParamValue(EndpointInvocation.java:115)
	at org.jboss.ws.core.EndpointInvocation.getRequestPayload(EndpointInvocation.java:135)
	at org.jboss.ws.core.server.DelegatingInvocation.getArgs(DelegatingInvocation.java:80)
	at org.jboss.wsf.container.jboss50.invocation.InvocationHandlerEJB3.invoke(InvocationHandlerEJB3.java:93)
	at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:221)
	at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:468)
	at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:293)
	at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:203)
	at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:129)
	at org.jboss.wsf.common.servlet.AbstractEndpointServlet.service(AbstractEndpointServlet.java:85)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
	at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
	at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	at java.lang.Thread.run(Thread.java:662)
Tagged with:
 

I have decided to write some of the devotional text we learn in Telugu font so it is available for wider audience and can be read on any screens (Mobile/Table/PC) screens on any resolution on can be printed nicely as well. Coming from a background of Telugu medium, it does feel nice to be able to write in Telugu again. Let’s keep Telugu alive and well.


Sri Rama Rama Rameti Mantra on occasion of  Sri Rama Navami.

శ్రీ రామ రామ రామేతి
రమే రామే మనోరమే
సహస్రనామ తత్ తుల్యం
రామ నామ వరాననే

See this video for details on how it is to be pronounced.

Tagged with: