Exception with liberty profile 18.0.0.1 - java-8

[WARNING ] CWWKZ0014W: The application abcEAR could not be started as it could not be found at location abcEAR.ear.
[ERROR ] CWWKZ0106E: Could not start web application abcEAR.
[ERROR ] CWWKZ0002E: An exception occurred while starting the application abcEAR. The exception message was: com.ibm.ws.container.service.state.StateChangeException: java.lang.ExceptionInInitializerError
[ERROR ] CWWKZ0106E: Could not start web application abcEAR.
[ERROR ] CWWKZ0004E: An exception occurred while starting the application abcEAR. The exception message was: com.ibm.ws.container.service.state.StateChangeException: java.lang.ExceptionInInitializerError
Any thoughts what could be the reason\fix for this exception?
below is the server.xml. Let me know any more details required.I am quite new so not sure i am providing the correct details.-----------------------------------------------------------------------------------------------------------------
<server description="new server">
<!-- Enable features -->
<featureManager>
<feature>cdi-1.2</feature>
<feature>jaxb-2.2</feature>
<feature>localConnector-1.0</feature>
<feature>beanValidation-1.1</feature>
<feature>servlet-3.1</feature>
<feature>jaxws-2.2</feature>
<feature>ejbLite-3.2</feature>
<feature>concurrent-1.0</feature>
<feature>monitor-1.0</feature>
<feature>jaxrs-2.0</feature>
</featureManager>
<!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
<httpEndpoint host="*" httpPort="${default.http.port}" httpsPort="${default.https.port}" id="defaultHttpEndpoint"/>
<managedExecutorService jndiName="abc/abc">
</managedExecutorService>
<library id="configs">
<folder dir="${server.config.dir}/config"/>
</library>
<logging maxFileSize="20" maxFiles="10" traceFileName="trace.log" traceFormat="BASIC" traceSpecification="*=info: JCDI=all: com.ibm.ws.webbeans*=all: org.apache.webbeans*=all"/>
<include location="serverConfig.xml"/>
<include location="server-webservices-jndi.xml"/>
<include location="server-wmq.xml"/>
<include location="server-datasources.xml"/>
<applicationMonitor updateTrigger="mbean"/>
<webContainer deferServletLoad="false"/>
<logging hideMessage="SRVE9967W"/>
<cdi12 enableImplicitBeanArchives="false"/>
<enterpriseApplication id="abcEAR" location="abcEAR.ear" name="abcEAR">
<classloader commonLibraryRef="OracleLib,configs"/>
</enterpriseApplication>
</server>
i see errors in below format for various jar\packages in the log
000000ba org.jboss.weld.Bootstrap I WELD-000119: Not generating any bean definitions from 'package' because of underlying class loading error: Type package not found. If this is unexpected, enable DEBUG logging to see the full error.
W CWNEN0047W: Resource annotations on the fields of the 'package' class will be ignored. The annotations could not be obtained because of the exception : java.lang.NoClassDefFoundError: package
WARNING ] SRVE9967W: The manifest class path guava.jar can not be found in jar file ... or its parent.
------Start of DE processing------
Exception = java.lang.ExceptionInInitializerError
Source = com.ibm.ws.container.service.state.internal.ApplicationStateManager
probeid = 31
Stack Dump = java.lang.ExceptionInInitializerError
at java.lang.J9VMInternals.ensureError(J9VMInternals.java:141)
at java.lang.J9VMInternals.recordInitializationFailure(J9VMInternals.java:130)
at org.mockito.internal.exceptions.stacktrace.ConditionalStackTraceFilter.<init>(ConditionalStackTraceFilter.java:17)
at org.mockito.exceptions.base.MockitoException.filterStackTrace(MockitoException.java:30)
at org.mockito.exceptions.base.MockitoException.<init>(MockitoException.java:19)
at org.mockito.exceptions.misusing.MockitoConfigurationException.<init>(MockitoConfigurationException.java:18)
at org.mockito.internal.configuration.ClassPathLoader.loadImplementations(ClassPathLoader.java:145)
at org.mockito.internal.configuration.ClassPathLoader.findPluginImplementation(ClassPathLoader.java:110)
at org.mockito.internal.configuration.ClassPathLoader.findPlatformMockMaker(ClassPathLoader.java:106)
at org.mockito.internal.configuration.ClassPathLoader.<clinit>(ClassPathLoader.java:59)
at org.mockito.internal.util.MockUtil.<clinit>(MockUtil.java:21)

Related

Setting up listener using IBM MQ in eclipse using wlp for java springboot application

Setting up listener using IBM MQ in eclipse using wlp for java springboot application
Hi, I am trying to set up listener using wlp in my local in eclipse,
following is the code :
pom.xml
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>4.3.10.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.jms</groupId>
<artifactId>javax.jms-api</artifactId>
<version>2.0</version>
</dependency>
java class:
#JmsListener(containerFactory = "jmsListenerContainerFactory", destination = test.queue)
public void recieve(Message message) {
log.info("inside message receiver");
try {
if (message instanceof TextMessage) {
message.acknowledge();
String json = ((TextMessage) message).getText();
/** To solve Json injection fortify issue **/
String sanitisedJsonMessage = JsonSanitizer.sanitize(json);
Gson gson = new Gson();
//business logic
} else {
log.error("ERROR ::: invalid message type");
message.acknowledge();
}
} catch (JsonSyntaxException | JMSException ex) {
log.error("ERROR: " + ex + ex.getMessage());
}
}
#Bean
public DefaultJmsListenerContainerFactory jmsListenerContainerFactory() {
ConnectionFactory connectionfactory;
DefaultJmsListenerContainerFactory listenerFactory;
try {
log.info("inside listener factory");
#Cleanup
Context context = null;
listenerFactory = new DefaultJmsListenerContainerFactory();
context = new InitialContext();
connectionfactory = (ConnectionFactory) context.lookup(jms/ConnectionFactory);
listenerFactory.setConnectionFactory(connectionfactory);
listenerFactory.setSessionAcknowledgeMode(Session.CLIENT_ACKNOWLEDGE);
} catch (NamingException ex) {
log.error("ERROR: error looking up queue connection factory jndi {}", ex);
}
return listenerFactory;
}
Now I tried to set up my server.xml in wlp as per ibm guidelines as follows:
<server description="new server">
<!-- Enable features -->
<featureManager>
<feature>javaee-7.0</feature>
<feature>jndi-1.0</feature>
<feature>jaxws-2.2</feature>
<feature>localConnector-1.0</feature>
<feature>transportSecurity-1.0</feature>
<feature>servlet-3.1</feature>
<feature>mdb-3.2</feature>
<feature>wmqJmsClient-2.0</feature>
<feature>jsp-2.3</feature>
</featureManager>
<!-- Define an Administrator and non-Administrator -->
<basicRegistry id="basic">
<user name="admin" password="adminpwd" />
<user name="nonadmin" password="nonadminpwd" />
</basicRegistry>
<!-- Assign 'admin' to Administrator -->
<administrator-role>
<user>admin</user>
</administrator-role>
<keyStore id="defaultKeyStore" password="Liberty" />
<httpEndpoint host="*" httpPort="9081" httpsPort="9444"
id="defaultHttpEndpoint" />
<!-- Automatically expand WAR files and EAR files -->
<applicationManager autoExpand="true" />
<applicationMonitor updateTrigger="mbean" />
<enterpriseApplication
id="mqtest-ear"
location="mqtest-ear.ear"
name="mqtest-ear" />
<variable name="wmqJmsClient.rar.location"
value="path\to\wlp\wmq\wmq.jmsra.rar" />
<jmsQueueConnectionFactory
jndiName="jms/ConnectionFactory">
<properties.wmqJms transportType="CLIENT"
hostName="<test.correcthostname>" port="<test.correctportname>"
channel="<test.correctchannelname>" queueManager="<test.correctqmgrname>" useSSL="true"
headerCompression="SYSTEM" messageCompression="RLE"
sslCipherSuite="SSL_RSA_WITH_AES_256_CBC_SHA256"
targetClientMatching="true" />
<connectionManager></connectionManager>
</jmsQueueConnectionFactory>
<jmsQueue id="JMSQueue" jndiName="jms/InQueue">
<properties.wmqJms baseQueueName="test.queue"
baseQueueManagerName="<test.correctqmgrname>" receiveConversion="CLIENT_MSG"
putAsyncAllowed="DESTINATION" targetClient="MQ"
readAheadAllowed="ENABLED" />
</jmsQueue>
<!-- <resourceAdapter
location="${wmqJmsClient.rar.location}" id="resourceAdapter">
</resourceAdapter> -->
<keyStore id="keyAndTrustStore" password="password"
location="path\to\keyandtruststore"
type="PKCS12">
</keyStore>
I have downloaded latest resource adapter and 9.0.0.8-IBM-MQ-Java-InstallRA.jar,
When I run the application , I get constant error:
2020-01-10 11:21:16 ERROR o.s.j.l.DefaultMessageListenerContainer - Could not refresh JMS Connection for destination 'test.queue' - retrying using FixedBackOff{interval=5000, currentAttempts=12, maxAttempts=unlimited}. Cause: MQJCA1011: Failed to allocate a JMS connection.
what Can I do to make listener work
After trying and troubleshoting a lot, I found a solution to set up ibm mq message listener using springboot and jms locally in websphere liberty server version 19.0.0.6.
I used following steps to make listener work:
download resource adaptor 9.0.0.8-IBM-MQ-Java-InstallRA.jar
Run the jar, and a folder named wmq will be generated with required .rar file in it.
Place the wmq folder inside wlp server : path\to\wlp-webProfile8-19.0.0.6\wlp\usr\servers\defaultServer
if using keystores for ssl , place trust and key store .jks or .p12 file inside wlp server path\to\wlp-webProfile8-19.0.0.6\wlp\usr\servers\defaultServer\resources\security
create a new file name jvm.options with following details:
-Dcom.ibm.mq.cfg.useIBMCipherMappings=false
-Djavax.net.debug="all"
-Djdk.tls.client.protocols="TLSv1.2"
-Dhttps.protocols="TLSv1.2"
-Djavax.net.ssl.trustStore="path\to\keyandtruststore.jks"
-Djavax.net.ssl.trustStorePassword="secret"
-Djavax.net.ssl.keyStore="path\to\keyandtruststore.jks"
-Djavax.net.ssl.keyStorePassword="secret"
save file inside following location : path\to\wlp-webProfile8-19.0.0.6\wlp\usr\servers\defaultServer
now add required dependencies in pom.xml
I am using spring boot version 2.1.4.release and following are important dependecies which will be required:
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>mq-jms-spring-boot-starter</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.1.4.RELEASE</version>
</dependency>
now change the wlp server.xml as follows:
<!-- Enable features -->
<featureManager>
<feature>webProfile-8.0</feature>
<feature>localConnector-1.0</feature>
<feature>jndi-1.0</feature>
<feature>jaxws-2.2</feature>
<feature>transportSecurity-1.0</feature>
<feature>wmqJmsClient-2.0</feature>
<feature>jsp-2.3</feature>
<feature>servlet-4.0</feature>
<feature>jms-2.0</feature>
<feature>javaee-8.0</feature>
</featureManager>
<!-- Define an Administrator and non-Administrator -->
<basicRegistry id="basic">
<user name="admin" password="adminpwd"/>
<user name="nonadmin" password="nonadminpwd"/>
</basicRegistry>
<!-- Assign 'admin' to Administrator -->
<administrator-role>
<user>admin</user>
</administrator-role>
<!-- Automatically expand WAR files and EAR files -->
<applicationManager autoExpand="true"/>
<applicationMonitor updateTrigger="mbean"/>
<variable name="wmqJmsClient.rar.location" value="path\to\wlp-webProfile8-19.0.0.6\wlp\usr\servers\defaultServer\wmq\wmq.jmsra.rar"/>
<jmsQueueConnectionFactory jndiName="jms/ConnectionFactory" id="QueueConnectionFactory ">
<properties.wmqJms channel="channelName" headerCompression="NONE" hostName="host name" messageCompression="RLE" port="1414" queueManager="qmgrName" sslCipherSuite="TLS_RSA_WITH_AES_256_CBC_SHA256" targetClientMatching="true" transportType="CLIENT" temporaryModel="SYSTEM.DEFAULT.MODEL.QUEUE" pollingInterval="5s" rescanInterval="5s"/>
<connectionManager connectionTimeout="180s" maxPoolSize="20" minPoolSize="1" reapTime="180s" agedTimeout="0" maxIdleTime="30m"/>
</jmsQueueConnectionFactory>
<jmsQueue id="JMSQueue" jndiName="jms/testInQueue">
<properties.wmqJms putAsyncAllowed="DISABLED" readAheadAllowed="ENABLED" receiveConversion="CLIENT_MSG" targetClient="JMS" baseQueueName="queueName" baseQueueManagerName="qmgrName" failIfQuiesce="true" persistence="APP"/>
</jmsQueue>
<!-- <wmqJmsClient nativeLibraryPath="C:\Users\n78724\CRAS\resource adapter\lib"/> -->
<resourceAdapter id="resourceAdapter"
location="${wmqJmsClient.rar.location}">
<customize></customize>
</resourceAdapter>
<ssl id="keyAndTrustStore" keyStoreRef="defaultKeyStore" sslProtocol="TLSv1.2" trustStoreRef="defaultTrustStore"/>
<keyStore id="defaultKeyStore" location="path\to\wlp-webProfile8-19.0.0.6\wlp\usr\servers\defaultServer\resources\security\keyandtruststore.jks" password="secret"/>
<keyStore id="defaultTrustStore" location="path\to\wlp-webProfile8-19.0.0.6\wlp\usr\servers\defaultServer\resources\security\keyandtruststore.jks" password="secret"/>
<enterpriseApplication id="Test-ear" location="Test-ear.ear" name="Test-ear"/>
start the server
hope it helps.

org.springframework.beans.factory.BeanDefinitionStoreException, How to fix the error?

I am currently studying Spring DI.
But I have not been able to run the project due to some error.
Below is a list of errors.
Exception in thread "main"
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:344)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:252)
at org.springframework.context.support.GenericXmlApplicationContext.load(GenericXmlApplicationContext.java:124)
at org.springframework.context.support.GenericXmlApplicationContext.<init>(GenericXmlApplicationContext.java:69)
at Spring_DI.MainClass.main(MainClass.java:15)
Caused by: java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330)
The following is the contents of applicationContext.xml.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="cats" class="Spring_DI.Cats" />
<!-- "Spring_DI.MyCats"클래스를 myCats라는 id를 지정해서 객체(bean)을 생성 -->
<bean id="myCats" class="Spring_DI.MyCats">
<!-- Spring_DI.Cats.MyCats라는 클래스에 있는 필드들의 값을 설정해줌 -->
<property name="cats"><!-- 첫번째 property(필드) -->
<ref bean="cats"/><!-- 이 property는 위에서 생성한 bean(객체)인 cats를 참조한다. -->
</property>
<property name="firstCatName" value="순덕" /><!-- MyCats의 필드의 이름과 값을 설정 -->
<property name="secondCatName" value="나비" />
<property name="firstCatAge" value="1" />
<property name="secondCatAhttps://stackoverflow.com/jobs?med=site-ui&ref=jobs-tabge" value="2" />
</bean>
</beans>
Here is the contents of the java file.
package Spring_DI;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;
public class MainClass {
public static void main(String[] args) {
//bean을 설정한 xml파일이 있는 위치 지정
String configLocation = "classpath:applicationContext.xml";
//지정한 위치를 참고하여 설정파일을 얻어옴
AbstractApplicationContext ctx =
new GenericXmlApplicationContext(configLocation);
//설정파일에서 bean을 가져옴
//getBean()를 이용해서 MyCats타입에서 myCats를 얻어와서 객체를 생성
// = 방법1 예제처럼 직접 생성이 아닌 외부에서 얻어옴(주입을 시켜줌)
MyCats myCat = ctx.getBean("myCats",MyCats.class);
//호출
myCat.catsNameInfo();
myCat.catsAgeInfo();
}
}
The following is the project structure.
enter image description here
How can I handle the above error?
And why does the above error occur?
Please let me know how to fix the problem.
As per the screenshot, your project is maven project. So the resources(any other files than source files) should be placed in src/main/resources.When Maven build your project, it expects to find only Java source files under src/main/java, and ignores all the other files.

Websphere Liberty profile - transacted Websphere MQ connection factory

Trying to get my Liberty profile server to create a transacted jmsConnectionFactory to my instance of Websphere message queue.
Liberty profile v 8.5.5.5
Websphere MQ 7.x
I've tried to change the jmsQueueConnectionFactory to jmsXAQueueConnectionFactory but it does not help -> Then it seems to just ignore it and doesn't connect to the MQ
server.xml
<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">
<!-- Enable features -->
<featureManager>
<feature>wmqJmsClient-1.1</feature>
<feature>jndi-1.0</feature>
<feature>jsp-2.2</feature>
<feature>localConnector-1.0</feature>
</featureManager>
<variable name="wmqJmsClient.rar.location" value="D:\wlp\wmq\wmq.jmsra.rar"/>
<jmsQueueConnectionFactory jndiName="jms/wmqCF" connectionManagerRef="ConMgr6">
<properties.wmqJms
transportType="CLIENT"
hostName="hostname"
port="1514"
channel="SYSTEM.DEF.SVRCONN"
queueManager="QM"
/>
</jmsQueueConnectionFactory>
<connectionManager id="ConMgr6" maxPoolSize="2"/>
<applicationMonitor updateTrigger="mbean"/>
<application id="App"
location="...\app.war"
name="App" type="war"/>
<!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
<httpEndpoint id="defaultHttpEndpoint"
httpPort="9080"
httpsPort="9443"/>
</server>
log
2015-04-23 17:07:14,981 [JmsConsumer[A0]] WARN ultJmsMessageListenerContainer - Setup of JMS message listener invoker failed for destination 'A0' - trying to recover. Cause: Could not commit JMS transaction; nested exception is com.ibm.msg.client.jms.DetailedIllegalStateException: JMSCC0014: It is not valid to call the 'commit' method on a nontransacted session. The application called a method that must not be called on a nontransacted session. Change the application program to remove this behavior.
2015-04-23 17:07:14,983 [JmsConsumer[A0]] INFO ultJmsMessageListenerContainer - Successfully refreshed JMS Connection
Camel code
public static JmsComponent mqXAComponentTransacted(InitialContext context, String jndiName) throws JMSException, NamingException {
return JmsComponent.jmsComponentTransacted((XAQueueConnectionFactory) context.lookup(jndiName));
}
Ended up with:
public static JmsComponent mqXAComponentTransacted(InitialContext context, String connectionFactoryJndiName, String userTransactionJndiName) throws JMSException, NamingException {
LOG.info("Setting up JmsComponent using jndi lookup");
final JtaTransactionManager jtaTransactionManager = new JtaTransactionManager((UserTransaction) context.lookup(userTransactionJndiName));
final ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup(connectionFactoryJndiName);
final JmsComponent jmsComponent = JmsComponent.jmsComponentTransacted(connectionFactory, (PlatformTransactionManager) jtaTransactionManager);
jmsComponent.setTransacted(false);
jmsComponent.setCacheLevel(DefaultMessageListenerContainer.CACHE_NONE);
return jmsComponent;
}

How do I autowire my webservices client in my WAR application (using Spring)?

I’m using Maven 3.0.3, CXF 2.7.15, and Spring 3.2.11.RELEASE. Using the JAX-WS Maven plugin, web service client classes are auto-generated (plugin code below) ...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlDirectory>${basedir}/src/wsdl</wsdlDirectory>
<sourceDestDir>${basedir}/src/main/java</sourceDestDir>
<packageName>org.collegeboard.bsorg</packageName>
</configuration>
</execution>
</executions>
</plugin>
which include the below
package org.myproject.bsorg;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.1.3-b02-
* Generated source version: 2.1
*
*/
#WebService(name = "OrganizationWebService", targetNamespace = "http://mainco.org/bsorg/")
#XmlSeeAlso({
ObjectFactory.class
})
public interface OrganizationWebService {
Then I have my own service class, in which I try and reference the above through auto wiring …
package org.mainco.subco.myproject.service;
#Service("orgWsdlSvc")
public class OrgWsdlServiceImpl implements OrgWsdlService
{
#Autowired
private OrganizationWebService m_ows;
When I deploy my WAR file, I get the error
09:20:17,846 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-14) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orgWsdlSvc': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.mainco.bsorg.OrganizationWebService org.mainco.subco.myproject.service.OrgWsdlServiceImpl.m_ows; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.mainco.bsorg.OrganizationWebService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:290) [spring-beans-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1148) [spring-beans-3.2.11.RELEASE.jar:3.2.11.RELEASE]
But I’m confused about how to properly autowire things in my web.xml and accompanying context files. In my WEB-INF/web.xml, I have
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/META-INF/spring/applicationContext-myproject.xml,
classpath:/META-INF/spring/infrastructure.xml
</param-value>
</context-param>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>myproject.webapp</param-value>
</context-param>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
In my WEB-INF/dispatcher-servlet.xml file I have
<!-- Enable annotation driven controllers, validation etc... -->
<mvc:annotation-driven />
<context:component-scan base-package="org.mainco" />
<!-- Define spring bean for use with this app. -->
<bean id="localPropertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:application.properties</value>
</property>
</bean>
<!-- Define application properties for use in Spring classes -->
<util:properties id="applicationProperties" location="classpath:application.properties" />
<tx:annotation-driven />
and in my “applicationContext-myproject.xml”, I have
<util:properties id="applicationProperties" location="classpath:application.properties" />
<util:properties id="coreProperties" location="classpath:core.properties" />
<context:component-scan base-package="org.mainco.subco" />
<context:component-scan base-package="org.mainco.bsorg" />
<bean id="sessionTimeoutInSeconds" class="java.lang.Long">
<constructor-arg>
<value>3600</value>
</constructor-arg>
</bean>
<!-- Enable annotation driven controllers, validation etc... -->
<mvc:annotation-driven />
<!-- Define spring bean for use with this app. -->
<bean id="localPropertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:application.properties</value>
</property>
</bean>
<bean id="assert" class="org.mainco.subco.util.Assert" factory-method="createInstance" />
<http-conf:conduit name="https://.*">
<http-conf:tlsClientParameters secureSocketProtocol="TLSv1" disableCNCheck="true">
<sec:trustManagers>
<sec:keyStore type="JKS" password="${key.store.password}" resource="${key.store.file}" />
</sec:trustManagers>
<sec:keyManagers keyPassword="${key.manager.password}">
<sec:keyStore type="pkcs12" password="${private.key.password}" resource="${private.key.file}" />
</sec:keyManagers>
</http-conf:tlsClientParameters>
</http-conf:conduit>
<jaxws:client id="orgWebServiceClient"
serviceClass="org.mainco.bsorg.OrganizationWebService"
address="${wsdl.url}"
/>
<bean id="organizationWebService" class="org.mainco.bsorg.OrganizationWebService"></bean>
What do I need to do so I can autowire my web services client?
Edit: Per the suggestion given, I added the bean definition to my application context (see above) file, but received the following error upon deplyohing the application:
Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orgWsdlSvc': Injection of autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.myproject.bsorg.OrganizationWebService org.mainco.subco.myproject.service.OrgWsdlServiceImpl.m_ows;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'organizationWebService' defined in class path resource [META-INF/spring/applicationContext-myproject-mvc.xml]: Instantiation of bean failed;
nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.mainco.bsorg.OrganizationWebService]: Specified class is an interface
You are missing the bean definition in your applicationContext-myproject.xml.
<!-- Definition for OrganizationWebService bean -->
<bean id="organizationWebService" class="org.mainco.bsorg.OrganizationWebService"></bean>
See this for more examples:
http://www.mkyong.com/spring/spring-auto-wiring-beans-with-autowired-annotation/
EDIT:
You are making progress. Now spring is able to find the autowired candidate in the application context.
However, there is another problem, the candidate is an interface and spring is not able to instantiate it (neither does javac). So, you need to create a class to implement your interface and describe it in your application context (instead or describing an interface). So; you need to create a org.mainco.bsorg.OrganizationWebServiceImp class implementing org.mainco.bsorg.OrganizationWebService and change your application context to:
<bean id="organizationWebService" class="org.mainco.bsorg.OrganizationWebServiceImp"></bean>
More info here: Could not instantiate bean class: Specified class is an interface
EDIT2:
Look at https://jax-ws.java.net/2.2.1/docs/UsersGuide.html#3.1.2_Starting_from_a_WSDL_File
The documentation clarifies that:
Generate a service endpoint interface.
Implement the service endpoint interface.
Create a WAR file to deploy.
You need to implement the service endpoint interface with a concrete class eg: OrganizationWebServiceImp

Getting error "After parsing a valid expression, there is still more data in the expression: 'lcurly({)'"

I am using Spring-Integration for my project. I am experimenting with reading of the property/constant values from xml file (instead of .properties file).My xml file in which the properties/constants are placed is as below:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<persistence>
<dataSourceName>CS/PowerSTEPP_CSSTEPPQA</dataSourceName>
</persistence>
<customerservice>
<headerNames>
<jobName>jobDesignerJobName</jobName>
</headerNames>
<headerNames>
<originalPayload>originalPayload</originalPayload>
</headerNames>
<headerNames>
<originalPayloadDuplicate>originalPayload</originalPayloadDuplicate>
</headerNames>
<headerNames>
<legacySystem>legacySystem</legacySystem>
</headerNames>
<headerNames>
<businessArea>businessArea</businessArea>
</headerNames>
<routing>
<jobChannel>headers.jobDesignerJobName+'-InputChannel'</jobChannel>
</routing>
<routing>
<jobErrorChannel>headers.jobDesignerJobName+'-XsltTransformInputChannel'</jobErrorChannel>
</routing>
<legacySystem>
<powerstepp>PowerSTEPP</powerstepp>
</legacySystem>
<PQProviderSearch>
<storedProcedureName>PQPRVSCH</storedProcedureName>
</PQProviderSearch>
<PQProviderSearch>
<ROWREQ>00001</ROWREQ>
</PQProviderSearch>
<PQProviderSearch>
<DBGFLG>Y</DBGFLG>
</PQProviderSearch>
<PQProviderSearch>
<SECDAT></SECDAT>
</PQProviderSearch>
<stylesheet>
<PQProviderSearch>classpath:/CustomerServiceRD/spring-integration/stylesheets/PQProviderSearch.xsl</PQProviderSearch>
</stylesheet>
<stylesheet>
<PQProviderSearchCount>classpath:/CustomerServiceRD/spring-integration/stylesheets/PQProviderSearchCount.xsl</PQProviderSearchCount>
</stylesheet>
<resultSet>
<legacySystem>system</legacySystem>
</resultSet>
<resultSet>
<rootNode>results</rootNode>
</resultSet>
<responseXml>
<soapTemplate>CustomerServiceRD/JobDesigner-responseTemplate.xml</soapTemplate>
</responseXml>
<responseXml>
<xmlBodyTag>//PQ</xmlBodyTag>
</responseXml>
<http>
<header>
<ressponseXml>
<contentType>
<value>CustomerServiceRD/JobDesigner-responseTemplate.xml</value>
</contentType>
</ressponseXml>
</header>
</http>
<http>
<header>
<contentType>
<value>CustomerServiceRD/JobDesigner-responseTemplate.xml</value>
</contentType>
</header>
</http>
<error>
<Fault>Fault</Fault>
</error>
<error>
<errorCode>1111</errorCode>
</error>
<headerNames>
<hostAddress>hostAddress</hostAddress>
</headerNames>
<headerNames>
<hostPort>hostPort</hostPort>
</headerNames>
<error>
<Fault>faultcode</Fault>
</error>
<error>
<faultstring>faultstring</faultstring>
</error>
<error>
<faultactor>faultactor</faultactor>
</error>
<error>
<detail>detail</detail>
</error>
<label>
<externalSystem>ExternalSystem</externalSystem>
</label>
</customerservice>
</config>
Now, I am trying to read the above values in spring integration configuration files as below:
<beans
<import resource="spring-integration/Jobs/*.xml"/>
<!-- map of namespace prefix to URI -->
<util:map id="xmlMessageNamespace">
<entry key="SOAP" value="http://schemas.xmlsoap.org/soap/envelope/" />
</util:map>
<int:channel id="jobDesignerInputChannel" />
<int:channel id="cs-exceptionHandlingChannel" />
<bean id="msgHandler" class="com.dsths.cs.awd.jobs.PQMessageHandler" />
<!-- TODO: Following lines are commented out as part of POC.-->
<!--<bean id="xmlAggregator" class="com.dsths.cs.awd.jobs.XmlAggregator" />
<bean id="httpOutboundGatewayHandler" class="com.dsths.cs.awd.jobs.HttpOutboundGatewayHandler" />
<!--<bean id="xmlFilter" class="com.dsths.cs.awd.jobs.XmlFilter" />-->
<int:chain input-channel="jobDesignerInputChannel" >
<int-xml:xpath-header-enricher default-overwrite="true" should-skip-nulls="true" >
<int-xml:header name="${customerservice.headerNames.legacySystem}" xpath-expression="//LegacySystem" evaluation-type="STRING_RESULT" overwrite="true" />
</int-xml:xpath-header-enricher>
<!-- Some of the AWD jobs contain Business Area info under <code> tag, we should not keep that business area info in the
header since it is not required.This will help us in identifying AWD and Non-AWD jobs-->
<int:header-enricher>
<int:header name="${customerservice.headerNames.businessArea}" expression="#xpath(payload, '//businessArea/Code', 'boolean') ? null : #xpath(payload, '//businessArea')"/>
</int:header-enricher>
<int:router expression="${customerservice.routing.jobChannel}"/>
</int:chain>
<int:chain input-channel="cs-exceptionHandlingChannel">
<!-- Service Activator to handle the errors -->
<int:service-activator ref="msgHandler" method="handleError" />
<!-- Router to routing the error messages to appropriate job channel for xsl transormation -->
<int:router expression="${customerservice.routing.jobErrorChannel}"/>
</int:chain>
</beans>
But, unfortunately I am getting the following exception when try to read the properties from the xml file:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.handler.MessageHandlerChain#3': Cannot create inner bean 'org.springframework.integration.handler.MessageHandlerChain#3$child#2.handler' of type [org.springframework.integration.config.RouterFactoryBean] while setting bean property 'handlers' with key [2]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.handler.MessageHandlerChain#3$child#2.handler': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'expressionString' threw exception; nested exception is org.springframework.expression.spel.SpelParseException: EL1041E:(pos 1): After parsing a valid expression, there is still more data in the expression: 'lcurly({)'
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:281)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:120)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:353)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:153)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:103)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:124)
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:148)
... 24 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.handler.MessageHandlerChain#3$child#2.handler': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'expressionString' threw exception; nested exception is org.springframework.expression.spel.SpelParseException: EL1041E:(pos 1): After parsing a valid expression, there is still more data in the expression: 'lcurly({)'
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1396)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270)
... 42 more
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'expressionString' threw exception; nested exception is org.springframework.expression.spel.SpelParseException: EL1041E:(pos 1): After parsing a valid expression, there is still more data in the expression: 'lcurly({)'
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1393)
... 46 more
Anybody have any idea where I am doing wrong?
Please let me know if my question is not clear.
According to the StackTrace your issue is here:
<int:router expression="${customerservice.routing.jobChannel}"/>
Before to use such a difficult configuration you should be sure that your customerservice really returns all desired options.
Would be great, if you had shown how does that object look from Java perspective, rather than XML background

Resources