Migration from Glassfish 3.1 to Glassfish 4.0 - spring-mvc

There seems to be a problem with migrating from Glassfish 3.1 to Glassfish 4.x.
I am currently encountered with the following errors:
StandardWrapperValve[DispatcherServlet]: Servlet.service() for servlet DispatcherServlet threw exception java.lang.NullPointerException at com.sun.faces.facelets.tag.TagAttributeImpl.getInt(TagAttributeImpl.java:175) at com.sun.faces.facelets.tag.jstl.core.ForEachHandler.getEnd(ForEachHandler.java:266) at ......................
The code responsible for this works perfectly fine in Glassfish 3.1 but now fails in 4.x.
I've tried this answer out but no luck : How to set -Dorg.apache.el.parser.COERCE_TO_ZERO=false programmatically
Anyone who has encountered this issue?
Here is part of my applicationContext.xml stating the solution on the tutorial:
<bean id="trustStore" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject" value="#{#systemProperties}" />
<property name="targetMethod" value="putAll" />
<property name="arguments">
<props>
<prop key="org.apache.el.parser.COERCE_TO_ZERO">false</prop>
</props>
</property>
</bean>
Thank you.

Related

Upgrade of Spring webflow 1.0 to 2.4.2 - Setting default flow id?

I'm very much new to spring webflow framework and I have been working on upgrading the existing project on spring webflow 1.0 to use spring webflow 2.4.2 latest framework. Currently on our project we are using the defaultFlowId in dispatcher-servlet.xml and there is a corresponding setter method at FlowController.java of spring webflow 1.0 but it is not available with the current webflow framework.
I would like to understand if there is any alternative for the same ?
(dispatcher-servlet.xml)
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<value>
/**/index.htm=loginController
</value>
</property>
</bean>
<bean name="loginController" class="com.example.ui.controllers.LoginController">
<property name="defaultFlowId" value="init-flow" />
<property name="flowExecutor" ref="flowExecutor" />
</bean>
Now it says, Caused By: org.springframework.beans.NotWritablePropertyException: Invalid property 'defaultFlowId' of bean class [com.example.ui.controllers.LoginController]: Bean property 'defaultFlowId' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Since there is no setDefaultFlowId() in latest FlowController.java of org.springframework.webflow.mvc.servlet.FlowController
Anyone who worked/used the above method ? or can i know whether we can define the same kind of defaultId in other ways ?
Any help would be greatly appreciated !
We have upgraded. Here is the flow definition that we are required to use in order that the flow is maintained and default flow is used:
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<value>
/**/index.htm=yourController
</value>
</property>
</bean>
And the rest:
<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices">
<webflow:flow-location id="index" path="/WEB-INF/initialflow.xml" />
</webflow:flow-registry>

using c3p0 with java MVC (JDK 1.6)

I'm trying to create global connections for multiple WAR files (apps) to use.
Each project use entity manager architecture and maven. I'm using spring 3.5.1, tomcat 6.0.39, JDK 1.6.0_45, C3P0 0.9.1.2, hibernate-c3p0 4.2.3.Final, com.mchange c3p0 0.9.2
I saw examples all over but none works for me, I'm not sure why.
I tried almost everything, but I have no clue what's wrong.
I've written into server.xml the following:
<Resource auth="Container"
description="DB Connection"
driverClass="com.mysql.jdbc.Driver"
maxPoolSize="20"
minPoolSize="12"
acquireIncrement="1"
name="jdbc/testdb1"
user="root"
password=""
factory="org.apache.naming.factory.BeanFactory"
type="com.mchange.v2.c3p0.ComboPooledDataSource"
jdbcUrl="jdbc:mysql://localhost:3306/test_db1?autoReconnect=true" />
and into context.xml the following:
<ResourceLink name="jdbc/testdb1"
global="jdbc/testdb1"
type="javax.sql.DataSource" />
and into web.xml the following:
<resource-ref>
<res-ref-name>jdbc/testdb1</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
and my project (app) specific configuration:
PART 1 (JPA XML FILE):
<bean id="transactionManagerMysql" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="emfMysql"/>
</bean>
<bean id="emfMysql" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="jdbc/testdb1" />
<property name="persistenceXmlLocation" value="classpath:persistence-infrastructure.xml" />
<property name="persistenceUnitName" value="puMysql" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.max_fetch_depth">3</prop>
<prop key="hibernate.jdbc.fetch_size">50</prop>
<prop key="hibernate.jdbc.batch_size">10</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<jpa:repositories base-package="domain.data.repository"
entity-manager-factory-ref="emfMysql"
transaction-manager-ref="transactionManagerMysql"/>
PART 2 (PERSISTENCE XML FILE):
<persistence-unit name="puMysql" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>domain.Mysqltable1</class>
<properties>
<property name="hibernate.connection.datasource" value="jdbc/testdb1"/>
</properties>
</persistence-unit>
I get an exception:
Error creating bean with name 'emfMysql' defined in class path resource [datasource-tx-jpa-infrastructure.xml]: Cannot resolve reference to bean 'jdbc/testdb1' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'jdbc/testdb1' is defined
I hope someone can help me :)
Thanks ahead
It said that the datasource resource you defined in tomcat server.xml is not a bean in spring. You should define a datasource bean like this:
<bean id="dbDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/DatabaseName"/>
</bean>
And use this bean instead of jndi name for datasource property of emfMysql.
Please refer this answer

Tiles 3 with spring MVC 3 integration not working

First time I am trying to integrate Tiles3 with spring MVC 3. My Spring servlet has the following entries:
<bean id="tilesviewResolver" class="org.springframework.web.servlet.view.tiles3.TilesViewResolver" p:order="0"/>
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles.xml</value>
</list>
</property>
</bean>
The jar files I have in my project's class path are:
commons-beanutils-1.8.0.jar
commons-digester-2.0.jar
commons-lang-2.4.jar
commons-logging-1.0.4.jar
jstl-1.2.jar
log4j-1.2.16.jar
logback-access-1.0.0.jar
logback-classic-1.0.0.jar
logback-core-1.0.0.jar
logback-examples-1.0.0.jar
mysql-connector-java-5.0.5-bin.jar
org.springframework.asm-3.0.1.RELEASE-A.jar
org.springframework.beans-3.0.1.RELEASE-A.jar
org.springframework.context-3.0.1.RELEASE-A.
org.springframework.core-3.0.1.RELEASE-A.jar
org.springframework.expression-3.0.1.RELEASE
org.springframework.jdbc-3.0.1.RELEASE-A.jar
org.springframework.transaction-3.0.1.RELEAS
org.springframework.web-3.0.1.RELEASE-A.jar
slf4j-api-1.5.8.jar
slf4j-log4j12-1.5.10.jar
tiles-api-3.0.3.jar
tiles-autotag-core-runtime-1.1.0.jar
tiles-compat-3.0.3.jar
tiles-core-3.0.3.jar
tiles-el-3.0.3.jar
tiles-extras-3.0.3.jar
tiles-freemarker-3.0.3.jar
tiles-jsp-3.0.3.jar
tiles-mvel-3.0.3.jar
tiles-ognl-3.0.3.jar
tiles-request-api-1.0.3.jar
tiles-request-freemarker-1.0.3.jar
tiles-request-jsp-1.0.3.jar
tiles-request-mustache-1.0.3.jar
tiles-request-servlet-1.0.3.jar
tiles-request-servlet-wildcard-1.0.3.jar
tiles-request-velocity-1.0.3.jar
tiles-servlet-3.0.3.jar
tiles-template-3.0.3.jar
tiles-velocity-3.0.3.jar
But I am getting the error:
Cannot find class [org.springframework.web.servlet.view.tiles3.TilesConfigurer] for bean with name 'tilesConfigurer' defined in ServletContext resource [/WEB-INF/thinkTank-servlet.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.web.servlet.view.tiles3.TilesConfigurer
thinkTank-servlet.xml is my spring servlet, can anyone help, what I am doing wrong:
You need spring 3.2 for the org.springframework.web.servlet.view.tiles3 classes.
If for some reason you can't upgrade then you can download just the classes you need here from http://wever.org/spring-webmvc-tiles3-3.2.0.RC2-finn-1.jar
That jar file should be compatible with the spring 3.0.1 you have, but i would still recommend upgrading to 3.2 if you can.
add this snipt in your spring servlet
<beans:bean id="tilesViewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<beans:property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView" />
</beans:bean>
<beans:bean class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<beans:property name="definitions">
<beans:list>
<beans:value>/WEB-INF/spring/appServlet/views.xml</beans:value>
</beans:list>
</beans:property>
</beans:bean>

Application not working after modify dispatcher-servlet.xml in spring mvc

I'm new to the spring framework. Currently I studying about spring framework. I follow this tutorials,
http://netbeans.org/kb/docs/web/quickstart-webapps-spring.html
http://static.springsource.org/docs/Spring-MVC-step-by-step/part1.html
But I have a problem in both example, after adding beans to dispather-servlet.xml and modify application-contex.xml application is not deploy. It gives following massage.
In-place deployment at C:\Users...\Documents\NetBeansProjects\springapp\build\web
Initializing...
deploy?DEFAULT=C:\Users...\Documents\NetBeansProjects\springapp\build\web&name=springapp&contextroot=/springapp&force=true failed on GlassFish Server 3.1.2
Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.ClassNotFoundException: springapp.web.HelloController. Please see server.log for more details.
C:\Users...\Documents\NetBeansProjects\springapp\nbproject\build-impl.xml:728: The module has not been deployed.
See the server log for details.
BUILD FAILED (total time: 2 seconds)
Please help to solve this.
Thank you in advance.
PS:-
#shazinltc -
Here is my dispatcher-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="index.htm">indexController</prop>
</props>
</property>
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />
<bean name="indexController"
class="org.springframework.web.servlet.mvc.ParameterizableViewController"
p:viewName="index" />
<bean name="helloService" class="service.HelloService" />
I manage to solve my problem with following tutorial.
https://sites.google.com/site/springmvcnetbeans/step-by-step/
This tutorial is quite simple and more specific and descriptive in each step. I recommend this tutorial for beginners in spring.

Flex + Spring + BlazeDS + Glassfish + OpenMQ - How do you configure the web-application-config for OpenMQ?

I have the spring-flex-testdrive example (JMS chat application which uses a Topic to pub/sub messages) to work on Tomcat with ActiveMQ now I want to run this example on Glassfish with OpenMQ.
This is a related sample config I found online but it doesn't quite work for the Flex/Glassfish/OpenMQ/BlazeDs/Spring-Integration technology combination.
(Link)
I can deploy it on Glassfish but it can't connect to the destination. I've seen forums mention just replace ActiveMQ with OpenMQ classes/bean declarations but that does not appear to be the case. How do you configure the web-application-context.xml for OpenMQ? What are the common gotcha's?
Thanks.
<bean id="connectionFactory" class="CustomOpenMqConnectionFactoryBean">
<property name="imqAddressList" value="localhost:7676" />
<property name="imqDefaultUsername" value="admin" />
<property name="imqDefaultPassword" value="admin" />
</bean>
<bean id="chatTopic" class="com.sun.messaging.Topic">
<constructor-arg type="java.lang.String" value="cTopic"/>
</bean>

Resources