Wednesday, May 30, 2012

/apps/test/script/test_script.sh: bad substitution Error while running script through Cron Job

I was getting the following error while running the shell script through Cron Job..

/apps/test/script/test_script.sh: bad substitution

I was using bash when running this script manually. But while scheduling this script in a cron job a different shell (K shell) was being used. I put the following as first line of my script and it worked fine:

Solution:

#!/bin/bash



Friday, May 25, 2012

org.apache.axis2.AxisFault: Missing wsse:Security header in request

Issue : org.apache.axis2.AxisFault: Missing wsse:Security header in request

951> <BEA-000000> <2012-05-24 12:09:31.949 AM <id 15> <[ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)'> [SEVERE] org.apache.axis2.engine.AxisEngine receive : Missing
wsse:Security header in request
org.apache.axis2.AxisFault: Missing wsse:Security header in request
        at org.apache.rampart.handler.RampartReceiver.setFaultCodeAndThrowAxisFault(RampartReceiver.java:186)
        at org.apache.rampart.handler.RampartReceiver.invoke(RampartReceiver.java:99)
        at org.apache.axis2.engine.Phase.invokeHandler(Phase.java:340)
        at org.apache.axis2.engine.Phase.invoke(Phase.java:313)
        at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:262)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:168)
        at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:364)
        at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
        at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
        at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)



Try putting a security Header in your Soap Request:

<soapenv:Header>
      <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
         <wsse:UsernameToken wsu:Id="UsernameToken-32950583" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <wsse:Username>testuser</wsse:Username>
            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">testpassword</wsse:Password>
         </wsse:UsernameToken>
      </wsse:Security>
   </soapenv:Header>


Monday, May 21, 2012

error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock'

Issue connecting to Mysql.

mysqld_safe mysqld from pid file /usr/local/mysql-5.5.15-osx10.6-x86_64/data/sanjay-ingoles-MacBook-Pro.local.pid ended

/usr/local/mysql/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!


Resolution :

sudo /usr/local/mysql/bin/mysqld stop

Then
     shell> cd /usr/local/mysql
     shell> sudo ./bin/mysqld_safe

Then

/usr/local/mysql/bin/mysql -u username -p database

Sunday, March 4, 2012

Hibernate Error : org.hibernate.hql.ast.QuerySyntaxException: TestTable is not mapped [from TestTable}

Problem : Getting an exception while trying to get all the records from a TestTable.:

Following is the Hibernate Config for TestTable:


<hibernate-mapping>
    <class name="com.testapp.service.dataobjects.TestTableDO" table="testTable">
    <id name="testId" column="testId">
        <generator class="assigned"/>
    </id>
...
...
</class>
</hibernate-mapping>




And Following is the Java code to get all the records from the TestTable

List<TestTableDO> testTableResultSet = hibernateTemplate.find("from TestTable");



Solution: The problem is due to the name mismatch in the Hibernate table configurations and the Java Query.

As you can see the hibernate is configured to map the 'testTable' to the 'com.testapp.service.dataobjects.TestTableDO' whereas in Java it refers to 'TestTable' (database table name).
Because we have mapped it to 'TestTableDO' it should be referred as same in Java Query as follows:



List<TestTableDO> testTableResultSet = hibernateTemplate.find("from TestTableDO");

Cheers :)



Error Logs
org.hibernate.hql.ast.QuerySyntaxException: TestTable is not mapped [from TestTable]
at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:158)
at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:87)
at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:70)
at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:265)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3056)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2945)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:923)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:921)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:913)

Thursday, March 1, 2012

Shell Script to check and remove file with specific extension

help(){
        echo " This script checks for the employee files 'test_id001.dat' and delete the files with '*.dat' extension in the directory ${TEST_DIR}. Note : Make sure the TEST_DIR path is set as environment variable."

        exit;

}
if [[ $1 = "-help" ]]
        then
                help
fi

cd ${TEST_DIR}

for file in *.rules
do

## Extract a substring to get the Employee Id from the File Name
## i.e Employeed Id 'id001' in the file test_id001.dat
employeeid="${file##*_}"
employeeid="${employeddid%.*}"

echo " = Remove the file for Employee with ID - $employeeid, file location = ${TEST_DIR}$file"
rm -f ${TEST_DIR}$file

done

Wednesday, February 29, 2012

Delete JMS Messages from Weblogic 11G Server

To Delete the JMS messages from the Queue or Topic manually:
Go to JMS Queue or topic - > Monitoring -> select the queue and click on 'Show Messages' Button.
On the next page you have option to delete the messages.

Tuesday, February 28, 2012

subsystem failed. Reason: java.lang.NullPointerException

Was unable to start the managed server due to the following exception.
 I noticed the Perm space was almostfull.

I just killed the java process, restarted the Admin and managed server both and it resolved the issue.
ps -ef | grep java
kill -9 6682
<Feb 28, 2012 5:07:15 PM GMT> <Critical> <WebLogicServer> <BEA-000386> <Server subsystem failed. Reason: java.lang.NullPointerException
java.lang.NullPointerException
        at weblogic.store.io.file.StoreFile.close(StoreFile.java:440)
        at weblogic.store.io.file.Heap.open(Heap.java:320)
        at weblogic.store.io.file.FileStoreIO.open(FileStoreIO.java:104)
        at weblogic.store.internal.PersistentStoreImpl.recoverStoreConnections(PersistentStoreImpl.java:431)
        at weblogic.store.internal.PersistentStoreImpl.open(PersistentStoreImpl.java:422)
        Truncated. see log file for complete stacktrace
>
<Feb 28, 2012 5:07:15 PM GMT> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to FAILED>
<Feb 28, 2012 5:07:15 PM GMT> <Error> <WebLogicServer> <BEA-000383> <A critical service failed. The server will shut itself down>
<Feb 28, 2012 5:07:15 PM GMT> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to FORCE_SHUTTING_DOWN>

 PSYoungGen      total 172032K, used 153481K [0x00000000f4000000, 0x0000000100000000, 0x0000000100000000)
  eden space 147456K, 87% used [0x00000000f4000000,0x00000000fbde26d0,0x00000000fd000000)
  from space 24576K, 100% used [0x00000000fd000000,0x00000000fe800000,0x00000000fe800000)
  to   space 24576K, 0% used [0x00000000fe800000,0x00000000fe800000,0x0000000100000000)
 PSOldGen        total 65536K, used 4288K [0x00000000e0000000, 0x00000000e4000000, 0x00000000f4000000)
  object space 65536K, 6% used [0x00000000e0000000,0x00000000e0430010,0x00000000e4000000)
 PSPermGen       total 118784K, used 118201K [0x00000000d0000000, 0x00000000d7400000, 0x00000000e0000000)
  object space 118784K, 99% used [0x00000000d0000000,0x00000000d736e600,0x00000000d7400000)