Jboss Service depending on JNDI resource - service

I have written a Jboss4 MBean which relies on other JNDI resource named XAOracleDS and defined in an xml datasource file (*-ds.xml). But when I restart my JBoss instance, I have a
javax.naming.NameNotFoundException: XAOracleDS not bound
due to the implementation of my service. I tried to fix this by updating my jboss-service.xml file adding a dependency to the Jboss naming service
...
<depends>jboss:service=Naming</depends>
...
, but it didn't work.
Here is my jboss-service.xml
<server>
<classpath codebase="lib" archives="scheduler-plugin.jar" />
<mbean code="org.jboss.varia.scheduler.Scheduler" name="DefaultDomain:service=MigrationScheduler">
<attribute name="StartAtStartup">true</attribute>
<attribute name="SchedulableClass">MyScheduler</attribute>
<attribute name="InitialStartDate">NOW</attribute>
<attribute name="InitialRepetitions">1</attribute>
<attribute name="SchedulePeriod">1000</attribute>
<depends>jboss:service=Naming</depends>
</mbean>
Does anyone have an idea of what's wrong?

I ran into a similar issue a while back and not 100% sure whether it applies to you. Found that the files are deployed alphabetically. So try renaming your *-ds.xml files with say abc-ds.xml and see if it helps.

Related

Rest DSL restConfiguration way to dynamically inject Jetty port from jetty.xml

can you dynamically inject the port set in the jetty.xml config file?
I have multiple jboss fuse containers running, each has a different configuration of ports from rmiRegistryPort, to jetty.port. I would like to be able to just inject the port value from the jetty.xml. if i am using camel-jetty, do I need to worry about setting the port as it automatically takes if from this file???
restConfiguration()
.component("jetty")
.host("localhost")
.port(getPort())
.scheme("https")
.bindingMode(RestBindingMode.json)
.jsonDataFormat("json-jackson")
.dataFormatProperty("prettyPrint", "true");
I don't know myself, but the Camel REST DSL Docs say:
if you use servlet component then the port number configured here does not apply, as the port number in use is the actual port number the servlet component is using, e.g., if using Apache Tomcat its the tomcat HTTP port, if using Apache Karaf it's the HTTP service in Karaf that uses port 8181 by default etc. Though in those situations setting the port number here, allows tooling and JMX to know the port number, so its recommended to set the port number to the number that the servlet engine uses.
Based on this description I assume that:
Camel uses the actual jetty HTTP endpoint
Whatever port you set in the restConfiguration it is ignored for the jetty HTTP endpoint
JMX and other tools only work correct if you set the correct port in the restConfiguration
You have to provide the correct jetty port for the restConfiguration (no auto-magic)
You can use the port value inside an application.properties and read it to set the value.
thanks Victor, yeah, ... I was just wondering if there is some magic under the covers with the Jetty server, I will need to test this out I guess.
since there is a jetty.xml config file under etc/jetty.xml that defines the jetty config... but in every example I see the defining of a port ... it looks like it is possible if enabled ??? but I don't know. reason is I have 8 different JBoss Fuse containers running all having different etc/configs to keep from port conflicts.
inside jetty.xml
<!-- =========================================================== -->
<!-- Special server connectors -->
<!-- =========================================================== -->
<!-- This is a sample for alternative connectors, enable if needed -->
<!-- =========================================================== -->
<!--
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.ServerConnector">
<Arg name="server">
<Ref refid="Server" />
</Arg>
<Arg name="factories">
<Array type="org.eclipse.jetty.server.ConnectionFactory">
<Item>
<New class="org.eclipse.jetty.server.HttpConnectionFactory">
<Arg name="config">
<Ref refid="httpConfig" />
</Arg>
</New>
</Item>
</Array>
</Arg>
<Set name="host">
<Property name="jetty.host" default="localhost" />
</Set>
<Set name="port">
<Property name="jetty.port" default="8285" />
</Set>
<Set name="idleTimeout">
<Property name="http.timeout" default="30000" />
</Set>
<Set name="name">jettyConn1</Set>
</New>
</Arg>
</Call>

JPA 2.0 Ehcache configuration for L2 cache throwing Error

I am trying to configure Ehcache for JPA 2.0.
first i have setup following into persistance.xml
<property name="hibernate.cache.provider_class" value="net.sf.ehcache.hibernate.SingletonEhCacheProvider"/>
<property name="hibernate.cache.use_query_cache" value="true"/>
<property name="hibernate.cache.use_second_level_cache" value="true"/>
<property name="hibernate.generate_statistics" value="true"/>
I have ehcache.xml in my class path.
configure #Cacheable(true) to my #Entity class.
I am getting following error.
net.sf.ehcache.config.InvalidConfigurationException: There is one error in your configuration:
* Cache 'net.sf.ehcache.constructs.asynchronous.MessageCache' error: If your CacheManager has no maxBytesLocalHeap set, you need to either set maxEntriesLocalHeap or maxBytesLocalHeap at the Cache level
ehcache.xml
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true"
monitoring="autodetect" dynamicConfig="true">
<!-- By default, Ehcache stored the cached files in temp folder. -->
<!-- <diskStore path="java.io.tmpdir" /> -->
<!-- Ask Ehcache to store cache in this path -->
<diskStore path="c:\\cache" />
<!-- Sample cache named cache1
This cache contains a maximum in memory of 10000 elements, and will expire
an element if it is idle for more than 5 minutes and lives for more than
10 minutes.
If there are more than 10000 elements it will overflow to the
disk cache, which in this configuration will go to wherever java.io.tmp is
defined on your system. On a standard Linux system this will be /tmp" -->
<Cache name = "com.test.myDataDE"
maxEntriesLocalHeap="10000"
maxEntriesLocalDisk="1000"
eternal="false"
diskSpoolBufferSizeMB="20"
timeToIdleSeconds="300" timeToLiveSeconds="600"
memoryStoreEvictionPolicy="LFU"
transactionalMode="off">
<persistence strategy="localTempSwap" />
</Cache>
</ehcache>
Please help me understand any mistake I am doing?
I had the same problem today, solved it by adding:
maxBytesLocalHeap="100M"
and removing:
maxEntriesLocalHeap
in my ehcache.xml configuration.
Without your ehcache.xml content, it is hard to be definitive.
However, given the error message, I believe the issue is that you did not specify a heap size to your cache, either in entries or in bytes.

How to configure log4j2 JDBCAppender with DB2 in WebSphere Liberty Profile

I am trying to use the log4j2 JDBCAppender in my Java EE application in WebSphere Liberty Profile with a DataSource. I'm wondering, if I have a configuration error, because I am seeing the following error in my log:
Caused by: java.sql.SQLException: DSRA9350E: Operation Connection.commit is not allowed during a global transaction.
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.commit(WSJdbcConnection.java:778)
at org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager.commitAndClose(JdbcDatabaseManager.java:139)
... 84 more
2014-11-20 20:23:33,663 ERROR An exception occurred processing Appender OneViewPrimaryLogDatabase org.apache.logging.log4j.core.appender.AppenderLoggingException: Failed to commit transaction logging event or flushing buffer.
Here is my log4j config data:
<JDBC name="OneViewPrimaryLogDatabase" tableName="IONEVIEW.LOG">
<DataSource jndiName="jdbc/OneViewPrimaryLogDataSource" />
<Column name="LOGDATE" isEventTimestamp="true" />
<Column name="LOGGER" pattern="%logger" isUnicode="false" />
<Column name="LOGLEVEL" pattern="%level" isUnicode="false" />
<Column name="MESSAGE" pattern="%message" isUnicode="false" />
</JDBC>
And here is my DataSource config from WLP:
<jdbcDriver id="Db2V105JdbcDriver">
<library id="Db2V105JdbcDriverJars">
<fileset dir="C:/IBM/DB2V105/java" includes="db2jcc4.jar db2jcc_license_cisuz.jar"/>
</library>
</jdbcDriver>
<dataSource id="OneViewPrimaryLogDataSource" jdbcDriverRef="Db2V105JdbcDriver" jndiName="jdbc/OneViewPrimaryLogDataSource" type="javax.sql.ConnectionPoolDataSource">
<properties.db2.jcc databaseName="OVHALOGP" password="XXXX" portNumber="60008" user="myuser" serverName="myserver"/>
</dataSource>
Does anyone see anything I might be doing wrong here?
Remko's hint might be correct, for Liberty to achieve that add transactional="false" to datasource definition in server.xml:
<dataSource transactional="false" ...>
Someone resolved this issue by checking "Non-transactional data source" in WAS:
http://websphereissues.wordpress.com/2013/08/30/dsra9350e-operation-connection-commit-is-not-allowed-during-a-global-transaction/
Can you give that a try?

How to connect JMS queues from JBOSS 4 and 5?

I have a server on which a Jboss 4.2.2 and a Jboss 5.1.0 runs. The problem is that a 3rd party is not able to upgrade its application to Jboss 5.1.0 in the near future, for us it is a simple matter. Unfortunately we need to send and receive some JMS messages from the third party app running on Jboss 4.2.2.
What is the easiest way to enable the transfer of JMS messages between JbossMQ and JbossMessaging?
I think I found the solution for my problem. The JBOSS documentation has a chapter to migrate messages between JBOSS Messaging and JBOSS MQ: http://www.redhat.com/docs/en-US/JBoss_Enterprise_Application_Platform/5.0.0.BETA/html/JBoss_Messaging_User_Guide/inst-mqmessagemigration.html
I have 2 topics myTopicSend and myTopicReceive on my JBOSS 4.2 and I have 2 topics myTopicSend5 and myTopicReceive5 on JBOSS 5.1.
I wanted to bridge all messages from myTopicSend to myTopicReceive5 and from myTopicSend5 to MyTopicReceive.
Somehow the configuration didn't work at all first, but after some time of experimenting I have now the following config:
<mbean code="org.jboss.jms.jndi.JMSProviderLoader"
name="jboss.messaging:service=JMSProviderLoader,name=RemoteJBossMQProvider">
<attribute name="ProviderName">RemoteXAConnectionFactory</attribute>
<attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
<attribute name="FactoryRef">XAConnectionFactory</attribute>
<attribute name="QueueFactoryRef">XAConnectionFactory</attribute>
<attribute name="TopicFactoryRef">XAConnectionFactory</attribute>
<attribute name="Properties">
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=127.0.0.1:1099
</attribute>
</mbean>
<mbean code="org.jboss.jms.server.bridge.BridgeService"
name="jboss.messaging:service=Bridge,name=LegayBridgeSend" xmbean-dd="xmdesc/Bridge-xmbean.xml">
<depends optional-attribute-name="SourceProviderLoader">jboss.messaging:service=JMSProviderLoader,name=RemoteJBossMQProvider</depends>
<depends optional-attribute-name="TargetProviderLoader">jboss.messaging:service=JMSProviderLoader,name=JMSProvider</depends>
<attribute name="SourceDestinationLookup">/topic/myTopicSend</attribute>
<attribute name="TargetDestinationLookup">/topic/myTopicReceive5</attribute>
<attribute name="QualityOfServiceMode">0</attribute>
<attribute name="MaxBatchSize">1</attribute>
<attribute name="MaxBatchTime">-1</attribute>
<attribute name="FailureRetryInterval">5000</attribute>
<attribute name="MaxRetries">-1</attribute>
<attribute name="AddMessageIDInHeader">false</attribute>
</mbean>
<mbean code="org.jboss.jms.server.bridge.BridgeService"
name="jboss.messaging:service=Bridge,name=LegayBridgeReceive" xmbean-dd="xmdesc/Bridge-xmbean.xml">
<depends optional-attribute-name="SourceProviderLoader">jboss.messaging:service=JMSProviderLoader,name=JMSProvider</depends>
<depends optional-attribute-name="TargetProviderLoader">jboss.messaging:service=JMSProviderLoader,name=RemoteJBossMQProvider</depends>
<attribute name="SourceDestinationLookup">/topic/myTopicSend5</attribute>
<attribute name="TargetDestinationLookup">/topic/myTopicReceive</attribute>
<attribute name="QualityOfServiceMode">0</attribute>
<attribute name="MaxBatchSize">1</attribute>
<attribute name="MaxBatchTime">-1</attribute>
<attribute name="FailureRetryInterval">5000</attribute>
<attribute name="MaxRetries">-1</attribute>
<attribute name="AddMessageIDInHeader">false</attribute>
</mbean>
A important thing I realized was, to tweak the MaxBatchSize and MaxBatchTime parameters, because I want to deliver the messages immediately to the target queue.
A description of these parameters may be found at http://www.redhat.com/docs/en-US/JBoss_Enterprise_Application_Platform/5.0.0/html/JBoss_Messaging_1.4.6/index.html

JbossESB jmsProvider cannot convert IBMMQ JMS Message JMSTextMessage

I am trying to integrate IBMMQ v6.0.2 with jbossESB.
we have local Queue available on IBMMQ on one of our QA QUEUEMANAGER.
I am able to listen to the QUEUE using JMSprovider of jboss ESB. As soon as a message (of type jms_text ) is dropped , esb listen to it and pick it up and before it hit the next action it throws following error message.
ERROR [JmsComposer] Unsupported JMS message type: com.ibm.jms.JMSTextMessage
Here are the steps I followed.
jboss-service.mxl : Defined Connection Factory and QUEUE
added jars ( com.ibm.mq.* ) to ${jbossesb}/server/${mynode}/lib
Added jms lsinterner configuration on jboss-esb.xml
Please guide me what I m missing here... Do I need to create custom MessagePlugin ?
jboss-esb looks like this
<jms-provider name="WSMQ" connection-factory="MQQueueConnectionFactory">
<jms-bus busid="queuestartGwChannel"> <jms-message-filter
dest-type="QUEUE"
dest-name="wsmq/SerivceOrderQueue"
acknowledge-mode ="AUTO_ACKNOWLEDGE"
/>
</jms-bus>
<jms-bus busid="queuestartEsbChannel">
<jms-message-filter
dest-type="QUEUE"
dest-name="wsmq/SerivceOrderQueue"
/>
</jms-bus>
</jms-provider>
jboss-service.xml looks like this
<mbean code="jmx.service.wsmq.WSMQConnectionFactory"
name="jmx.service.wsmq:service=MQQueueConnectionFactory">
<attribute name="JndiName">MQQueueConnectionFactory</attribute>
<attribute name="JMSStyle">Queue</attribute>
<attribute name="IsXA">false</attribute>
<attribute name="QueueManagerName">SQAT0083</attribute>
<attribute name="HostName">111.111.111.111</attribute>
<attribute name="Port">1415</attribute>
<attribute name="Channel">MYCO.SVRCONN</attribute>
<attribute name="TransportType">CLIENT</attribute>
<depends>jboss:service=Naming</depends>
</mbean>
<mbean code="jmx.service.wsmq.WSMQDestination"
name="jmx.service.wsmq:service=WSMQRequestQueue">
<attribute name="JndiName">wsmq/SerivceOrderQueue</attribute>
<attribute name="JMSStyle">Queue</attribute>
<attribute name="QueueManagerName">SQAT0083</attribute>
<attribute name="DestinationName">MYCO.SERVICEORDER.QA01.QL01</attribute>
<attribute name="TargetClient">MQ</attribute>
<depends>jboss:service=Naming</depends>
</mbean>
I am using jboss-eap-4.3. Really appreciate any help.
Here is my Service Tag Looks like in jboss-esb.xml
<listeners>
<jms-listener name="MQ-Gateway"
busidref="queuestartGwChannel"
is-gateway="true" maxThreads="1"
/>
<jms-listener name="MQ-EsbListener" busidref="queuestartEsbChannel" />
</listeners>
<actions mep="OneWay">
<action name="serviceOrderMarshaller"
class="com.my.esb.actions.ServiceOrderMessageUnMarshallerAction"
process="unmarshalPayload">
<property name="springContextXml" value="spring/mainApplicationContext.xml"/>
</action>
<action name="serviceOrderStaging"
class="com.my.esb.actions.ServiceOrdersStagingAction"
process="stageServiceOrders">
<property name="springContextXml" value="spring/mainApplicationContext.xml"/>
</action>
<action name="marginAndLeadTimeRetriever"
class="com.my.esb.actions.MarginAndLeadTimeRetrieverAction"
process="retrieveJobCodeInfo">
<property name="springContextXml" value="spring/mainApplicationContext.xml"/>
</action>
<action name="createDraftRequestMapper"
class="com.my.esb.actions.CreateDraftRequestMapperAction"
process="mapData">
<property name="springContextXml" value="spring/mainApplicationContext.xml"/>
</action>
<action name="omsCreateDraftRequestTranslator"
class="com.my.esb.actions.OMSCreateDraftRequestTranslatorAction"
process="translateData">
<property name="springContextXml" value="spring/mainApplicationContext.xml"/>
</action>
<action name="createDraftRequestProcessor"
class="com.my.esb.actions.CreateDraftRequestProcessorAction"
process="dispatchRequest">
<property name="springContextXml" value="spring/mainApplicationContext.xml"/>
</action>
</actions>
Bit late response but if someone reads this, the answer is:
queuestartEsbChannel is listening to the same queue that is delivering jmstextmessages and it has is-gateway set to false (default value).
If is-gateway is false, only ESB messages can be recieved on that listener.
I would have expected to see com.ibm.mqjms.jar in the CLASSPATH for a JMS app, not com.ibm.mq.*.
Depending on the version of WMQ you are using, please reference the Environment Variables page in the Infocenter. WMQ V6 page is here (see Table #2), and the WMQ v7 page is here (see the table and the notes below). Note that the classes have been repackaged between versions and the CLASSPATH requirements are quite different.
On UNIX flavors, you can run the setmqjms script to configure the environment for WMQ JMS. It lives in /opt/mqm/java/bin or /usr/mqm/java/bin on AIX. This assumes a standard WMQ client installation, though. If you just grabbed the jars and relocated them, it won't work. In particular, if you just grabbed the com.ibm.mq* jars it likely won't work. You can verify your installation by running the Initial Verification Test (IVT) supplied with the client install. The additional benefit of using a full WMQ client is that all of the trace utilities and sample code and other diagnostics are installed.
One other piece of advice, be sure to use the WMQ v7 client even if the WMQ server is at v6. This is because WMQ v6 is going out of service next year and will not be supported after that. Using the v7 client now will save you a migration later, CLASSPATH changes, etc. In addition, the v7 classes have lots of cool new features when used with a v7 QMgr such as automatic client reconnection to the same or different QMgr, depending on your configuration. The WMQ client install is a free download (registration required) as SupportPac MQC7.