Wildfly Swarm - Resource adapters (IBM wmq.jmsra.rar) - adapter

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.

Related

The element 'Capabilities' in namespace msix Package.appmanifest xml

I have a warning highlighted for the element:
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="runFullTrust" />
<rescap:Capability Name="localSystemServices" />
<rescap:Capability Name="packagedServices" />
</Capabilities>
With the below detail:
The element 'Capabilities' in namespace 'http://schemas.microsoft.com/appx/manifest/foundation/windows10' has invalid
child element 'Capability' in namespace
'http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities'. List of possible elements
expected: 'CapabilityChoice' in namespace 'http://schemas.microsoft.com/appx/manifest/foundation/windows10' as well as
'Capability' in namespace 'http://schemas.microsoft.com/appx/manifest/uap/windows10' as well as 'Capability' in
namespace 'http://schemas.microsoft.com/appx/manifest/foundation/windows10' as well as 'Capability' in namespace
'http://schemas.microsoft.com/appx/manifest/uap/windows10/4' as well as 'Capability' in namespace
'http://schemas.microsoft.com/appx/manifest/uap/windows10/6' as well as 'Capability' in namespace
'http://schemas.microsoft.com/appx/manifest/uap/windows10/7' as well as 'Capability' in namespace
'http://schemas.microsoft.com/appx/manifest/uap/windows10/3' as well as 'Capability' in namespace
'http://schemas.microsoft.com/appx/manifest/uap/windows10/2' as well as 'CustomCapabilityChoice' in namespace
'http://schemas.microsoft.com/appx/manifest/foundation/windows10' as well as 'CustomCapability' in namespace
'http://schemas.microsoft.com/appx/manifest/uap/windows10/4' as well as 'Dev....
The Package.appmanifest xml manifest is below:
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
xmlns:desktop2="http://schemas.microsoft.com/appx/manifest/desktop/windows10/2"
xmlns:desktop6="http://schemas.microsoft.com/appx/manifest/desktop/windows10/6"
IgnorableNamespaces="uap rescap">
<Identity
Name="11d14331-0000-0000-0000-3c2e4cc6d69d"
Publisher="CN=my.name"
Version="1.0.10.0" />
<Properties>
<DisplayName>My Agent</DisplayName>
<PublisherDisplayName>My</PublisherDisplayName>
<Logo>Images\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.14393.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate"/>
</Resources>
<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe" EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="My Agent"
Description="My Agent."
BackgroundColor="transparent"
Square150x150Logo="Images\Square150x150Logo.png"
Square44x44Logo="Images\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png" />
<uap:SplashScreen Image="Images\SplashScreen.png" />
</uap:VisualElements>
<Extensions>
<desktop6:Extension Category="windows.service" EntryPoint="Windows.FullTrustApplication" Executable="Agent\Agent.exe">
<desktop6:Service Name="Agent" StartAccount="localSystem" StartupType="auto"/>
</desktop6:Extension>
</Extensions>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="runFullTrust" />
<rescap:Capability Name="localSystemServices" />
<rescap:Capability Name="packagedServices" />
</Capabilities>
<Extensions>
<desktop2:Extension Category="windows.firewallRules">
<desktop2:FirewallRules Executable="Agent\Agent.exe">
<desktop2:Rule Direction="in" IPProtocol="TCP" Profile="all"/>
<desktop2:Rule Direction="in" IPProtocol="UDP"
Profile="all"/>
<desktop2:Rule Direction="out"
IPProtocol="TCP"
Profile="all"/>
<desktop2:Rule Direction="out"
IPProtocol="UDP"
Profile="all"/>
</desktop2:FirewallRules>
</desktop2:Extension>
</Extensions>
</Package>

org.nd4j.linalg.factory.Nd4jBackend$NoAvailableBackendException in wildfly

I am using deeplearning4j with JBOSS wildfly. I have placed all the modules as mentioned below in the classpath:
<module name="org.nd4j.jackson" />
<module name="org.nd4j.nd4j-api" />
<module name="org.nd4j.nd4j-context" />
<module name="org.nd4j.nd4j-common" />
<module name="org.nd4j.nd4j-cuda-92" />
<module name="org.nd4j.nd4j-cuda-92-platform" />
<module name="org.nd4j.nd4j-native" />
<module name="org.nd4j.nd4j-native-api" />
<module name="org.nd4j.nd4j-native-platform" />
<module name="org.bytedeco.javacpp" />
<module name="org.bytedeco.javacpp-presets.cuda" />
<module name="org.bytedeco.javacpp-presets.cuda-platform" />
<module name="org.bytedeco.javacpp-presets.mkl" />
<module name="org.bytedeco.javacpp-presets.openblas" />
<module name="org.bytedeco.javacv" />
<module name="org.datavec.datavec-api" />
<module name="org.deeplearning4j.deeplearning4j-core" />
<module name="org.deeplearning4j.deeplearning4j-nlp" />
<module name="org.deeplearning4j.deeplearning4j-nn" />
I am still getting an exception java.lang.RuntimeException:
org.nd4j.linalg.factory.Nd4jBackend$NoAvailableBackendException: Please ensure that you have an nd4j backend on your classpath. Please see: http://nd4j.org/getstarted.html
at org.nd4j.linalg.factory.Nd4j.initContext(Nd4j.java:5449)
while executing the below line of code, basically where I read the model
org.deeplearning4j.models.embeddings.loader.WordVectorSerializer.readWord2Vec(WordVectorSerializer.java:787)
Any idea what could be going on here?
ND4j uses ServiceLoader to find the backend. In the Wildfly to enable this, in the jboss-deployment-structure.xml mention services="import".
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
<deployment>
<dependencies>
<module name="module.name" services="import"/>
</dependencies>
</deployment>
</jboss-deployment-structure>

NLog not logging the exception or any other text

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>

Why is my windows service not logging anything?

<?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.

Struts Validation Not Working [strange]

I think I get a strange condition in struts validation, because sometimes it works and sometimes do not work. I using maven. On the first install, i get it work. But after maven clean, it never work again.
When I install my project (maven install), xml validation (CustomerAction-validation.xml) is not copied to action class package in the target folder. I don't know why.
It will error if I remove <interceptor-ref name="prepare"/> in "customer-form" action. Although I use default-interceptor. No customization.
Other question about login form (unrelated to validation). How to post the form to another namespace. I try by using namespace="/web", but it not work. That's why i try by using s:url, but it make i can't use s:form
This is my project structure
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>struts.test</groupId>
<artifactId>validation</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>validation Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<junit.version>3.8.1</junit.version>
<struts2.version>2.3.1.2</struts2.version>
<struts2-tiles-plugin.version>2.3.14</struts2-tiles-plugin.version>
<tiles.version>2.0.7</tiles.version>
<commons-logging.version>1.1.3</commons-logging.version>
<commons-collection.version>3.2.1</commons-collection.version>
<xwork.version>2.1.3</xwork.version>
<dojo.version>2.1.8</dojo.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- Struts 2 -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>${struts2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-tiles-plugin</artifactId>
<version>${struts2-tiles-plugin.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-api</artifactId>
<version>${tiles.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-core</artifactId>
<version>${tiles.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-jsp</artifactId>
<version>${tiles.version}</version>
</dependency>
<!-- Struts 2 Dojo Ajax Tags -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-dojo-plugin</artifactId>
<version>${dojo.version}</version>
</dependency>
<!-- Struts 2 JSON Plugins -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-json-plugin</artifactId>
<version>${dojo.version}</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>${commons-logging.version}</version>
</dependency>
<dependency>
<groupId>com.opensymphony</groupId>
<artifactId>xwork</artifactId>
<version>${xwork.version}</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.19</version>
</dependency>
<dependency>
<groupId>ognl</groupId>
<artifactId>ognl</artifactId>
<version>3.0.6</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.3</version>
</dependency>
<dependency>
<groupId>commons-digester</groupId>
<artifactId>commons-digester</artifactId>
<version>2.1</version>
</dependency>
</dependencies>
<build>
<finalName>validation</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<constant name="struts.custom.i18n.resources" value="ApplicationResources" />
<package name="default" extends="struts-default" namespace="/web">
<result-types>
<result-type name="tiles"
class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
<action name="login" class="struts.test.validation.action.LoginAction">
<result name="success" type="tiles">/welcome.tiles</result>
<result name="error">Login.jsp</result>
</action>
<action name="savecustomer" class="struts.test.validation.action.CustomerAction" method="saveCustomer">
<result name="success" type="tiles">/customer.success.tiles</result>
<result name="input" type="tiles">/customer.tiles</result>
</action>
<action name="customer-form" class="struts.test.validation.action.CustomerAction" method="addCustomer">
<interceptor-ref name="prepare"/>
<result name="success" type="tiles">/customer.tiles</result>
<result name="input" type="tiles">/customer.tiles</result>
</action>
</package>
</struts>
CustomerAction-validation.xml
<!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.3//EN"
"http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
<validators>
<field name="customer.name">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message key="errors.required" />
</field-validator>
</field>
<field name="customer.email">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message key="errors.required" />
</field-validator>
</field>
<field name="customer.type">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message key="errors.required" />
</field-validator>
</field>
</validators>
CustomerAction class
public class CustomerAction extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = 1L;
private CustomerDto customer;
private List<String > listCustoType;
public String addCustomer(){
listCustoType = new ArrayList<String>();
listCustoType.add("Type1");
listCustoType.add("Type2");
return SUCCESS;
}
public String saveCustomer() {
System.out.println(customer.getName()+" "+customer.getEmail());
return SUCCESS;
}
public CustomerDto getCustomer() {
return customer;
}
public void setCustomer(CustomerDto customer) {
this.customer = customer;
}
public List<String> getListCustoType() {
return listCustoType;
}
public void setListCustoType(List<String> listCustoType) {
this.listCustoType = listCustoType;
}
}
CustomerDto class
public class CustomerDto {
private Integer id;
private String name;
private String email;
private String type;
//getter & setter
Customer Form
<%# page contentType="text/html; charset=UTF-8"%>
<%# taglib prefix="s" uri="/struts-tags"%>
<html>
<body>
<h2>Customer Form</h2>
<s:form action="savecustomer" method="post" validate="true" namespace="/web">
<s:select
label="Customer Type"
list="listCustoType"
name="customer.type"
headerKey="-1"
headerValue=""/>
<s:textfield name="customer.name" key="customer.name" size="20" />
<s:textfield name="customer.email" key="email" size="20" />
<s:submit method="addCustomer" key="label.add.customer" align="center" />
</s:form>
</body>
</html>
Login form
<form action='<s:url value='/'/>web/login' method="post">
<s:textfield name="username" key="label.username" size="20" />
<s:password name="password" key="label.password" size="20" />
<s:submit method="execute" key="label.login" align="center" />
</form>
My complete project I uploaded here
In Maven projects, non-Java artifacts intended to be deployed on the classpath need to be in:
src/main/resources
Because you've placed them in the Java source directory tree they will not be deployed.
In your specific case:
src/main/resources/struts/test/validation/action/CustomerValidation-validation.xml
This is the same pattern as the other XML files in the resources directory, deployed to the classpath.
Just ran into the problem where my validation files were not copying over. To fix this problem, you need to add in the maven-war-plugin and configure it properly to include the XML files. Here is what I added to my pom.xml file to get it working in my project:
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>src/main/java/com/project/controller/</directory>
<targetPath>WEB-INF/classes/com/project/controller/</targetPath>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
You can read up more on how the maven-war-plugin works here.

Resources