Apache CXF multiple bus definitios - spring

I am trying to using CXF with multiples endpoints and 2 bus definitions, here is my configurations:
<jaxws:endpoint id="csSegSEndPoint"
implementor="#csSegServices"
address="/ESTSServices"
bus="busEST">
</jaxws:endpoint>
<cxf:bus name="busEST">
<cxf:inInterceptors>
<ref bean="logInbound"/>
</cxf:inInterceptors>
<cxf:outInterceptors>
<ref bean="logOutbound"/>
</cxf:outInterceptors>
</cxf:bus>
The thing is that when I start the application I get:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'csSegSEndPoint': Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)
I did some search and I cannot get what I am doing wrong. Could you please help me?
NOTE: I am using CXF 2.2.10.
salu2..
masch...

This never really worked until CXF 2.4.x sometime. Definitely upgrade. 2.2.10 is ancient, buggy, unsupported and has a BUNCH of security issues.

Related

NoClassDefinitionError with simple bean configuration

<bean id="xmlItemReader" class="org.springframework.batch.item.xml.StaxEventItemReader">
<property name="fragmentRootElementName" value="SomeElement" />
<property name="unmarshaller" ref="jaxb2unmarshaller" />
</bean>
<bean id="jaxb2unmarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<value>org.MappedClass</value>
</list>
</property>
</bean>
I started with multi step job and have issue when packaged as the job module in the spring-xd, I stripped all the other beans from the configuration and finally figured the issue was coming due to the above two beans.
The spring-oxm jar is present in the custom modules lib. I am using spring-xd 1.0.0.RC1.
I don't want to put the jars in to the server lib, all the required libraries should be part of the custom module lib directory.
How to get it working?
If I place the spring-oxm jar in the spring-xd/lib directory the error goes but then I get the other errors too.
I guess the real reason for the NoClassDefError could be the missing dependencies and the error does not indicate the information about the missing dependent class.
Any inputs would be appreciated?
The information provided is not sufficient to conclude anything. However, you could check the second last line of the code block provided above. The closing <property> tag is missing or it's a TYPO while writing the code here.
The module's dependent jars should go in the module's lib/ directory if they are not on the server class path already. Spring XD 1.1 has improved support for module packaging but in 1.0 you need to install the jars manually. Also, I would suggest upgrading to 1.1.0.M2 or 1.0.3.RELEASE at least.

CXF request response logging using log4j: debug

I am trying to enable logging for cxf framework in weblogic application server along with log4j.
I have placed cxf.xml in domain home and have modified setdomainenv to add cxf.xml entry -Dcxf.config.file.url=cxf.xml.
I am setting System.setProperty("org.apache.cxf.Logger", "org.apache.cxf.common.logging.Log4jLogger") before making a webservice call and i have tried configuring all 3 types of configuration specified in http://cxf.apache.org/docs/configuration.html. But nothing seems to work.
I even tried creating org.apache.cxf.Logger file containing value org.apache.cxf.common.logging.Log4jLogger.
my log4j.properties
log4j.rootLogger = DEBUG, FILE
log4j.logger.org.apache.cxf=DEBUG
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=<>/logFile.log
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.conversionPattern=%m%n
CXF version: 2.7.5
Please suggest if there is change required for me to log both request and response xml?
Make sure your org.apache.cxf.Logger file is under META-INF/cxf. Inspect your war to make sure.
Also, assuming you are defining your services using jaxws, make sure you're defining loggers under the jaxws:inInterceptor and jaxws:outInterceptor
<jaxws:client id="..." serviceClass="..." address="..." >
<jaxws:outInterceptors>
<ref bean="logOut" />
</jaxws:outInterceptors>
<jaxws:inInterceptors>
<ref bean="logIn"/>
</jaxws:inInterceptors>
</jaxws:client>
<bean class='org.apache.cxf.interceptor.LoggingInInterceptor' id='logIn'/>
<bean class='org.apache.cxf.interceptor.LoggingOutInterceptor' id='logOut'/>

No SQL connection

Recently I've decided to move from Common DBCP to Tomcat JDBC Connection Pool. I changed bean description (using spring 3.1 + hibernate 4 + tomcat) and was faced with the next issue on my web app start up:
HHH000342: Could not obtain connection to query metadata : com.mysql.jdbc.Driver
and then when I try to query db from my app I am getting:
23:04:40,021 WARN [http-bio-8080-exec-10] spi.SqlExceptionHelper:(SqlExceptionHelper.java:143) - SQL Error: 0, SQLState: null
23:04:40,022 ERROR [http-bio-8080-exec-10] spi.SqlExceptionHelper:(SqlExceptionHelper.java:144) - com.mysql.jdbc.Driver
I must have done something wrong with configuration so hibernate cannot obtain connection but do not see it. really appreciate if you can point me to the right direction.
here is piece of my datasource bean definition
<bean id="jdbcDataSource" class="org.apache.tomcat.jdbc.pool.DataSource" destroy- method="close"
p:driverClassName="com.mysql.jdbc.Driver"
p:url="jdbc:mysql://127.0.0.1:3306/test"
p:username="root"
p:password="test"
p:defaultAutoCommit="false"
p:maxActive="100"
p:maxIdle="100"
p:minIdle="10"
p:initialSize="10"
p:maxWait="30000"
p:testWhileIdle="true"
p:validationInterval="60000"
p:validationQuery="SELECT 1"
p:timeBetweenEvictionRunsMillis="60000"
p:minEvictableIdleTimeMillis="600000"
p:maxAge="360000"
/>
and here is how I tie it with spring's session factory
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="jdbcDataSource" />...
Make sure you are using JDK 6. Using JDK5 might be one cause of this error.
However, there is a workaround to your problem, explained here.
after migration, I forgot to add lib tomcat-jdbc to my classpath :)
now it wroks

PropertyPlaceholderConfigurer does not find property file on disk

I am trying to move a working spring WAR to OSGI environment (in glassfish 3.1 and blueprint, spring 3.0.5).
The application loads properties file from disk, like this:
<bean id="myProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="${my_conf}/my.properties"/>
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
</bean>
I see in debugger that ${my_conf}/my.properties is translated to the existing path (c:\conf\my.properties)
I use the property jms.url defined in my.properties in the next bean declaration
<amq:broker useJmx="false" persistent="false" brokerName="embeddedbroker">
<amq:transportConnectors>
<amq:transportConnector uri="tcp://${jms.url}"/>
<amq:transportConnector uri="vm://embeddedbroker" />
</amq:transportConnectors>
</amq:broker>
And in deployment I get an exception "Could not resolve placeholder ${jms.url}"
Why it fails? Is there another way to load properties from file on disk?
thank you
Since its an OSGI environment, you will need spring-osgi-core jar added to your application. Take a look at this link to configure property-placeholder for OSGI framework.
It isn't a solution, but an explanation of my problem.
The problem is related to this bug in spring 3 and osgi.
I had to open spring logs to debug level to understand it.

Spring alias not available when running in Grails

I have a problem with Spring aliases in Grails. I have a library .jar file containing classes and Spring configuration that is not working as expected. It does work as expected when I import them from a standard (no Grails) Java app.
The current configuration contains this.
<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="contextPath" value="uk.co.company.package"/>
</bean>
<alias name="marshaller" alias="unmarshaller"/>
And fails with an error.
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'unmarshaller' is defined
Changing the configuration to the following then leads it to work as expected.
<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="contextPath" value="uk.co.company.package"/>
</bean>
<bean id="unmarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="contextPath" value="uk.co.company.package"/>
</bean>
The configuration is being imported and is being read. For some reason the alias is unavailable when I try to use it. What is that reason?
This is with Grails 1.3.7 and Spring 3.0.5.
I am seeing this issue as well. You can get around it by defining the alias in the Grails resources.xml or in my case in my plugin doWithSpring closure:
springConfig.addAlias "aliasName", "beanName"
I'd expect the importBeans to import alias as well
This link might be helpful for you:
http://burtbeckwith.com/blog/?p=85
It is mentioned there that aliases don't work at least when declared in the resources.xml. The post also mentions a way of declaring aliases programatically. But it seems like this post was written a while back and not sure how relevant it is with grails 1.3.7.

Resources