Spring Tiles Integration Error - spring

I am trying to integrate Tiles 3.0.0 with Spring 3.1, I have all the tile jar files under my lib folder. When I run the web project I get an
java.lang.ClassNotFoundException: org.apache.tiles.startup.BasicTilesInitializer
error. I need some help understanding why I am getting this error. Here is my configuration to setup in my servlet.xml page.
<bean class="org.springframework.web.servlet.view.tiles2.TilesViewResolver" />
<bean class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/views/**/views.xml</value>
</list>
</property>
</bean>
Here is a question that's a lot like mine, link, but I've already got my tiles-core-3.0.0 in my build path. So I just need some help understanding how to get over this error.
Morgan

At the time of writing this, Spring still does not support Tiles 3. I'm using Spring 3.1.2 and had to downgrade Tiles back to version 2.2.2 in order for my application to run.

I've make a program working with Spring Framework version 3.2.13.RELEASE and Tiles-3 (version 3.0.5). You need to use following configuration
<bean id="tilesConfigurer"
class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles/tiles-definitions.xml</value>
</list>
</property>
</bean>
with dependency
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-extras</artifactId>
<version>3.0.5</version>
</dependency>
<!-- Spring Web MVC -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.2.13.RELEASE</version>
</dependency>
I think this is what you're trying to achieve. It works fine in my case !

Related

HazelCast Hibernate52 - Throws Unable to resolve name com.hazelcast.hibernate.HazelcastCacheRegionFactory

I'm trying to create a second level cache using hazelcast-hibernate52 (which supports hibernate 5.2.12.Final, I guess) when I run it throws the following exception
Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [com.hazelcast.hibernate.HazelcastCacheRegionFactory] as strategy [org.hibernate.cache.spi.RegionFactory]
at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:126)
at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.resolveStrategy(StrategySelectorImpl.java:194)
at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.resolveStrategy(StrategySelectorImpl.java:161)
at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:67)
at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:28)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:259)
... 47 more
Below are my Spring hazel configurations
<hz:hazelcast id="instance">
<hz:config>
<hz:instance-name>hazelcast</hz:instance-name>
<!-- <hz:spring-aware /> -->
<hz:group name="dev" password="dev-password"/>
<hz:management-center enabled="true" url="http://localhost:9008/hazelcast-mancenter"/>
<hz:properties>
<hz:property name="hazelcast.merge.first.run.delay.seconds">5</hz:property>
<hz:property name="hazelcast.merge.next.run.delay.seconds">5</hz:property>
</hz:properties>
<hz:network port="5701" port-auto-increment="false" port-count="1">
<hz:join>
<!-- Enable for auto detection -->
<hz:multicast enabled="true" />
<hz:tcp-ip enabled="false">
<hz:members>120.0.0.1</hz:members>
</hz:tcp-ip>
</hz:join>
<hz:interfaces>
<hz:interface>120.0.0.*</hz:interface>
</hz:interfaces>
</hz:network>
These are my spring hibernate configurations
<bean id="tpSessionFactory"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="tpDataSource"></property>
<property name="hibernateProperties">
<props>
<!-- <prop key="hibernate.dialect">${db.dialect}</prop> -->
<prop key="hibernate.show_sql">${db.show_sql}</prop>
<prop key="hibernate.hbm2ddl.auto">${db.hbm2ddl.auto}</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.region.factory_class">com.hazelcast.hibernate.HazelcastCacheRegionFactory</prop>
<prop key="hibernate.cache.hazelcast.instance_name">hazelcast</prop>
</props>
and the dependencies which are used are:
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-all</artifactId>
<version>3.10.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-spring</artifactId>
<version>3.10.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-hibernate52</artifactId>
<version>1.2</version>
</dependency>
Is there anything which i'm missing in here?
#Clovrr, a couple of things I can see:
hibernate 5.2.12 support added in 1.2.2 version. Can you upgrade to 1.2.2 or latest 1.2.3 version?
Don't add hazelcast-all since it contains hazelcast-hibernate for Hibernate 3.X. Just use hazelcast-spring dependency, it'll get all necessary hazelcast dependencies.
Please check those & try again.
Problem with hazelcast-hibernate52 dependency.
Looks like the dependency isn't updating or could be some other reasons.
what I did is,
look the git code from here, built a jar out of it and included that into my classpath. Voila! everything seems to work well and good.

Spring Config for the Ignite

I have a block of the spring Configuration of Ignite. The current scenario as below:
We want to deploy the Ignite Cache in the Different Stand-alone Servers. And modify the existing code to access the Ignite Cache Server, then using the spring #Cacheable Annotation to implement the cache. My configuration as blow:
<bean id="igniteCacheManager" class="org.apache.ignite.cache.spring.SpringCacheManager">
<property name="igniteInstanceName" value="myGrid"/>
<property name="configuration">
<bean id="gridCfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
<property name="addresses">
<list>
<value>(server Ip Address)</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
</bean>
</property>
</bean>
But it doesn't work, and the Spring application can't startup now.
it shows the error message
Caused by: org.h2.jdbc.JdbcSQLException: General error: "java.lang.IncompatibleClassChangeError: Implementing class" [50000-192]
could you help to do me a favor, whether our solution is feasible? and how to config the spring to access the stand-alone ignite server?
Thank you very much
Have you included h2 dependency ? If not , try to add this dependency in your pom.xml.
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.196</version>
</dependency>

java.lang.ClassCastException: com.ibm.ws.tx.jta.TranManagerSet incompatible with javax.transaction.TransactionManager

I am getting class cast exception while trying to Index the entity through Hibernate5 Search API on Websphere 8.5.5.10. The transactions are being managed by Spring Transaction. The document entities are getting indexed properly on local tomcat but not on WebSphere.
I have created a RESTFUl web service call to index the entities.
Spring 4.2
Hibernate Core 5.0.11.Final
Hibernate Search 5.5.5.Final
Here is my config file
<bean id="sessionFactory"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="datasource" />
<property name="packagesToScan">
<list>
<value>model</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">false</prop>
<prop key="hibernate.default_schema">dev</prop>
<prop key="hibernate.generate_statistics">true</prop>
<prop key="hibernate.search.default.directory_provider">filesystem</prop>
<prop key="hibernate.search.default.indexBase">/var/lucene/indexes</prop>
</props>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
And the stack trace in websphere app logs:-
HSEARCH000058: HSEARCH000116: Unexpected error during MassIndexer operation
org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException: Could not obtain WebSphere TransactionManager
at org.hibernate.engine.transaction.jta.platform.internal.WebSphereJtaPlatform.locateTransactionManager(WebSphereJtaPlatform.java:66)
at org.hibernate.engine.transaction.jta.platform.internal.AbstractJtaPlatform.retrieveTransactionManager(AbstractJtaPlatform.java:87)
at org.hibernate.search.batchindexing.impl.BatchTransactionalContext.lookupTransactionManager(BatchTransactionalContext.java:53)
at org.hibernate.search.batchindexing.impl.BatchTransactionalContext.(BatchTransactionalContext.java:42)
at org.hibernate.search.batchindexing.impl.BatchIndexingWorkspace.runWithErrorHandler(BatchIndexingWorkspace.java:118)
at org.hibernate.search.batchindexing.impl.ErrorHandledRunnable.run(ErrorHandledRunnable.java:32)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:483)
at java.util.concurrent.FutureTask.run(FutureTask.java:274)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1157)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:627)
at java.lang.Thread.run(Thread.java:798)
Caused by: java.lang.ClassCastException: com.ibm.ws.tx.jta.TranManagerSet incompatible with javax.transaction.TransactionManager
at org.hibernate.engine.transaction.jta.platform.internal.WebSphereJtaPlatform.locateTransactionManager(WebSphereJtaPlatform.java:63)
I am not sure what am I doing wrong here. Apart from Index Webservice call, other REST webservices are running fine and my UI is populating as expected.
Any help will be much appreciated.
We ran into this issue.
Issue:
If we use a hibernate version that uses JPA 2.1 (> hibernate version 4.3), it will conflict with older versions of websphere (versions 7, 8.5 without the JPA 2.1 fix packs). Specifically the exception you would see is this:
nested exception is java.lang.NoSuchMethodError: javax/persistence/Table.indexes()[Ljavax/persistence/Index;
Solution 1:
One way to resolve this issue is setting the classloader to parent_last so that JPA 2.1 that ships with hibernate will be used. However, you will run into other problems like the ones mentioned above.
Conflict with TransactionManager that ships with hibernate, Exception:
java.lang.ClassCastException: com.ibm.ws.tx.jta.TranManagerSet incompatible
with javax.transaction.TransactionManager
This can be solved by excluding the following jar (example maven
configuration for the hibernate dependency) that causes the
conflict:
<exclusion>
<artifactId>jboss-transaction-api_1.2_spec</artifactId>
<groupId>org.jboss.spec.javax.transaction</groupId>
</exclusion>
Conflict with xml-apis.jar that ships with hibernate resulting in the exception:
javax.xml.parsers.FactoryConfigurationError: Provider for javax.xml.parsers.DocumentBuilderFactory cannot be found
This can be resolved by excluding the xml-apis.jar from hibernate
dependency like so:
<exclusion>
<artifactId>xml-apis</artifactId>
<groupId>xml-apis</groupId>
</exclusion>
Solution 2:
Use a custom PersistenceProviderResolver so that the Websphere classes do not interfere with Hibernate:
https://stackoverflow.com/a/37354979/5150013
According to this article, this is a conflict between 2 different versions of java.transaction packages (one is in websphere, one in GemFire.jar, a lib deployed with websphere).
It also suggests a fix :
Drop the package javax.transaction from GemFire.jar: zip -d gemfire.jar javax/transaction/*
Hope this helps.
From SpringBoot version 2.2.0.RELEASE, there is transaction manager api used from jakarta. In case you want to make it work just exclude
<dependency>
<groupId>jakarta.transaction</groupId>
<artifactId>jakarta.transaction-api</artifactId>
</dependency>
from
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
The basic thought is to have only one transaction manager. Here we are removing the one being provided from the sprintboot-jpa

HornetQConnectionFactory is not javax.jms.ConnectionFactory

I have a spring-bean of connectionFactory to hornetQ:
<bean name="connectionFactory" class="org.hornetq.jms.client.HornetQConnectionFactory" >
<constructor-arg value="false" />
<constructor-arg ref="transportConfiguration" />
</bean>
and, this bean are using it:
<bean name="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="connectionFactory"></property>
</bean>
All fails with that exception when 'jmsTemlpate' bean is starting:
Failed to convert property value of type
'org.hornetq.jms.client.HornetQConnectionFactory' to required type
'javax.jms.ConnectionFactory'
I.e. jmsTemplate requires connectionFactory to be a javax.jms.ConnectionFactory, but it is not.
The question, how and where download the right implementation of 'HornetQConnectionFactory' to meet the requirements.
I use this deps in my pom.xml:
<hornetq.version>2.2.13.Final</hornetq.version>
...
<dependency>
<groupId>org.hornetq</groupId>
<artifactId>hornetq-core</artifactId>
<version>${hornetq.version}</version>
</dependency>
<dependency>
<groupId>org.hornetq</groupId>
<artifactId>hornetq-jms</artifactId>
<version>${hornetq.version}</version>
</dependency>
<dependency>
<groupId>org.hornetq</groupId>
<artifactId>hornetq-spring-integration</artifactId>
<version>${hornetq.version}</version>
</dependency>
The best way to do this is to use HornetQJMSClient.createConnectionFactory methods
You were using the implementation directly and that's subjected to change.
The HornetQJMSClient is part of the API and hence the contract is better kept between releases.
You should convert your example to use HornetQJMSClient...
Regarding the blog you found this, perhaps you should point to this question / answer as the blog is using the internal implementation and not the public API.
I guess I found the solution:
just using HornetQJMSConnectionFactory (with JMS word inside).
It seems there was old implementation of HornetQConnectionFactory wich was a javax.jms.ConnectionFactory, but now it is not.

How to start a Maven Spring JSF 2.0 Richfaces project?

For some of you it might sound trvial, but for days I have been fighting with pom.xml files and facets in order to build a Spring JSF 2.0 Maven project (run on tomcat 7.0) with RichFaces, but with no success. Can someone please reference me to a full working example ,I am using STS (tutorial from scratch , I can download a fully working example but I want to learn how to create one ) ?
So after few days of work I came to the conclusion I have to do the dirty work therefore I will explain how I managed to start a project :
download sts
open template project , in my case it was spring integration with hibernate
right click on project-> preferences->facets
change to JSF 2.0 and web dynamic above 2.5(require above 1.5 java )
add to the maven dependencies ( pom.xml ):
<!-- spring hibernate 3 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-hibernate3</artifactId>
<version>2.0.8</version>
</dependency>
set up your
<property name="dataSource" ref="dataSource" />
the ref is pointed to this bean :
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
<property name="url" value="jdbc:hsqldb:mem:."/>
<property name="username" value="sa"/>
<property name="password" value=""/>
</bean>
or any other you decide ...
add to your project pom :
<dependency>
<groupId>org.richfaces.framework</groupId>
<artifactId>richfaces-impl</artifactId>
<version>3.2.2.GA</version>
</dependency>
<dependency>
<groupId>org.richfaces.ui</groupId>
<artifactId>richfaces-ui</artifactId>
<version>3.2.2.GA</version>
</dependency>
start praying it will work :)

Resources