Wednesday, April 21, 2010

Html contents using h:outputText

<h:outputText value="#{testBean.htmlText}"
               escape="false" />

 Generate your html contents in testBean.htmlText

Tuesday, April 20, 2010

The code of method _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit



If you are using <%@ include file="test.jsp" %>(static include),
replace this to <jsp:include page="test.jsp" /> (dynamic include).

Wednesday, April 14, 2010

jndi configuration in Jboss server

Jijo-ds.xml (put this file in jboss deploy folder)

<datasources>
  <local-tx-datasource>
    <jndi-name>jijoDS</jndi-name>
    <connection-url>jdbc:mysql://localhost:3306/jijo</connection-url>

    <driver-class>com.mysql.jdbc.Driver</driver-class>
    <user-name>root</user-name>
    <password>mysql</password>
    <!-- you can include connection properties that will get passed in

     the DriverManager.getConnection(props) call-->
    <!-- look at your Driver docs to see what these might be -->
    <connection-property name="char.encoding">UTF-8</connection-property>

    <transaction-isolation>TRANSACTION_SERIALIZABLE</transaction-isolation>

    <!--pooling parameters-->
    <min-pool-size>10</min-pool-size>
    <max-pool-size>30</max-pool-size>

    <blocking-timeout-millis>5000</blocking-timeout-millis>
    <idle-timeout-minutes>1</idle-timeout-minutes>
    <!-- sql to call when connection is created -->
    <new-connection-sql>select 1</new-connection-sql>

   

    <!-- sql to call on an existing pooled connection when it is obtained from pool -->
    <check-valid-connection-sql>select 1</check-valid-connection-sql>
   
    <set-tx-query-timeout></set-tx-query-timeout>
    <query-timeout>300</query-timeout> <!-- maximum of 5 minutes for queries -->

  </local-tx-datasource>
</datasources>

in your application WEB-INF/jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
        <security-domain>java:/jaas/jmx-console</security-domain> 
         <resource-ref> 
       <res-ref-name>jijoDS</res-ref-name>
       <jndi-name>java:/jijoDS</jndi-name>
   </resource-ref>    
</jboss-web>

in web.xml

<resource-ref>
        <res-ref-name>jijoDS</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>



in applicationContext.xml you are using Spring-Hibernate combination


<bean id="dataSource" class="org.springframework.
jndi.JndiObjectFactoryBean" singleton="true">
     <property name="jndiName">
        <value>java:/jijoDS</value>
     </property>
</bean>

<bean id="hibernateProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean" >
<property name="properties">
<props>
<prop key="hibernate.dialect">dialect name</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</prop>
<prop key="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</prop>
<prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop>
<prop key="hibernate.connection.datasource">java:/comp/env/jdbc/jijoDS</prop>
</props>
</property>
</bean>

DataBase connection configuration in Spring-Hibernate(applicationContext.xml)

in jdbc.properties  

#for Oracle
#jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
#jdbc.url=jdbc:oracle:thin:@192.168.0.69:1521:jijo
#jdbc.username=jijo
#jdbc.password=jijo
#hibernate.dialect=org.hibernate.dialect.Oracle10gDialect


#for MYSQL
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/jijo
jdbc.username=root
jdbc.password=jijo
hibernate.dialect=org.hibernate.dialect.MySQLDialect

hibernate.c3p0.initialPoolSize=10
hibernate.c3p0.minPoolSize=5
hibernate.c3p0.maxPoolSize=25
hibernate.c3p0.acquireRetryAttempts=10
hibernate.c3p0.acquireIncrement=5
hibernate.c3p0.idleConnectionTestPeriod=3600
hibernate.c3p0.preferredTestQuery=SELECT 1;
hibernate.c3p0.testConnectionOnCheckin=false
hibernate.c3p0.maxConnectionAge=100
hibernate.c3p0.maxIdleTime=120


in applicationContext.xml

 <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${jdbc.driverClassName}"/>
<property name="jdbcUrl" value="${jdbc.url}"/>
<property name="user" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/> 
<property name="initialPoolSize"><value>${hibernate.c3p0.initialPoolSize}</value></property>
<property name="minPoolSize"><value>${hibernate.c3p0.minPoolSize}</value></property>
<property name="maxPoolSize"><value>${hibernate.c3p0.maxPoolSize}</value></property>
<property name="acquireRetryAttempts"><value>${hibernate.c3p0.acquireRetryAttempts}</value></property>
<property name="acquireIncrement"><value>${hibernate.c3p0.acquireIncrement}</value></property>
<property name="idleConnectionTestPeriod"><value>${hibernate.c3p0.idleConnectionTestPeriod}</value></property>
<property name="maxIdleTime"><value>${hibernate.c3p0.maxIdleTime}</value></property>
<property name="maxConnectionAge"><value>${hibernate.c3p0.maxConnectionAge}</value></property>
<property name="preferredTestQuery"><value>${hibernate.c3p0.preferredTestQuery}</value></property>
<property name="testConnectionOnCheckin"><value>${hibernate.c3p0.testConnectionOnCheckin}</value></property>
</bean>


<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

<property name="hibernateProperties">
            <props>

                 <prop key="hibernate.dialect">
                    ${hibernate.dialect}
                </prop>

                <prop key="hibernate.show_sql">false</prop>
                <prop key="hibernate.cglib.use_reflection_optimizer">
                    true
                </prop>
                <prop key="hibernate.cache.provider_class">
                    org.hibernate.cache.HashtableCacheProvider
                </prop>
                <prop key="hibernate.c3p0.acquire_increment">${hibernate.c3p0.acquireIncrement}</prop>
                <prop key="hibernate.c3p0.idle_test_period">${hibernate.c3p0.idleConnectionTestPeriod}</prop>
                <prop key="hibernate.c3p0.timeout">${hibernate.c3p0.maxIdleTime}</prop>
                <prop key="hibernate.c3p0.max_size">${hibernate.c3p0.maxPoolSize}</prop>
                <prop key="hibernate.c3p0.min_size">${hibernate.c3p0.minPoolSize}</prop>
                <prop key="hibernate.show_sql">false</prop>
            </props>
        </property>
    </bean>