JasperReports - Numerical Values Are Not Recognized When Exporting to Excel - export

I've created a report in iReport which contains numerical values. These values are of type java.math.BigDecimal. After exporting the report to xls (using iReport) the cells containing those numbers are correctly recognized. It is possible to change the number format, add decimal places and so on. To accomplish that I added the following line to the report definition:
<property name="net.sf.jasperreports.export.xls.detect.cell.type" value="true"/>
My problem is that the export to Excel does not work on the server (JasperServer 4.1.0). I already changed the property net.sf.jasperreports.export.xls.detect.cell.type=true in the file jasperreports.properties. Unfortunately that didn't solve the problem. I've also checked the spring-bean xlsExportParameter and the property detectCellType is also set to true. Did I miss anything or could there be a problem with the exporter on the server?
Thanks a lot!

You can try to change detectCellType property in applicationContext.xml file (you can find it in jasperserver\WEB-INF\ folder) at JasperServer.
<bean id="xlsExportParameters" class="com.jaspersoft.jasperserver.api.engine.jasperreports.common.XlsExportParametersBean">
<property name="detectCellType" value="true"/>
<property name="onePagePerSheet" value="false"/>
<property name="removeEmptySpaceBetweenRows" value="true"/>
<property name="removeEmptySpaceBetweenColumns" value="true"/>
<property name="whitePageBackground" value="false"/>
<property name="ignoreGraphics" value="true"/>
<property name="collapseRowSpan" value="true"/>
<property name="ignoreCellBorder" value="true"/>
<property name="fontSizeFixEnabled" value="true"/>
<property name="maximumRowsPerSheet" value="0"/>
<property name="xlsFormatPatternsMap" ref="formatPatternsMap"/>
</bean>

Related

Came jmsComponent: what's the difference setting the exception Listener in different beans?

I set up a jms component with spring like this way:
<bean id="jmsConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616" />
</bean>
<bean id="cachedConnectionFactory"
class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory" ref="jmsConnectionFactory"/>
<property name="sessionCacheSize" value="10"/>
<property name="exceptionListener" ref="exceptionListener"/>
</bean>
<bean id="jmsConfig"
class="org.apache.camel.component.jms.JmsConfiguration">
<property name="connectionFactory" ref="cachedConnectionFactory"/>
<property name="concurrentConsumers" value="10"/>
</bean>
I notice that all these 4 beans have exceptionListener property. So I wonder what's the difference setting exceptionListener in different beans.
During my test, only setting in CachingConnectionFactory can work, it can go into my ExceptionListener, while in other cases, the exception will be logged somewhere else, but can't go into my code, the exception is like below.
WARN CachingConnectionFactory.onException(322) - Encountered a JMSException - resetting the underlying JMS Connection
javax.jms.JMSException: java.io.EOFException
at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:54)
at org.apache.activemq.ActiveMQConnection.onAsyncException(ActiveMQConnection.java:1983)
at org.apache.activemq.ActiveMQConnection.onException(ActiveMQConnection.java:2002)
at org.apache.activemq.transport.TransportFilter.onException(TransportFilter.java:101)
at org.apache.activemq.transport.ResponseCorrelator.onException(ResponseCorrelator.java:126)
at org.apache.activemq.transport.TransportFilter.onException(TransportFilter.java:101)
at org.apache.activemq.transport.TransportFilter.onException(TransportFilter.java:101)
at org.apache.activemq.transport.WireFormatNegotiator.onException(WireFormatNegotiator.java:160)
at org.apache.activemq.transport.AbstractInactivityMonitor.onException(AbstractInactivityMonitor.java:314)
at org.apache.activemq.transport.TransportSupport.onException(TransportSupport.java:96)
at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:200)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.EOFException
at java.io.DataInputStream.readInt(DataInputStream.java:392)
at org.apache.activemq.openwire.OpenWireFormat.unmarshal(OpenWireFormat.java:275)
at org.apache.activemq.transport.tcp.TcpTransport.readCommand(TcpTransport.java:221)
at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:213)
at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:196)
... 1 more
I can't understand how this works, please give some explanation or hint.
org.springframework.jms.connection.CachingConnectionFactory.exceptionListener set the org.apache.activemq.ActiveMQConnectionFactory.exceptionListener , so this is the same.
org.apache.camel.component.jms.JmsConfiguration.exceptionListener set up the org.springframework.jms.listener.AbstractMessageListenerContainer.exceptionListener
Set the JMS ExceptionListener to notify in case of a JMSException
thrown by the registered message listener or the invocation infrastructure.
so it is nearly the same use of that listener at any level but it is better to set it at the org.apache.camel.component.jms.JmsConfiguration.exceptionListener level to be managed by the spring Container.

Changing default settings for JMS messaging in Camel

I've found only a way to specify JMS settings directly on end points, but I would like to change default values, so that we do not have to remember to set the same value on each endpoint.
Below there are few examples of properties which I would like to set globally:
from("jms:topic:xyx?concurrentConsumers=1") I would be good to have an option to set different concurrentConsumers value for queues and topics.
from("jms:queue:abc?receiveTimeout=60000&concurrentConsumers=1")
Enable transaction for each JMS Message, so I do not have to call from(...).transacted()
You can always define your components as a bean and reuse them everywhere. In your case, you can have:
<bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="concurrentConsumers" value="1"/>
<property name="transacted" value="true"/>
</bean>

Google App Engine & JDO: Transaction is not written to the datastore

We are using GAE with JDO2.3 and have this code:
public void submit_job (HttpSession session, BlobKey blobKey) throws Exception {
// START TRANSACTION
PersistenceManager pm = PMF.get().getPersistenceManager();
Transaction tx = pm.currentTransaction();
tx.begin();
// GET JOB AND MEMBER FROM DATASTORE
Key jobKey = (Key)session.getAttribute("jobkey");
String userName = session.getAttribute("username").toString();
Job job = pm.getObjectById(Job.class, jobKey);
Member m = pm.getObjectById(Member.class, username);
// STORE JOB INFORMATION IN DATASTORE
Date now = new Date();
job.caricature = blobKey;
job.whenSubmitted = now;
job.whenFinished = now;
pm.makePersistent(job);
pm.flush();
log.warning("submit_job: updating job " + job.key);
// UPDATE MEMBER INFORMATION
m.numSubmittedJobs++;
pm.makePersistent(m);
pm.flush();
log.warning("submit_job: updating user " + username);
// COMPLETE TRANSACTION
tx.commit();
pm.close();
log.warning("transaction completed? " + !tx.isActive());
}
The symptoms:
no exception is thrown, everything runs fine
at the end, the transaction is properly completed ("transaction completed? true")
following queries can read the updated data from the Member and Job objects
BUT
the information does not show up in the datastore manager
after restarting the instance, the JDO objects have their old values. ALL CHANGES ARE LOST.
Here is our jdoconfig.xml:
<?xml version="1.0" encoding="utf-8"?>
<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig">
<persistence-manager-factory name="transactions-optional">
<property name="javax.jdo.PersistenceManagerFactoryClass"
value="org.datanucleus.api.jdo.JDOPersistenceManagerFactory"/>
<property name="javax.jdo.option.ConnectionURL" value="appengine"/>
<property name="javax.jdo.option.NontransactionalRead" value="true"/>
<property name="javax.jdo.option.NontransactionalWrite" value="true"/>
<property name="javax.jdo.option.RetainValues" value="true"/>
<property name="datanucleus.appengine.autoCreateDatastoreTxns" value="true"/>
<property name="datanucleus.appengine.singletonPMFForName" value="true"/>
<property name="datanucleus.appengine.datastoreEnableXGTransactions" value="true"/>
</persistence-manager-factory>
</jdoconfig>
and the persistence.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<persistence
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="transactions-optional">
<provider>org.datanucleus.api.jpa.PersistenceProviderImpl</provider>
<properties>
<property name="datanucleus.NontransactionalRead" value="true"/>
<property name="datanucleus.NontransactionalWrite" value="true"/>
<property name="datanucleus.ConnectionURL" value="appengine"/>
</properties>
</persistence-unit>
</persistence>
Any help is appreciated, we already put a lot of effort into this topic, but are unable to solve it yet.
Thanks!
So you're setting public fields of a persistable class, and somehow expect the persistence mechanism to know about this. As per the JDO spec, you should use setters, or annotate the class doing the setting as PersistenceAware.
And look at the log too, since it tells you what is happening

"Cannot rollback() inside an XASession" error on Fuse ESB 7.1.0

Yesterday I tried to migrate my bundles from ServiceMix 4.4.1 to Fuse ESB Enterprise 7.1.0. Bundles with local transactions work fine, but other ones with XA transaction don't work well. They write continuously tracebacks with the following messages to the log file:
13:30:29,283 | WARN | cation-stageOne] | PooledSession | 139 - org.apache.activemq.activemq-spring - 5.7.0.fuse-71-047 | Caught exception trying rollback() when putting session back into the pool, will invalidate. javax.jms.TransactionInProgressException: Cannot rollback() inside an XASession
javax.jms.TransactionInProgressException: Cannot rollback() inside an XASession
at org.apache.activemq.ActiveMQXASession.rollback(ActiveMQXASession.java:76)279:org.apache.activemq.activemq-core:5.7.0.fuse-71-047
at org.apache.activemq.pool.PooledSession.close(PooledSession.java:120)139:org.apache.activemq.activemq-spring:5.7.0.fuse-71-047
at org.springframework.jms.connection.JmsResourceHolder.closeAll(JmsResourceHolder.java:193)153:org.springframework.jms:3.0.7.RELEASE
at org.springframework.jms.connection.ConnectionFactoryUtils$JmsResourceSynchronization.releaseResource(ConnectionFactoryUtils.java:412)153:org.springframework.jms:3.0.7.RELEASE
at org.springframework.jms.connection.ConnectionFactoryUtils$JmsResourceSynchronization.releaseResource(ConnectionFactoryUtils.java:1)153:org.springframework.jms:3.0.7.RELEASE
at org.springframework.transaction.support.ResourceHolderSynchronization.afterCompletion(ResourceHolderSynchronization.java:98)148:org.springframework.transaction:3.0.7.RELEASE
at org.springframework.transaction.support.TransactionSynchronizationUtils.invokeAfterCompletion(TransactionSynchronizationUtils.java:168)148:org.springframework.transaction:3.0.7.RELEASE
at org.springframework.transaction.support.AbstractPlatformTransactionManager.invokeAfterCompletion(AbstractPlatformTransactionManager.java:996)148:org.springframework.transaction:3.0.7.RELEASE
at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerAfterCompletion(AbstractPlatformTransactionManager.java:971)148:org.springframework.transaction:3.0.7.RELEASE
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:799)148:org.springframework.transaction:3.0.7.RELEASE
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)148:org.springframework.transaction:3.0.7.RELEASE
at org.apache.aries.transaction.GeronimoPlatformTransactionManager.commit(GeronimoPlatformTransactionManager.java:76)
at sun.reflect.GeneratedMethodAccessor243.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25):1.6.0_35
at java.lang.reflect.Method.invoke(Method.java:597):1.6.0_35
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)110:org.springframework.aop:3.0.7.RELEASE
at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58)114:org.springframework.osgi.core:1.2.1
at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62)114:org.springframework.osgi.core:1.2.1
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)110:org.springframework.aop:3.0.7.RELEASE
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)110:org.springframework.aop:3.0.7.RELEASE
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)110:org.springframework.aop:3.0.7.RELEASE
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)110:org.springframework.aop:3.0.7.RELEASE
at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:56)114:org.springframework.osgi.core:1.2.1
at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:39)114:org.springframework.osgi.core:1.2.1
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)110:org.springframework.aop:3.0.7.RELEASE
at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)114:org.springframework.osgi.core:1.2.1
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)110:org.springframework.aop:3.0.7.RELEASE
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)110:org.springframework.aop:3.0.7.RELEASE
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)110:org.springframework.aop:3.0.7.RELEASE
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)110:org.springframework.aop:3.0.7.RELEASE
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)110:org.springframework.aop:3.0.7.RELEASE
at $Proxy178.commit(Unknown Source)[:]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:257)153:org.springframework.jms:3.0.7.RELEASE
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1058)153:org.springframework.jms:3.0.7.RELEASE
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1050)153:org.springframework.jms:3.0.7.RELEASE
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:947)153:org.springframework.jms:3.0.7.RELEASE
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886):1.6.0_35
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908):1.6.0_35
at java.lang.Thread.run(Thread.java:662):1.6.0_35
It happens with an empty queue.
My activemq endpoint configuration looks as following:
<osgi:reference id="osgiPlatformTransactionManager" interface="org.springframework.transaction.PlatformTransactionManager"/>
<osgi:reference id="osgiJtaTransactionManager" interface="javax.transaction.TransactionManager"/>
<bean id="jmstx" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="configuration" ref="jmsTxConfig" />
</bean>
<bean id="jmsTxConfig" class="org.apache.camel.component.jms.JmsConfiguration">
<property name="connectionFactory" ref="jmsXaPoolConnectionFactory"/>
<property name="transactionManager" ref="osgiPlatformTransactionManager"/>
<property name="transacted" value="true"/>
<property name="cacheLevelName" value="CACHE_NONE"/>
<property name="concurrentConsumers" value="${jms.concurrentConsumers}" />
</bean>
<bean id="jmsXaPoolConnectionFactory" class="org.apache.activemq.pool.XaPooledConnectionFactory">
<property name="maxConnections" value="${jms.maxConnections}" />
<property name="connectionFactory" ref="jmsXaConnectionFactory" />
<property name="transactionManager" ref="osgiJtaTransactionManager" />
</bean>
<bean id="jmsXaConnectionFactory" class="org.apache.activemq.ActiveMQXAConnectionFactory">
<property name="brokerURL" value="${jms.broker.url}"/>
<property name="redeliveryPolicy">
<bean class="org.apache.activemq.RedeliveryPolicy">
<property name="maximumRedeliveries" value="-1"/>
<property name="initialRedeliveryDelay" value="2000" />
<property name="redeliveryDelay" value="5000" />
</bean>
</property>
</bean>
This endpoint is used very easy in the camel context as:
<route id="route">
<from uri="jmstx:queue:somequeue" />
<!-- some logic here -->
</route>
I would be glad if someone can help me to solve this issue. I can provide more deatails if it necessary.
EDIT
It seems that the issue is connected to the JMS connection pool: when I change connection factory to a simple ActiveMQXAConnectionFactory, then the exception disappears.
This is a known problem in the activemq-pool of version 5.7.0 (and most likely earlier versions) and has been reported http://fusesource.com/issues/browse/ENTMQ-441.

Camel - using custom jmsOperations: cannot be cast to org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate

I want to use a custom jmsOperations, when I try that I get a class cast exception: cannot be cast to org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate
Config :
<bean id="jmsErf" class="org.apache.camel.component.jms.JmsComponent">
<property name="jmsOperations" ref="myJmsTemplate" />
<property name="preserveMessageQos" value="true"/>
<property name="explicitQosEnabled" value="false"/>
<property name="testConnectionOnStartup" value="true"/>
<!--property name="useMessageIDAsCorrelationID" value="true" / WARNING! Do not use this as we need to copy only in the beginning not everywhere -->
<property name="transactionManager" ref="jpaTransactionManager" />
<property name="transacted" value="true" />
</bean>
<bean name="myJmsTemplate" class="blabla.MyJmsTemplate">
<property name="connectionFactory">
<bean class="jms.MQConnectionFactory">
<property name="queueManagerName" value="${Queue.My.manager}" />
<property name="throwOnInvalidMessageProperty" value="false" />
</bean>
</property>
</bean>
Sample class I created
MyJmsTemplate extends org.springframework.jms.core.JmsTemplate implements
org.springframework.jms.core.JmsOperations { .. no code :)
Why I'm trying jmsOperations:
I just need to have original JMSPriority maintained. Yes I did try preserveQoS explicitQoS [various combinations of enablingetc.. it either sets all priority to 4; or priority remains zero despite setting eg=6 priority]. by creating my own jmsOperations and explictly transfering JMSPriority value.
Exception trace:
Caused by: org.apache.camel.FailedToCreateProducerException: Failed to
create Producer for endpoint:
Endpoint[jmsErf://queue:MQDEV.MYQ.ERROR]. Reason:
java.lang.ClassCastException: blabla.MyJmsTemplate cannot be cast to
org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate at
org.apache.camel.component.jms.JmsProducer.testConnectionOnStartup(JmsProducer.java:458)
at
org.apache.camel.component.jms.JmsProducer.doStart(JmsProducer.java:469)
at
org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at
org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at
org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:387)
... 115 more Caused by: java.lang.ClassCastException:
bla.MyJmsTemplate cannot be cast to
org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate at
org.apache.camel.component.jms.JmsProducer.testConnectionOnStartup(JmsProducer.java:447)
... 119 more
Can anyone point me to jmsOptions usage in camel?
What Camel version do you use?
You should use a custom messageConverter if you want to map to/from JMS messages yourself.
And the JMSPriority ought to be preserved if you set preserveMessageQos=true.

Resources