Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts

Wednesday, 10 March 2010

Install MySQL 5.0.27 on Solaris 5.10

Compilation from Source (GCC 3.4.6)



Get the Source


A distribution mysql-5.0.27.tar.gz (20 Oct 2006, 24.7M) was downloaded from MySQL website and stored in /usr/local/software.


Pre-Compile Config


All default except install location:



./configure --prefix=/usr/local/mysql


configure:22606: WARNING: term.h: present but cannot be compiled
configure:22608: WARNING: term.h: check for missing prerequisite headers?
configure:22610: WARNING: term.h: see the Autoconf documentation
configure:22612: WARNING: term.h: section "Present But Cannot Be Compiled"
configure:22614: WARNING: term.h: proceeding with the preprocessor's result
configure:22616: WARNING: term.h: in the future, the compiler will take precedence
configure:22628: checking for term.h
.
.
configure:32423: WARNING: sys/ptem.h: present but cannot be compiled
configure:32425: WARNING: sys/ptem.h: check for missing prerequisite headers?
configure:32427: WARNING: sys/ptem.h: see the Autoconf documentation
configure:32429: WARNING: sys/ptem.h: section "Present But Cannot Be Compiled"
configure:32431: WARNING: sys/ptem.h: proceeding with the preprocessor's result
configure:32433: WARNING: sys/ptem.h: in the future, the compiler will take precedence
configure:32445: checking for sys/ptem.h

Check configure.log found:



configure:23024: checking term.h usability
configure:23036: gcc -c conftest.c >&5
In file included from conftest.c:102:
/usr/include/term.h:1034: error: syntax error before "bool"
/usr/include/term.h:1060: error: syntax error before "SGTTY"
/usr/include/term.h:1081: error: syntax error before "sgr_mode"
/usr/include/term.h:1082: error: syntax error before "sgr_faked"
/usr/include/term.h:1092: error: syntax error before "funckeystarter"
/usr/include/term.h:1094: error: syntax error before "_fl_rawmode"
/usr/include/term.h:1101: error: syntax error before "_input_queue"
/usr/include/term.h:1108: error: syntax error before '*' token
/usr/include/term.h:1111: error: syntax error before "bit_vector"
/usr/include/term.h:1115: error: syntax error before "check_turn_off"
/usr/include/term.h:1116: error: syntax error before "non_faked_mode"
/usr/include/term.h:1117: error: syntax error before "_cur_pair"
/usr/include/term.h:1118: error: syntax error before '*' token
/usr/include/term.h:1120: error: syntax error before '}' token
/usr/include/term.h:1207: error: syntax error before "int"
/usr/include/term.h:1207: error: `vidputs' declared as function returning a function
/usr/include/term.h:1207: error: syntax error before ')' token
configure:23042: $? = 1
configure: failed program was:
| /* confdefs.h. */


configure:34054: checking sys/ptem.h usability
configure:34066: gcc -c -O3 -DDBUG_OFF -DHAVE_RWLOCK_T conftest.c >&5
In file included from conftest.c:169:
/usr/include/sys/ptem.h:25: error: syntax error before "mblk_t"
/usr/include/sys/ptem.h:29: error: syntax error before '}' token
configure:34072: $? = 1
configure: failed program was:
| /* confdefs.h. */

It seems that two files could not be compiled due to syntax errors. Could be GCC version problem. The warning does not affect the compilation.



Compilation Error



./gen_lex_hash > lex_hash.h-t
ld.so.1: gen_lex_hash: fatal: libstdc++.so.6: open failed: No such file or directory
/bin/bash: line 1: 5234 Killed ./gen_lex_hash >lex_hash.h-t
make[1]: *** [lex_hash.h] Error 137

Library libstdc++ is not on path. Need adding LD_LIBRARY_PATH.



Direct Installation from Binary (Standard & max)



Didn't adopt the installation from source and install from binary directly.



Get the Distributions


Two files: mysql-standard-5.0.27-solaris10-x86_64.pkg & mysql-max-5.0.27-solaris10-x86_64.pkg.



Installation Steps


Installing MySQL 5.0 on Solaris 10



Post Installation Config



Modify mysql @ /usr/init.d/



basedir=/opt/mysql/mysql
#datadir=/var/lib/mysql
datadir=/data


Create my.cnf @ /etc/



[mysqld]
basedir=/opt/mysql/mysql
datadir=/data
lower_case_table_names=1


Remove Most Symlinks About MySQL


The following directories are found to contains symlinks to MySQL:



rm -rf /usr/sbin/mysql.symlinks.2010-03-12
rm -rf /usr/local/mysql.2010-03-12
rm -rf /usr/include/mysql
rm -rf /usr/bin/mysql.symlinks

rm /usr/share/man/man1/msql2mysql.1
rm /usr/share/man/man1/mysql_config.1
rm /usr/share/man/man1/mysql_explain_log.1
rm /usr/share/man/man1/mysql_fix_privilege_tables.1
rm /usr/share/man/man1/mysql_upgrade.1
rm /usr/share/man/man1/mysql_zap.1
rm /usr/share/man/man1/mysql.1
rm /usr/share/man/man1/mysql.server.1
rm /usr/share/man/man1/mysqlaccess.1
rm /usr/share/man/man1/mysqladmin.1
rm /usr/share/man/man1/mysqlbinlog.1
rm /usr/share/man/man1/mysqlcheck.1
rm /usr/share/man/man1/mysqld_multi.1
rm /usr/share/man/man1/mysqld_safe.1
rm /usr/share/man/man1/mysqld.1
rm /usr/share/man/man1/mysqldump.1
rm /usr/share/man/man1/mysqlhotcopy.1
rm /usr/share/man/man1/mysqlimport.1
rm /usr/share/man/man1/mysqlman.1
rm /usr/share/man/man1/mysqlmanager.1
rm /usr/share/man/man1/mysqlshow.1
rm /usr/share/man/man1/safe_mysqld.1

rm /usr/sfw/include/mysql

rm /usr/info/mysql.info
rm /usr/lib/libmysqlclient_r.a
rm /usr/lib/libmysqlclient.a


mysqld_safe Change Due to Symlink Removal


All /usr/local/mysql strings are replaced by /opt/mysql/mysql. Now the MySQL server can be started by just typing:


# mysqld_safe

Monday, 27 July 2009

Seam 2 + MySQL 5 + jBPM 3

Seam (jboss-seam-2.1.2) could not start jBPM (jbpm-3.2.6.SP1) causes application deployment fails



02:08:48,718 ERROR [jbpm]] Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.bpm.jbpm


Caused by: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of org.jbpm.job.Job.id

jboss-seam-2.1.2 comes with an older version of jbpm-jpdl.jar. Copy the newer one from jbpm-3.2.6.SP1 to replace the one in seam.



Seam (jboss-seam-2.1.2) example Hotel Booking, it causes exceptions during undeployment during JBoss shutdown



17:35:36,421 WARN [Component] Exception calling stateful session bean default @Remove method: hotelBooking
org.jboss.ejb3.common.registrar.spi.NotBoundException: Requested value bound at name "jboss.j2ee:ear=seam.example.hotel-ear.ear,jar=seam.example.hotel-ejb.jar,name=HotelBookingAction,service=EJB3" is not bound.


17:35:36,437 WARN [Component] Exception calling stateful session bean default @Remove method: bookingList
org.jboss.ejb3.common.registrar.spi.NotBoundException: Requested value bound at name "jboss.j2ee:ear=seam.example.hotel-ear.ear,jar=seam.example.hotel-ejb.jar,name=BookingListAction,service=EJB3" is not bound.


17:35:36,437 WARN [Component] Exception calling stateful session bean default @Remove method: hotelSearch
org.jboss.ejb3.common.registrar.spi.NotBoundException: Requested value bound at name "jboss.j2ee:ear=seam.example.hotel-ear.ear,jar=seam.example.hotel-ejb.jar,name=HotelSearchingAction,service=EJB3" is not bound.

Only the Stateful session beans like hotelSearch cause the exception. Inside the example there are jboss.xml which contains session bean registrations. Places this file to seam.example.hotel-ear\EarContent\META-INF.



Seam (jboss-seam-2.1.2) jBPM file for page flow could not be parsed



Caused by: org.jbpm.jpdl.JpdlException: [[ERROR] Unable to parse process definition pageflow.jpdl.xml]
at org.jboss.seam.bpm.Jbpm.getPageflowDefinitionFromResource(Jbpm.java:169)
at org.jboss.seam.bpm.Jbpm.installPageflowDefinitions(Jbpm.java:278)

Check if the process definition contains any sub process. If it does, in components.xml, all sub processes MUST be defined before the main process. For example: if cheat.jpdl.xml is a sub process of pageflow.jpd.xml, the follow one will cause the trouble




pageflow.jpdl.xml
cheat.jpdl.xml


And this one is correct.




cheat.jpdl.xml
pageflow.jpdl.xml

Saturday, 22 November 2008

MySQL connection problem with “Spring Transaction Management”

This problem bugs me for a long long time.. it happens when need DB access after a certain period of inactivity. It gives you like:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Connection.close() has already been called. Invalid operation in this state.
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:583)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

root cause

org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Connection.close() has already been called. Invalid operation in this state.
org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:238)
org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:377)
org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:263)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
$Proxy15.searchMovies(Unknown Source)
com.showman.mediaapp.web.MainViewController.handleRequest(MainViewController.java:36)
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

root cause

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Connection.close() has already been called. Invalid operation in this state.
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
java.lang.reflect.Constructor.newInstance(Unknown Source)
com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
com.mysql.jdbc.Util.getInstance(Util.java:381)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
com.mysql.jdbc.ConnectionImpl.getMutex(ConnectionImpl.java:3018)
com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:4827)
org.apache.commons.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:331)
org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.setAutoCommit(PoolingDataSource.java:317)
org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:221)
org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:377)
org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:263)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
$Proxy15.searchMovies(Unknown Source)
com.showman.mediaapp.web.MainViewController.handleRequest(MainViewController.java:36)
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

After done some research, I found out this problem could be a stale DB connection problem (connection killed by the DB server , but still considered alive by the connection pool). I am using MySQL and DBCP from Apaches Commons, now I set pool maxWait (for connection return to pool) from indefinitely to 3000 milliseconds and see if the problem can be solved...