I have the following configs in my IBM Liberty server.xml:
<!-- resource adapter location -->
<variable name="wmqJmsClient.rar.location" value="${shared.resource.dir}/lib/global/wmq.jmsra-9.1.0.0.rar"/>
<!-- jmsActivationSpec configs -->
<jmsActivationSpec authDataRef="myAuthData" id="my-app-name/MyMessageDrivenBean">
<properties.wmqJms destinationRef="jms/MyQueue"
destinationType="javax.jms.Queue"
sslCipherSuite="SSL_RSA_WITH_AES_256_CBC_SHA256"
channel="MY.MQCHANNEL"
queueManager="MY_QM"
hostName="myhost" port="32100"
transportType="CLIENT" />
</jmsActivationSpec>
I also have a message-driven bean I am using to handle messages that appear on the queue. And everything works fine.
I'd like to migrate to open-liberty and keep my JMS stuff but their documentation is a little bit different even though the same config elements are there.
Some properties are missing and it's not clear how to replace them. No hostName and port, instead I found only remoteServerAddress and it has to be a triplet host:port:something_i_dont_understand so not sure it's exactly the same :)
How can I configure all this required stuff in open-liberty to make my message-driven bean work?
Any help is appreciated :)
In WebSphere Liberty you are likely using the wmqJmsClient-2.0 feature. This isn't available in Open Liberty, but it is really only a convenience feature. You should be able to configure the following:
<featureManager>
<feature>jms-2.0</feature>
<feature>jca-1.7</feature>
</featureManager>
<resourceAdapter id="mqJMS" location="${shared.resource.dir}/lib/global/wmq.jmsra-9.1.0.0.rar"/>
<!-- jmsActivationSpec configs -->
<jmsActivationSpec authDataRef="myAuthData" id="my-app-name/MyMessageDrivenBean">
<properties.mqJms destinationRef="jms/MyQueue"
destinationType="javax.jms.Queue"
sslCipherSuite="SSL_RSA_WITH_AES_256_CBC_SHA256"
channel="MY.MQCHANNEL"
queueManager="MY_QM"
hostName="myhost" port="32100"
transportType="CLIENT" />
</jmsActivationSpec>
This configures the jms-2.0 feature, and the jca-1.7 which enables the JMS, and RA support in Liberty. The resourceAdapter element configures Liberty to know about the RA's existence and where it is (similar to the variable you have in your existing configuration). The value of the id attribute is then used on the properties element under the jmsActivationSpec element, so in the wmqJmsClient-2.0 feature we define this to be wmqJms, in this case I've used mqJms because I think wmqJms is reserved. In any case this config should work both in Open Liberty and WebSphere Liberty.
Related
I try to deploy a Java EE Application containing several EJB Timer Services (with persistence=true).
The server complains that no datasource was defined:
Caused by: javax.ejb.EJBException: See nested exception; nested exception is: java.lang.IllegalStateException: The ejbPersistentTimer feature is enabled, but the defaultEJBPersistentTimerExecutor persistent executor cannot be resolved. The most likely cause is that the DefaultDataSource datasource has not been configured. Persistent EJB timers require a datasource configuration for persistence.
The ejbPersistentTimer-3.2 feature is turned on.
I can not find an example how to configure such a datasource in the server.xml file
I tried:
<dataSource id="timerDataSource" jndiName="jdbc/timerDataSource">
</dataSource>
<databaseStore id="EJBTimerDatabaseStore"
tablePrefix="EJBTimer_" dataSourceRef="timerDataSource" />
<persistentExecutor
id="defaultEJBPersistentTimerExecutor"
taskStoreRef="EJBTimerDatabaseStore" />
But this seems to be not enoght? Did I need to activate DerbyDB as a feature too?
It looks like your <dataSource> configuration is missing a few items:
A <jdbcDriver> which points to the JDBC driver jar that corresponds with the DB you are using
A <properties> element which identifies DB properties such as the DB server's hostname, port, and DB name.
Since you mentioned using DerbyDB, here is an example of what Derby config might look like:
<dataSource id="timerDataSource" jndiName="jdbc/timerDataSource">
<jdbcDriver libraryRef="DerbyLib"/>
<properties.derby.embedded databaseName="${server.config.dir}/data/EJBTimerDB" createDatabase="create"/>
</dataSource>
<library id="DerbyLib">
<fileset dir="${server.config.dir}/derbyDriverDir/"/>
</library>
For additional info on configuring DataSources in Liberty, check out this doc:
Configuring relational database connectivity in Liberty
I'm new to JPA and Liberty. Could anyone please explain how to relate/link the server.xml, web.xml and persistence.xml configuration to set up the database connection?
your help on this is much appreciated.
In Liberty, you define the location of the JDBC driver jar files and configure a dataSource element with a JNDI name. This knowledge center page contains an example for MySQL,
https://www.ibm.com/support/knowledgecenter/en/SSEQTP_liberty/com.ibm.websphere.wlp.doc/ae/twlp_dep_configuring_ds.html
Directly quoting from the above page,
<dataSource id="DefaultDataSource" jndiName="jdbc/mySQL">
<jdbcDriver libraryRef="MySQLLib"/>
<properties databaseName="SAMPLEDB" serverName="localhost" portNumber="3306"/>
</dataSource>
<library id="MySQLLib">
<file name="C:/mysql-connector-java-x.x.xx/mysql-connector-java-x.x.xx.jar"/>
</library>
After this, you can configure the jta-data-source element in your persistence.xml pointing at the JNDI name that you chose. For example,
...
<persistence-unit name="ExamplePersistenceUnit">
<jta-data-source>jdbc/mySQL</jta-data-source>
</persistence-unit>
The above is sufficient to get it working, without involving web.xml.
The deployment descriptor (web.xml) gives you the option of adding a level of indirection/mapping and the ability to configure some additional settings such as shareability and container vs application authentication. You can do this by defining a resource reference in web.xml pointing to the data source. Resource references have names in java:comp/env, java:module/env, java:app/env or java:global/env that reflect their visibility. I'll use java:module in the following example, meaning that the reference we are defining is only visibility within the same module (the web module that provides the web.xml),
<resource-ref>
<res-ref-name>java:module/env/jdbc/mySQLRef</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
<lookup-name>jdbc/mySQL</lookup-name>
</resource-ref>
After defining the resource reference above, the data source continues to be available at the JNDI name specified in server.xml, but also becomes available via the JNDI name of the resource reference, meaning you could alternately specify,
<jta-data-source>java:module/env/jdbc/mySQLRef</jta-data-source>
Deployment descriptors can also do some more advanced things like defining a data source in place of the server config. However, to keep this answer simple, I've skipped over that possibility.
This IBM KnowledgeCenter topic is a good place to start
Having deployed the activemq-web-console war into a Tomcat embedded application how can one make it connect to an existing broker rather than create a new one?
The war comes with a set of predefined configurations, in particular, the WEB-INF/activemq.xml contains a configuration for the BrokerService
<broker brokerName="web-console" useJmx="true" xmlns="http://activemq.apache.org/schema/core">
<persistenceAdapter><kahaDB directory="target/kahadb"/></persistenceAdapter>
<transportConnectors>
<transportConnector uri="tcp://localhost:12345"/>
</transportConnectors>
</broker>
used from webconsole-embedded.xml in the following manner:
<bean id="brokerService" class="org.apache.activemq.xbean.BrokerFactoryBean">
<property name="config" value="/WEB-INF/activemq.xml"/>
</bean>
This configuration creates a new instance of BrokerService and tries to start the broker.
It is reported that the web console can be used to monitor an existing broker service rather than creating a new one. For this one should set the following properties somewhere:
webconsole.type=properties
webconsole.jms.url=tcp://localhost:61616
webconsole.jmx.url=service:jmx:rmi:///jndi/rmi://localhost:1099/karaf-trun
The questions is, where does one have to set these properties within the Tomcat embedded app and which XML changes in the above have to be performed for them to be used. I cannot find any sensible explanation how to configure it, and a BrokerService instance seems to be required by the remaining spring config.
Any ideas?
Please do not suggest to use hawtio instead!
I had the same problem today. You can start the webconsole in "properties" mode which gives you the oppertunity to connect over jmx.
I added following java arguments to our Jboss 6.1 and it worked immediatley. I didn't change any of the xmls (works out of the box)...
Example:
-Dwebconsole.type=properties -Dwebconsole.jms.url=tcp://<hostname>:61616 -Dwebconsole.jmx.url=service:jmx:rmi:///jndi/rmi://<hostname>:1090/jmxrmi -Dwebconsole.jmx.user=admin -Dwebconsole.jmx.password=123456
Also discussed here: https://svn.apache.org/repos/infra/websites/production/activemq/content/5.7.0/web-console.html
we are using oracle database, this is how we configured JNDI against oracle on liberty profile, I want to use hikarui-cp instead if javax.sql.ConnectionPoolDataSource.
<library id="oracleJDBCJars" name="oracleJDBCJars">
<fileset dir="${shared.resource.dir}/oracle-jars" includes="*.jar"/>
</library>
<dataSource beginTranForResultSetScrollingAPIs="true"
beginTranForVendorAPIs="false"
commitOrRollbackOnCleanup="rollback"
connectionManagerRef="default-conn-mgr"
isolationLevel="TRANSACTION_READ_COMMITTED"
jndiName="jdbc/dev"
transactional="true"
type="javax.sql.ConnectionPoolDataSource">
<jdbcDriver libraryRef="oracleJDBCJars"/>
<properties.oracle currentSchema="DEV"
databaseName="DBU"
password="Admin12"
portNumber="3714"
serverName="host.local.com"
user="ADMIN"/>
</dataSource>
Opinion part:
First off, I will say that it's probably not necessary to use HikariCP with a Java EE app server. From what I've read, HikariCP is a great connection pool and makes sense to use if you are in a Java SE environment. You might gain a small benefit from using HikariCP in an EE environment, but you will need to jump through additional hoops to get it working when you could just use the Liberty connection pool. In my opinion, your development time will be better spent elsewhere, because Liberty already has a well tested, well performing connection pool out of the box. Using an alternate connection pool on an app server that already provides a good one seems like an unnecessary micro-optimization.
Disclaimer: I am a Liberty developer who works on the connection pool among other things.
To answer your question:
Your configuration is for a DB2 database, not an Oracle database (i.e. properties.oracle should be used instead of properties.db2.jcc). Also, it has many additional properties specified that aren't necessary.
Your configuration can be simplified to this:
<library id="oracleJDBCJars" name="oracleJDBCJars">
<fileset dir="${shared.resource.dir}/oracle-jars" includes="*.jar"/>
</library>
<dataSource jndiName="jdbc/dev">
<jdbcDriver libraryRef="DB2JCC4Jars"/>
<properties.oracle URL="jdbc:oracle:thin:#//host.local.com:3714/DBU"
password="Admin12"
user="ADMIN"/>
</dataSource>
For more info on configuring a data source in Liberty, see this document:
Configuring relational database connectivity in Liberty
Validate your config:
If you have the April beta or newer, you can use the test connection service to check if your data source config works or not. See this article for a walkthrough on how to do that:
Testing database connections in Liberty apps with REST APIs
If you don't have the the April beta or newer, you can write a simple test servlet to attempt to get a connection.
Attempting to use HikariCP:
You will want to modify your jdbc driver <library> to also include the HikariCP jars.
Next, modify your <dataSource> to point to the HikariDataSource implementation. You will need to set 2 attributes (noted below):
<!-- Tell the <dataSource> to use `javax.sql.DataSource` (as opposed to auto-detecting ConnectionPoolDataSource or XADataSource) -->
<dataSource jndiName="jdbc/dev" type="javax.sql.DataSource">
<!-- Tell the <jdbcDriver> what implementation class to use for `javax.sql.DataSource` -->
<jdbcDriver libraryRef="DB2JCC4Jars" javax.sql.DataSource="com.zaxxer.hikari.HikariDataSource"/>
<properties.oracle URL="jdbc:oracle:thin:#//host.local.com:3714/DBU"
password="Admin12"
user="ADMIN"/>
</dataSource>
I am developing a webapp with an embedded webservice with Axis2 using Maven.
The service implementation is a POJO with RPC-style interaction, the target appserver is Tomcat running the Axis2 servlet.
The "Hello world" works but now I need to configure some global axis2 settings in the axis2.xml file (placed under WEB-INF/conf).
Please provide or point to a simple configuration for axis2.xml for this common environment.
The default taken from the binary distribution has too many features activated (hotdeploy?) and also causes this problem:
<soapenv:Reason>
<soapenv:Text xml:lang="en-US">
The ServiceClass object does not implement the required method
in the following form: OMElement ping(OMElement e)
</soapenv:Text>
</soapenv:Reason>
As a reference: http://axis.apache.org/axis2/java/core/docs/servlet-transport.html says to configure the servlet transport in this way, but it does not solve the issue.
<transportReceiver name="http" class="org.apache.axis2.transport.http.AxisServletListener"/>
Apparently the problem is that the default axis2.xml sets raw xml messageReceivers, instead of the RPC ones.
Try to add this to the services.xml for the developed service, should fix the problem.
<messageReceivers>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" />
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</messageReceivers>
"Solution that worked for me was adding the operation tag in the service.xml against the Java Service method name:
<operation name="sayHello" >
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
<parameter name="ServiceClass" locked="false">com.learning.webservices.pojo.HelloService</parameter>