Friday, February 04, 2011

attempted to return null from a method with a primitive return type (void).


Problem:
I was encoutering this excpetion while inserting a row in the database using myBatis 3. 

Solution:
I had forgotton to change my mapper file xml tag from <select> to <insert>.

org.apache.ibatis.binding.BindingException: Mapper method 'xxx' (interface in.xx.xxxx..xxxDAO) attempted to return null from a method with a primitive return type (void).
 org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:40)
 $Proxy34.XXXX(Unknown Source)
 xxx.xxx.XXXXServiceImpl.save(XXXServiceImpl.java:94)
 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 java.lang.reflect.Method.invoke(Method.java:597)
 org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
 org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
 org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
 org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
 org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopP

Friday, January 07, 2011

SEVERE: Could not start SOLR. Check solr/home property



StackTrace
INFO: created /debug/dump: solr.DumpRequestHandler
Jan 8, 2011 10:30:22 AM org.apache.solr.servlet.SolrDispatchFilter init
SEVERE: Could not start SOLR. Check solr/home property
java.lang.RuntimeException: java.io.IOException: read past EOF
at org.apache.solr.core.SolrCore.getSearcher(SolrCore.java:1068)
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:579)
at org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:137)
at org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:83)
at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:99)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:594)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:139)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1218)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:500)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:147)


Cause
I copied the SOLR directory to another machine and when I fired up SOLR received this error.

Solution:
The error message was misleading as even though I started the server with -Dsolr.solr.home option the error was still the same.

The index was somehow corrupted and when I deleted the $SOLR_HOME/solr/data/index directory and restarted SOLR it worked fine. Obviously after that the data had to be reindexed

Thursday, November 25, 2010

Exception in thread "main" java.lang.NoClassDefFoundError: org/jvnet/staxex/XMLStreamReaderEx

Exception in thread "main" java.lang.NoClassDefFoundError: org/jvnet/staxex/XMLStreamReaderEx
at com.sun.xml.stream.buffer.stax.StreamReaderBufferCreator.storeElementAndChildren(StreamReaderBufferCreator.java:174)
at com.sun.xml.stream.buffer.stax.StreamReaderBufferCreator.storeDocumentAndChildren(StreamReaderBufferCreator.java:158)
at com.sun.xml.stream.buffer.stax.StreamReaderBufferCreator.store(StreamReaderBufferCreator.java:139)
at com.sun.xml.stream.buffer.stax.StreamReaderBufferCreator.create(StreamReaderBufferCreator.java:82)
at com.sun.xml.stream.buffer.MutableXMLStreamBuffer.createFromXMLStreamReader(MutableXMLStreamBuffer.java:113)
at com.sun.xml.stream.buffer.XMLStreamBuffer.createNewBufferFromXMLStreamReader(XMLStreamBuffer.java:398)
at com.sun.xml.ws.api.addressing.WSEndpointReference.<init>(WSEndpointReference.java:174)
at com.sun.xml.ws.api.addressing.WSEndpointReference.<init>(WSEndpointReference.java:166)
at com.sun.xml.ws.api.addressing.AddressingVersion.<init>(AddressingVersion.java:436)
at com.sun.xml.ws.api.addressing.AddressingVersion.<init>(AddressingVersion.java:67)
at com.sun.xml.ws.api.addressing.AddressingVersion$1.<init>(AddressingVersion.java:146)
at com.sun.xml.ws.api.addressing.AddressingVersion.<clinit>(AddressingVersion.java:69)
at com.sun.tools.ws.wsdl.parser.MemberSubmissionAddressingExtensionHandler.getNamespaceURI(MemberSubmissionAddressingExtensionHandler.java:62)
at com.sun.tools.ws.wsdl.parser.WSDLParser.register(WSDLParser.java:129)
at com.sun.tools.ws.wsdl.parser.WSDLParser.<init>(WSDLParser.java:119)
at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.buildModel(WSDLModeler.java:109)
at com.sun.tools.ws.wscompile.WsimportTool.run(WsimportTool.java:183)
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 com.sun.tools.ws.Invoker.invoke(Invoker.java:116)
at com.sun.tools.ws.WsImport.main(WsImport.java:52)
erEx

Solution:
During the setup of Metro 1.5 I had also copied the webservices-rt.jar and other files in JDK_HOME/jre/lib/endorsed directory.
Removing the files from endorsed directory removed this error and led to generation of files.

Monday, November 01, 2010

org.postgresql.util.PSQLException: The column {n} index is out of range {m}

The cause of the error was that in the Query for {n} dynamic parameters, {m} parameters were being inserted

Tuesday, October 19, 2010

Cannot find message resources under key org.apache.struts.action.MESSAGE with

Received error while using <bean:write> tag
Cannot find message resources under key org.apache.struts.action.MESSAGE

Cause:
A int value was being displayed using <bean:write>
<bean:write property="xxxProperty" name="xxForm />

Solution:
Used format attribute to provide the format of Integer
<bean:write property="xxxProperty" name-"xForm" format="#" />

and it worked.

P.S.- Working in Struts 1 again makes me realize how painful it was :-)

Tuesday, October 07, 2008

java.lang.NoSuchMethodError: com/ibm/ejs/ras/TraceComponent.isAnyTracingEnabled()Z

Include the com.ibm.ws.webservices.thinclient_6.1.0.jar file is in the classpath.
Remove other jars if present (such as ras.jar, com.ibm.ws.runtime_6.1.0.jar) which contain TraceComponent class

Monday, October 06, 2008

java.lang.NoSuchFieldError: com/ibm/mq/MQC.MQCT_NONE

com.ibm.mq.jar is required in the classpath of the java class.
This jar is supplied with WAS

Thursday, July 24, 2008

Unable to use CSS style on the page

I was going nuts why I am unable to view the style on the pages using Struts 2 with AJAX.

I have to investigate but once I removed this line from my JSP it ran fine :-)

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">


Saturday, August 25, 2007

Show Hide using display.style in javascript problem in Firefox

An already javascript function was used to show/hide an array of elments in an HTML page.
It worked perfectly in IE but in Firefox it gave a problem when we used to show/hide multiple times on an element. A new row/column was added in every iteration of show hide.

On investigation, a single line code change made in work fine in both IE and firefox

Old Code
function showHideElement(elementId, showHideFlag) {
var elementObj = document.getElementById(elementId);
if(showHideFlag == 1) {
elementObj.style.display = 'block';
} else if(showHideFlag == 0) {
elementObj.style.display = 'none';
}
}
New Code
function showHideElement(elementId, showHideFlag) {
var elementObj = document.getElementById(elementId);
if(showHideFlag == 1) {
elementObj.style.display = '';
} else if(showHideFlag == 0) {
elementObj.style.display = 'none';
}
}
A single line change from elementObj.style.display = 'block' to elementObj.style.display = '' stopped creation of blank rows/columns on every iteration of show hide

http://www.ozzu.com/ftopic41924.html
http://www.velocityreviews.com/forums/t160487-firefox-and-stylequotdisplayblockquot-on-table-row.html

Friday, August 10, 2007

Wednesday, July 11, 2007

No form found under 'null' in locale 'en_US'. A form must be defined in the Commons Validator configuration when dynamicJavascript=&q

As soon as I put &lt;html:javascript /&gt; tag in the jsp, I get this error.
It indicates that it is unable to find a formset.

Solution: Did not add the form name with the tag
ex:

The path of an ForwardConfig cannot be null

Usually, this is an indication that you have validation turned on, the
validation is failing, and the "input" attribute is not set (i.e. it's
NULL)
Source

I was adding validator and forgot to do 'validation="true"' add the 'input' attribute in action mapping

Tuesday, March 27, 2007

java.sql.SQLException: ORA-01008: not all variables bound

One of the cause of this error can be found in the following snippet of code:

query = "select * from AAA where condn = ?";
pstmt = con.prepareStatement(query);
pstmt.setString(1, firstValue);
// ResultSet rs = pstmt.executeQuery(query); // Wrong Usage - Do not provide query again
ResultSet rs = pstmt.executeQuery(); // Correct Usage

Another reason is that you have not mapped all '?' with corresponding values




Thursday, July 27, 2006

ORA-00911: invalid character

The exception was because I had a semicolon(;) after the preparedstatement query.
Removal of it resolved the problem

Tuesday, May 09, 2006

Database Explorer in Eclipse 3.1

Hi,

These are two Plugins which can be used for exploring the DB.
Hence it will reduce the dependency on PL/SQL Dev and Toad.
1. SourceForge.net: Eclipse SQLExplorer plugin
2. SourceForge.net: DBEdit Plugin for Eclipse

Installation is simple, just extract them in the plugin directory of Eclipse.
After you restart your Eclipse you can see one more Perspective(SQLExplorer/DBEdit) which will depend on which plugin you have installed.

Hopefully once we move to Eclipse 3.2 we will get all this features from the Data Tools Platform.

The  installation instruction for SQL Exlplorer are present on this link
http://www.onjava.com/pub/a/onjava/2005/05/11/sqlexplorer.html



Thursday, March 23, 2006

Cannot create JDBC driver of class '' for connect URL 'null'

If you get this Exception while using Tomcat 5.5.9 or 5.5.*
Caused by: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:780) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540) at com.vsnl.pcr.dao.DataAccessObject.getConnection(DataAccessObject.java:119) ... 29 more

Possible Solution:
Check the database lookup entry in either context.xml or server.xml
In Tomcat 5.5.9 there are no <ResouceParams> tag and the parameters are passed alongiwth the resource tag.

e.g Resource Entry in Tomcat 5.5.9


<resource name="jdbc/XYZ"
auth="Container"
scope="Shareable"
type="javax.sql.DataSource"
driverclassname="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1521:XYZ"
username="xyz"
password="xyz"
maxactive="10"
maxidle="100"
maxwait="3000">
</resource>




In Tomcat 5.0.28


<resource name="jdbc/XYZ" scope="Shareable" type="javax.sql.DataSource">
<resourceparams name="jdbc/XYZ">
<parameter>
<name>factory</name>
<value>
org.apache.commons.dbcp.BasicDataSourceFactory
</value>
</parameter>
<!-- DBCP database connection settings -->
<parameter>
<name>url</name>
<value>jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1521:XYZ</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value>
</parameter>
<parameter>
<name>username</name>
<value>xyz</value>
</parameter>
<parameter>
<name>password</name>
<value>xyz</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>3000</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>100</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>10</value>
</parameter>

</resourceparams>
</resource>

One Last Point: Dont forget to put your classes12.jar/ojdbc14.jar file in /commons/lib folder.

Two useful links which help me discover this.. :-) (after I had already wasted a lot of time)
1. Java Forums
2. Tomcat Docs

Monday, March 13, 2006

Common Struts Errors

Common Struts Errors
A really good compilation of some Common Struts erors and I find it quite handy :-) most of the times

Wednesday, March 08, 2006

javax.servlet.ServletException: Define tag cannot set a null value

If you are using struts and get this error, it means you might have used
tag for a value which is null.

The problem would be solved if you use tag to check for the null value.
e.g.

1 <logic:notEmpty name="fooForm" property="fooList">
2 <bean:define id="fooList" name="fooForm" property="fooList" />
3 <html:options collection="fooList" property="id" labelProperty="fooname" />
4 </logic:notEmpty>

The 'fooList' is checked before being defined in the samplecode

Thursday, February 16, 2006

How to Stop double submit on click of refresh button in Struts

Follow these steps if you are using Struts
1. Add saveToken(request) in the execute() method of the Action when the page needs to displayed first or initialized.
2. Add the following code in the execute() method of Action handling the processing of the page on Submit

if (isTokenValid(request)) {
////// Do the processing for the request and add messages if required

resetToken(request); /// Reset the token so that on resubmit it does not come in this block
return mapping.findForward("success");
} else {
///// The page is submitted again so take app. action if required
return mapping.findForward("failure");
}