In these moments, I'm trying to configure the IBM wmq.jmsra.rar resource adapter with Wildfly Swarm in a Java project but without success.
Those are the stepts that I've been doing till now:
1) pom.xml (the artifact was installed manually)
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>mq</artifactId>
<version>7.5.0.8</version>
<type>rar</type>
</dependency>
2) module.xml for this resource adapter (in src/main/resources/modules/com/ibm/wsmq/main):
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:2.0" name="com.ibm.mq">
<resources>
<resource-root path="." />
<resource-root path="com.ibm.mq.commonservices.jar" />
<resource-root path="com.ibm.mq.connector.jar" />
<resource-root path="com.ibm.mq.headers.jar" />
<resource-root path="com.ibm.mq.jar" />
<resource-root path="com.ibm.mq.jmqi.jar" />
<resource-root path="com.ibm.mq.jmqi.local.jar" />
<resource-root path="com.ibm.mq.jmqi.remote.jar" />
<resource-root path="com.ibm.mq.jmqi.system.jar" />
<resource-root path="com.ibm.mq.jms.admin.jar" />
<resource-root path="com.ibm.mq.pcf.jar" />
<resource-root path="com.ibm.mqjms.jar" />
<resource-root path="com.ibm.msg.client.commonservices.j2se.jar" />
<resource-root path="com.ibm.msg.client.commonservices.jar" />
<resource-root path="com.ibm.msg.client.jms.internal.jar" />
<resource-root path="com.ibm.msg.client.jms.jar" />
<resource-root path="com.ibm.msg.client.matchspace.jar" />
<resource-root path="com.ibm.msg.client.provider.jar" />
<resource-root path="com.ibm.msg.client.ref.jar" />
<resource-root path="com.ibm.msg.client.wmq.common.jar" />
<resource-root path="com.ibm.msg.client.wmq.factories.jar" />
<resource-root path="com.ibm.msg.client.wmq.jar" />
<resource-root path="com.ibm.msg.client.wmq.v6.jar" />
<resource-root path="dhbcore.jar" />
</resources>
<dependencies>
<module name="javax.api" />
<module name="javax.resource.api" />
<module name="javax.jms.api" />
<module name="javax.management.j2ee.api" />
</dependencies>
</module>
Note: In the main folder of this path I copied the mq-7.5.0.8.rar file too.
3) project-stages.yml:
resource-adapters:
resource-adapters:
mq:
archive: mq.rar
transaction-support: XATransaction
connection-definitions:
BSMConnectionFactoryHigh:
class-name: com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl
jndi-name: jms/bsmConnectionFactoryHigh
config-properties:
hostName:
value: tqhr0712.sede.corp.sanpaoloimi.com
queueManager:
value: TQHR0712
port:
value: 1412
channel:
value: CH.BSMA.CONN
transportType:
value: CLIENT
admin-objects:
BSMSendQueueHigh:
class-name: com.ibm.mq.connector.outbound.MQQueueProxy
jndi-name: jms/bsmSendQueueHigh
config-properties:
baseQueueName:
value: QLOCAL.DATAGRAM.WUO.UOS4APPO9
baseQueueManagerName:
value: TQHR0712
deployment:
com.ibm.mq:mq.rar:
Then, when I run the project I get this error:
2018-02-08 10:33:54 INFO <org.jboss.as.server.deployment> <MSC service thread 1-7> WFLYSRV0028: Stopped deployment mq.rar (runtime-name: mq.rar) in 72ms
2018-02-08 10:33:54 INFO <org.jboss.as.controller> <main> WFLYCTL0183: Service status report
WFLYCTL0184: New missing/unsatisfied dependencies:
service jboss.resourceadapters-subsystem (missing) dependents: [service jboss.deployment.unit."mq.rar".CONFIGURE_MODULE]
Someone would be kind to help to fix this problem?
Thank a lot.
I'm glad to tell you that I found how to make the Wildfly Swarm and IBM websphere mq resource adapter integration with success.
These are the steps to follow:
1) Get the wmq.jmsra.rar from IBM (version 8.x)
2) Creating the artifacts for this file like this:
<dependency>
<groupId>com.ibm</groupId>
<artifactId>mq</artifactId>
<version>8.0.0.7</version>
<type>rar</type>
</dependency>
<dependency>
<groupId>com.ibm</groupId>
<artifactId>mq</artifactId>
<version>8.0.0.7</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
3) src/main/resources:
a) Create the folder modules.
b) Inside modules folder create com/ibm/mq/main.
c) Inside the main folder copy the resource adapter (the .rar file) and
rename it as mq.rar.
d) Inside main folder create the file module.xml like this:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:2.0" name="com.ibm.mq">
<resources>
<resource-root path="." />
<resource-root path="com.ibm.mq.connector.jar" />
<resource-root path="com.ibm.mq.headers.jar" />
<resource-root path="com.ibm.mq.jar" />
<resource-root path="com.ibm.mq.jmqi.jar" />
<resource-root path="com.ibm.mq.pcf.jar" />
<resource-root path="com.ibm.mq.jmqi.local.jar" />
<resource-root path="com.ibm.mqjms.jar" />
</resources>
<dependencies>
<module name="javax.api" />
<module name="javax.resource.api" />
<module name="javax.jms.api" />
<module name="javax.management.j2ee.api" />
</dependencies>
</module>
4) project-stages.yml:
swarm:
jca:
archive-validation:
enabled: false
fail-on-warn: false
resource-adapters:
resource-adapters:
mq:
archive: mq.rar
transaction-support: XATransaction
connection-definitions:
ReinoltroConnectionFactory:
class-name: com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl
jndi-name: jms/testConnectionFactory
recovery-username:
recovery-password:
tracking: false
pool-name: MQCONNF
config-properties:
hostName:
value:
queueManager:
value:
port:
value:
channel:
value:
transportType:
value: CLIENT
admin-objects:
testQueue:
class-name: com.ibm.mq.connector.outbound.MQQueueProxy
jndi-name: jms/testQueue
pool-name: MQQUEUENAME
config-properties:
baseQueueName:
value:
baseQueueManagerName:
value:
deployment:
com.ibm:mq.rar:
5) Java code (send message using JMS 2)
#Stateless
#TransactionManagement(TransactionManagementType.CONTAINER)
public class RichiesteServiceImpl {
....
#Inject
#JMSConnectionFactory("java:/jms/reinoltroConnectionFactory")
JMSContext jmsContext;
#Resource(mappedName = "java:/jms/reinoltroBDQueue")
Queue testQueue;
.....
public boolean sendMessage() {
boolean esitoReinoltro = false;
try {
jmsContext.createProducer().send(reinoltroQueue, "Messaggio di prova" );
esitoReinoltro = true;
return esitoReinoltro;
}
catch(Exception e) {
throw new ServiceException(e);
}
}
}
and the job is done.
Here is my Nlog.Config code.
<nlog>
<variable name="logFilePath" value="C:\NLog\IDG-${shortdate}.log" />
<targets>
<target name="logfile"
xsi:type="File"
fileName="${logFilePath}"
layout="${longdate} LEVEL=${level:upperCase=true}: ${message}"
keepFileOpen="true" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="logfile" />
<logger name="*" minlevel="Info" writeTo="logfile" />
<logger name="*" minlevel="Warn" writeTo="file"/>
</rules>
</nlog>
and am defining this in my class
private static Logger logger = LogManager.GetCurrentClassLogger();
and then I'm logging the error as:
catch (Exception ex)
{
logger.Error(ex.Message,"test");
}
Can anyone please suggest me if there is any better way to do this, I don't see the file logging in the destined folder.
It seems that you may not be referencing the config section correctly. Try changing your main config file to something like this and remove the Nlog.Config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<variable name="logFilePath" value="C:\temp\output.log" />
<targets>
<target name="logfile"
xsi:type="File"
fileName="${logFilePath}"
layout="${longdate} LEVEL=${level:upperCase=true}: ${message}"
keepFileOpen="true" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="logfile" />
<logger name="*" minlevel="Info" writeTo="logfile" />
<logger name="*" minlevel="Warn" writeTo="file"/>
</rules>
</nlog>
</configuration>
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,
log4net" />
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<system.serviceModel>
<!-- Redacted -->
</system.serviceModel>
<log4net debug="true">
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
<file value="logs\" />
<datePattern value="'Proxy_'dd.MM.yyyy'.log'" />
<staticLogFileName value="false" />
<appendToFile value="true" />
<rollingStyle value="Composite" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="5MB" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
<root>
<priority value="ALL" />
<appender-ref ref="RollingLogFileAppender" />
</root>
<category name="Client.log">
<priority value="ALL" />
</category>
</log4net>
<applicationSettings>
<!-- Redacted -->
</applicationSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
I have the above config for my windows service when it's installed, and I'm initializing my logger like so in the Progam.cs file on the service that I'm installing:
static void Main()
{
XmlConfigurator.Configure();
_logger.Debug("ProxyServerService Started.");
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new ProxyServerService()
};
ServiceBase.Run(ServicesToRun);
_logger.Debug("ProxyServerService Terminated.");
}
When I use pretty much the same configuration in an application that communicates with this service it creates a log directory and writes logs to that directory. But when I run the service nothing happens.
Turns out that the reason I couldn't see the logs is because I'd configured the logger the log in the active directory, which is Windows\system32 and windows wouldn't let me do that.
I changed the following line:
<file value="logs\" />
To:
<file value="C:\AppName\logs\" />
And it works fine.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<MasterDetailsResponse xmlns="http://192.168.100.173/ArvindMill/">
<MasterDetailsResult>
<GetAllMasterDetail>
<TABLENAME>item_master</TABLENAME>
<ITEMID>1</ITEMID>
<ITEMTYPE>CTS</ITEMTYPE>
<GROUP />
<VARIETY />
<FORM />
<STATUS />
<ITEM />
<GRADE />
<TYPE />
</GetAllMasterDetail>
<GetAllMasterDetail>
<TABLENAME>item_master</TABLENAME>
<ITEMID>2</ITEMID>
<ITEMTYPE>AGS</ITEMTYPE>
<GROUP /><VARIETY />
<FORM />
<STATUS />
<ITEM />
<GRADE />
<TYPE />
</GetAllMasterDetail>
<GetAllMasterDetail>
<TABLENAME>tablet_taluka_master</TABLENAME>
<VILLAGE>Anturli</VILLAGE>
<TALUKA>Anturli</TALUKA>
<TABLETUSERCODE />
<TABLETUSERNAME /><TABLETCODE />
<TABLETTALUKAID />
</GetAllMasterDetail>
<GetAllMasterDetail>
<TABLENAME>tablet_taluka_master</TABLENAME>
<VILLAGE>Bortha</VILLAGE>
<TALUKA>Sadgavan</TALUKA>
<TABLETUSERCODE /><TABLETUSERNAME />
<TABLETCODE />
<TABLETTALUKAID /></GetAllMasterDetail>
<GetAllMasterDetail>
<TABLENAME>tablet_taluka_master</TABLENAME>
<VILLAGE>Kukarmunda</VILLAGE>
<TALUKA>Kukarmunda</TALUKA>
<TABLETUSERCODE />
<TABLETUSERNAME /><TABLETCODE /><TABLETTALUKAID />
</GetAllMasterDetail>
The above code is the response returned from soapobject in android. How to retrieve the data from the above XML file? I want to display it in list view and the response returned from the soapobject contains more than one table so how to retrieve it?
If your are using Java use SAX Parser
My Visual Studio Solution contains:
[DLL] Sol.DataAccess (NHibernate sessionManager)
[DLL] Sol.Core (Models and Repository)
[MVC] Sol.WebMvc (Controler, View)
All my application contains are (nhibernate.dll [v3.0] and log4net.dll[v1.2.10])
I have 3 configs:
web.config:
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821" requirePermission="false" />
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/>
</configSections>
</configuration>
nhibernate.config:
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<session-factory name="...">
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string_name">...</property>
<property name="adonet.batch_size">10</property>
<property name="show_sql">true</property>
<property name="generate_statistics">true</property>
<property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
<property name="use_outer_join">true</property>
<property name="max_fetch_depth">2</property>
<property name="command_timeout">60</property>
<property name="adonet.batch_size">25</property>
<property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
<property name="current_session_context_class">web</property>
<property name="cache.use_query_cache">true</property>
<property name="cache.provider_class">NHibernate.Caches.SysCache2.SysCacheProvider, NHibernate.Caches.SysCache2</property>
<mapping assembly="..."/>
</session-factory>
</hibernate-configuration>
and log4net.config:
<log4net>
<appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
<!--for release-->
<!--<bufferSize value="10" />-->
<!--for debug-->
<bufferSize value="1" />
<connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<connectionString value="Data Source=xxxxx; Initial Catalog=xxxx; User Id=xxxx; Password=xxxxx; App=xxxx" />
<commandText value="INSERT INTO Logs ([Application],[Host],[User],[Date],[Thread],[Level],[Operation],[Logger],[Message],[Exception]) VALUES (#app, #hostName, #userName, #log_date, #thread, #log_level, #operation, #logger, #message, #exception)" />
<parameter>
<parameterName value="#app" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="xxxx" />
</layout>
</parameter>
<parameter>
<parameterName value="#hostName" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%property{hostName}" />
</layout>
</parameter>
<parameter>
<parameterName value="#userName" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%property{userName}" />
</layout>
</parameter>
<parameter>
<parameterName value="#log_date" />
<dbType value="DateTime" />
<layout type="log4net.Layout.RawTimeStampLayout" />
</parameter>
<parameter>
<parameterName value="#thread" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%thread" />
</layout>
</parameter>
<parameter>
<parameterName value="#log_level" />
<dbType value="String" />
<size value="50" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%level" />
</layout>
</parameter>
<parameter>
<parameterName value="#operation" />
<dbType value="String" />
<size value="50" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%property{Operation}" />
</layout>
</parameter>
<parameter>
<parameterName value="#logger" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%logger" />
</layout>
</parameter>
<parameter>
<parameterName value="#message" />
<dbType value="String" />
<size value="4000" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message" />
</layout>
</parameter>
<parameter>
<parameterName value="#exception" />
<dbType value="String" />
<size value="2000" />
<layout type="log4net.Layout.ExceptionLayout" />
</parameter>
</appender>
<appender name="FileAppender" type="log4net.Appender.FileAppender">
<file value="Logs/Logs.txt"/>
<appendToFile value="true"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"/>
</layout>
</appender>
<appender name="Console" type="log4net.Appender.AspNetTraceAppender">
<!--A1 uses PatternLayout-->
<layout type="log4net.Layout.PatternLayout">
<!--Print the date in ISO 8601 format-->
<conversionPattern value="%date [%thread] %-5level %logger %ndc - %message%newline"/>
</layout>
</appender>
<root>
<level value="ALL"/>
<appender-ref ref="Console"/>
<appender-ref ref="FileAppender"/>
<appender-ref ref="AdoNetAppender"/>
</root>
</log4net>
Global.cs:
protected void Application_Start()
{
...
// Configuration
#region log4net
// log4net.config
System.IO.FileInfo fi = new System.IO.FileInfo(Server.MapPath("~/log4net.config"));
if (fi != null && fi.Exists)
{
// Code that runs on application startup
log4net.Config.XmlConfigurator.Configure(fi);
}
// web.config
//log4net.Config.XmlConfigurator.Configure();
// set properti hostName
log4net.GlobalContext.Properties["hostName"] = Dns.GetHostName();
#endregion
#region NHibernate
//HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize();
var factory = NHibernateSessionManager.ConfigureFromFile(Server.MapPath("~/hibernate.config"));
#endregion
}
in my test controller i have:
public class TestController : BaseController
{
[NHibernateSession]
public ActionResult Index()
{
Logger.Error("fake error", new Exception());
}
}
In my log file - Logs/Logs.txt:
2011-03-11 18:19:23,097 [8] ERROR System.Web.Mvc.Controller [(null)] - fake error
System.Exception: Exception of type 'System.Exception' was thrown.
QUESTION:
Why log4net doesn't log NHibernate information (info, debug ....)
Aren't the versions of these dlls compatible?
I have create an empty ASP.Net MVC3 project. and loss much time trying to fix this issue.
And I find VS2010 bug. Visual Studio 2010 don't copy dll's in bin when you refer it in project.
I put log4net.dll manual in my bin folder and work fine. (Interesting thing is that Logger.Error("fake error") work fine without log4net.dll in bin folder ...)
First off: you speak of "log4net.config", but you don't include that anywhere. The way you configure it in web.config, you should actually include a section called <log4net> inside your web.config, not as a separate file.
If you don't want it in your web.config, you can remove the log4net related sections altogether and add the following line to yur global.asax.cs:
log4net.Config.XmlConfigurator.ConfigureAndWatch(
New FileInfo(Server.MapPath("~/yourreleativepath/log4net.config")))
Also, possibly you miss the priority setting, not entirely sure this helps, but give it a try:
<root>
<priority value="DEBUG"/>
<appender-ref ref="Console"/>
<appender-ref ref="FileAppender"/>
<appender-ref ref="AdoNetAppender"/>
</root>
Also, to finetune (because you'll get a lot messages), use something like this:
<logger name="NHibernate.SQL">
<level value="DEBUG"/>
</logger>
<logger name="NHibernate">
<level value="WARN"/>
</logger>
On nhibernate.info you'll find a full example.