It would not be bad to expand the documentation on citrus for different types of queues!
This is the piece of code in which I'm trying to start the Simulator.class:
#SpringBootApplication
public class Simulator extends SimulatorJmsAdapter {
public static void main(String[] args) {
SpringApplication.run(Simulator.class, args);
}
#Override
public ConnectionFactory connectionFactory() {
QueueConnectionFactory factory = new QueueConnectionFactory();
try {
factory.setProperty(ConnectionConfiguration.imqAddressList, "mq://192.168.116.21:7676");
} catch (JMSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return new QueueConnectionFactory();
}
#Override
public boolean synchronous(SimulatorJmsConfigurationProperties simulatorJmsConfiguration) {
return true;
}
}
And here context.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"
xmlns:citrus="http://www.citrusframework.org/schema/config"
xmlns:citrus-jms="http://www.citrusframework.org/schema/jms/config"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.citrusframework.org/schema/jms/config http://www.citrusframework.org/schema/jms/config/citrus-jms-config.xsd
http://www.citrusframework.org/schema/config http://www.citrusframework.org/schema/config/citrus-config.xsd">
<citrus:schema-repository id="schemaRepository">
<citrus:locations>
<citrus:location path="classpath:xsd/HelloService.xsd"/>
</citrus:locations>
</citrus:schema-repository>
<!-- Test JMS client -->
<citrus-jms:sync-endpoint id="simulatorEndpoint"
destination-name="Citrus.Simulator.Inbound"/>
<bean id="connectionFactory" class="com.sun.messaging.QueueConnectionFactory.QueueConnectionFactory">
<property name="ConnectionConfiguration" ref="ConnectionConfiguration" />
</bean>
<bean id="ConnectionConfiguration" class="com.sun.messaging.ConnectionConfiguration">
<property name="imqAddressList" ref="mq://192.168.116.21:7676" />
</bean>
</beans>
When I run clean install, spring-boot: run. I get this error: C4003: Error occurred on connection creation [localhost:7676].
Somebody can help me, why it is happen? And how I correctly to create file context I need some example?
Here my answer: In class EndpointConfig I added few Beans:
#Bean
public QueueConnectionFactory connectionFactory() throws JMSException {
QueueConnectionFactory connectionFactory = new QueueConnectionFactory();
connectionFactory.setProperty(ConnectionConfiguration.imqAddressList, "mq://#####.stage.tema:7676");
return connectionFactory;
}
#Bean
public DefaultJmsListenerContainerFactory jmsListenerContainerFactory(QueueConnectionFactory connectionFactory,
PlatformTransactionManager transactionManager) {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
factory.setConnectionFactory(connectionFactory);
factory.setTransactionManager(transactionManager);
factory.setSessionTransacted(true);
factory.setSessionAcknowledgeMode(Session.SESSION_TRANSACTED);
// factory.setErrorHandler(errorHandler);
return factory;
}
#Bean
public JmsTemplate jmsTemplate(QueueConnectionFactory qcf) throws JMSException {
JmsTemplate template = new JmsTemplate();
template.setConnectionFactory(qcf);
return template;
}
In my test I send my personal object which was injected in pom.Here code:
#CitrusTest
#Test
public void send() {
action(new AbstractTestAction() {
#Override
public void doExecute(TestContext context) {
MORequest req = new MORequest(param1, param2, param3);
//Method of object
req.setSourcePort(4);
jmsTemplate.send("queue_name", (Session sn) -> sn.createObjectMessage(req));
}
});
}
Related
I am very disappointed, I followed a tutorial on how to add Thymeleaf to a Spring MVC project but it doesn't even work with a 3-classes sample project. Thymeleaf cannot find my views and I don't know what I am missing.
Stacktrace :
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "ServletContext resource [/WEB-INF/views/test.html]")
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:866)
javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
SpringMVCConfiguration.class
#Configuration
#ComponentScan({ "main.java" })
#EnableWebMvc
public class SpringMVCConfiguration implements WebMvcConfigurer {
#Autowired
private ApplicationContext applicationContext;
#Bean
public SpringResourceTemplateResolver templateResolver() {
SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
templateResolver.setApplicationContext(applicationContext);
templateResolver.setPrefix("/WEB-INF/views/");
templateResolver.setSuffix(".html");
return templateResolver;
}
#Bean
public SpringTemplateEngine templateEngine() {
SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.setTemplateResolver(templateResolver());
templateEngine.setEnableSpringELCompiler(true);
return templateEngine;
}
#Override
public void configureViewResolvers(ViewResolverRegistry registry) {
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
resolver.setTemplateEngine(templateEngine());
registry.viewResolver(resolver);
}
}
DispatcherServletConfiguration.class
public class DispatcherServletConfiguration extends AbstractAnnotationConfigDispatcherServletInitializer {
#Override
protected Class<?>[] getRootConfigClasses() {
return null;
}
#Override
protected Class<?>[] getServletConfigClasses() {
return new Class[] { SpringMVCConfiguration.class };
}
#Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
}
TestController.class
#Controller
public class TestController {
#GetMapping("/test")
public String test(Model model) {
System.out.println("controller test");
return "test";
}
}
In Eclipse, the HTML file is located here :
-- Project
-- WebContent
-- WEB-INF
-- views
- test.html
test.html
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>TEST</h1>
</body>
</html>
To get off the ground running faster, I would suggest using spring-boot with its thyme-leaf starter. It handles most of the frustrating wiring code to avoid these issues.
https://www.mkyong.com/spring-boot/spring-boot-hello-world-example-thymeleaf/
Per your code, I'm guessing your component scan is wrong. Can you switch it from main.java to the root of your package hierarchy... whatever that is? Its probably the package name that the main.java file is in.
Also, maybe try moving your WEB-INF to src/main/web-app/WEB-INF?
I am learning spring-security and created simple application to learn matchers. Unfortunately, I cannot get mvcMatchers to work. The other thing is that it works perfectly with antMatchers. Please see it's source below.
1) dependencies in pom.xml:
<dependencies>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>5.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>5.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring5</artifactId>
<version>3.0.9.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
2) MvcWebApplicationInitializer:
public class MvcWebApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
#Override
protected Class<?>[] getRootConfigClasses() {
return new Class[]{SecurityConfig.class};
}
#Override
protected Class<?>[] getServletConfigClasses() {
return new Class[] { MvcWebConfig.class };
}
#Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
}
3) MvcWebConfig
#Configuration
#EnableWebMvc
#ComponentScan("com.example.controller")
public class MvcWebConfig implements WebMvcConfigurer {
#Autowired
private ApplicationContext applicationContext;
#Bean
public SpringResourceTemplateResolver templateResolver() {
SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
templateResolver.setApplicationContext(applicationContext);
templateResolver.setPrefix("/WEB-INF/views/");
templateResolver.setSuffix(".html");
return templateResolver;
}
#Bean
public SpringTemplateEngine templateEngine() {
SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.setTemplateResolver(templateResolver());
templateEngine.setEnableSpringELCompiler(true);
return templateEngine;
}
#Override
public void configureViewResolvers(ViewResolverRegistry registry) {
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
resolver.setTemplateEngine(templateEngine());
registry.viewResolver(resolver);
}
}
4) SecurityConfig:
#Configuration
#EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
#Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER").and()
.withUser("admin").password("password").roles("USER", "ADMIN");
}
#Bean
public static NoOpPasswordEncoder passwordEncoder() {
return (NoOpPasswordEncoder) NoOpPasswordEncoder.getInstance();
}
#Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers(HttpMethod.GET, "/secured/**").hasRole("ADMIN")
//.mvcMatchers(HttpMethod.GET, "/secured/**").hasRole("ADMIN")
.anyRequest().permitAll()
.and()
.formLogin();
}
}
5) SecurityWebInitializer:
public class SecurityWebInitializer extends AbstractSecurityWebApplicationInitializer {}
6) MyController
#Controller
public class MyController {
#GetMapping("unsecured")
public String unsecured(Model model) {
model.addAttribute("message", "Unsecured");
return "index";
}
#GetMapping("secured/msg")
public String secured(Model model) {
model.addAttribute("message", "Secured");
return "index";
}
}
7) index.html is just simple Themeleaf template to output message
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="ISO-8859-1">
</head>
<body>
<p th:text="${message}"></p>
</body>
</html>
I package app as war, deploy it to Tomcat 9 application server, and open warname/unsecured and warname/secured/msg URLs and it works as expected (unsecured just outputs message 'unsecured', secured asks for login/password. After logging in it displays page with message 'secured'). When I comment antMatchers and uncomment mvcMatchers in SecurityConfig navigating to any of these 2 urls gives me standard 404 Tomcat page. I tried to provide mvcMatchers with different patterns, such as: /secured/msg, /secured/msg/, secured/msg, /secured/msg/*, and every time I got 404. While remote debugging of app I have found that it seems that mvcMatcher.match is not get called, while antMatcher.match is called during attemt to access warname/secured/msg page. Can you please tell me how I can make app to work with mvcMatchers the same way as it works now with antMatchers?
Try add annotation #PreAuthorized("hasRole('ADMIN')") abow your endpoints like this:
#PreAuthorized("hasRole('ADMIN')")
#GetMapping("secured/msg")
public String secured(Model model) {
model.addAttribute("message", "Secured");
return "index";
}
btw. You should use direct paths in mvcMatchers like:
mvcMatchers(HttpMeethod.GET, "/secured/msg"...)
I have following classes
AppConfig.java
#Configuration
#EnableWebMvc
#ComponentScan(basePackages = "com.pdma.dmapp")
public class AppConfig extends WebMvcConfigurerAdapter{
#Bean(name="multipartResolver")
public StandardServletMultipartResolver resolver(){
return new StandardServletMultipartResolver();
}
#Override
public void configureViewResolvers(ViewResolverRegistry registry){
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setViewClass(JstlView.class);
viewResolver.setPrefix("/WEB-INF/views/");
viewResolver.setSuffix(".jsp");
registry.viewResolver(viewResolver);
}
#Override
public void addResourceHandlers(ResourceHandlerRegistry registry){
registry.addResourceHandler("/webResources/**").addResourceLocations("/webResources/");
registry.addResourceHandler("/angularApps/**").addResourceLocations("/angularApps/");
}
}
SecurityConfiguration.java
#Configuration
#EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter{
#Autowired
public void configureGlobalSecurity(AuthenticationManagerBuilder auth) throws Exception
{
auth.inMemoryAuthentication()
.withUser("GISManager")
.password("gis#manager#pdma")
.roles("GISManager");
}
#Override
public void configure(HttpSecurity http) throws Exception
{
http.authorizeRequests()
.antMatchers("/**").access("hasRole('GISManager')")
.and().formLogin()
.and().exceptionHandling().accessDeniedPage("/Access_Denied");
}
}
AppInitializer.java
public class AppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer{
private static final String LOCATION = "D:/uploads/";
private static final long MAX_FILE_SIZE = 1024*1024*25;
private static final long MAX_REQUEST_SIZE = 1024*1024*30;
private static final int FILE_SIZE_THRESHOLD = 0;
#Override
protected Class<?>[] getRootConfigClasses() {
// TODO Auto-generated method stub
return new Class [] {AppConfig.class,SecurityConfiguration.class};
}
#Override
protected Class<?>[] getServletConfigClasses() {
// TODO Auto-generated method stub
return null;
}
#Override
protected String[] getServletMappings() {
// TODO Auto-generated method stub
return new String [] {"/",
"*.html",
"*.htm",
"*.ajax"};
}
#Override
protected void customizeRegistration(ServletRegistration.Dynamic registration){
registration.setMultipartConfig(getMultipartConfigElement());
}
private MultipartConfigElement getMultipartConfigElement(){
MultipartConfigElement element = new MultipartConfigElement(LOCATION,
MAX_FILE_SIZE,
MAX_REQUEST_SIZE,
FILE_SIZE_THRESHOLD);
return element;
}
}
WelcomeController.java
#Controller
#RequestMapping(value="/")
public class WelcomeController {
#GetMapping(value="")
public String getWelcomePage(){
return "welcome";
}
}
welcome.jsp is placed in /WEB-INF/views/
I am getting login page and all other pages like main.html etc but I am unable to get welcome page. When I try to hit localhost:8080/dmapp/ I get following message in console:
WARNING: No mapping found for HTTP request with URI [/dmapp/] in DispatcherServlet with name 'dispatcher'
This problem was present before I used spring-security
What can be the problem
changing
#Override
protected String[] getServletMappings() {
// TODO Auto-generated method stub
return new String [] {"/",
"*.html",
"*.htm",
"*.ajax"};
}
to
#Override
protected String[] getServletMappings() {
// TODO Auto-generated method stub
return new String [] {"/"};
}
solved problem in my case
Hi I have a strange problem,
I'am following this Tutorial (http://websystique.com/springmvc/spring-4-mvc-and-hibernate4-integration-example-using-annotations/) and at step 5, configurting initializer class there are two ways of doing that:
1 with WebAppInitializer (my code below)
public class SpindleSpringWebAppInitializer implements WebApplicationInitializer {
public void onStartup(ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext();
appContext.register(AppConfig.class);
appContext.setServletContext(servletContext);
ServletRegistration.Dynamic dispatcher = servletContext.addServlet(
"SpringDispatcher", new DispatcherServlet(appContext));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/");
}
With AppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer (my code here)
public class AppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
#Override
protected Class<?>[] getRootConfigClasses() {
return new Class[] { AppConfig.class };
}
#Override
protected Class<?>[] getServletConfigClasses() {
return null;
}
#Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
}
This is my AppConfig.java
#Configuration
#EnableWebMvc
public class AppConfig extends WebMvcConfigurerAdapter{
#Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/").setCachePeriod(31556926);
}
#Bean
public ViewResolver viewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setViewClass(JstlView.class);
viewResolver.setPrefix("/WEB-INF/views/");
viewResolver.setSuffix(".jsp");
return viewResolver;
}
#Bean
public MessageSource messageSource() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("messages");
return messageSource;
}
}
The Thing is that when I use the first method everything works, but when I use the second one i get 404 (description The requested resource is not available). I have no other errors and I have no idea how to debug this. I wouldn't bother but I'm trying to implement Spring Security to the code and as I understand the secon type of initializer is the preffered type nowdays.
I'm using Maven, STS, Pivotal tc Servert Developer Edition. Thanks for any feedback.
The problem is solved. Target folder still held web.xml and context.xml files. Deleting target folder and reinstalling the app was the right thing to do
I &m trying to expose my data base using a web service , i am using a postgresql data base , ejb 3.1 and , CXF as webservice framework.
This is the entity
package persistance.model;
import java.io.Serializable;
import java.lang.String;
import java.util.Date;
import javax.persistence.*;
/**
* Entity implementation class for Entity: ENVOI
*
*/
#Entity
#Table(name = "Envoi")
#NamedQueries({#NamedQuery(name="Envoi.getAll", query="Select e from Envoi e")})
public class Envoi implements Serializable {
#Id
#Column
#GeneratedValue(strategy=GenerationType.AUTO)
private int Id;
#Column
private int Numet;
#Column
private int Numseq;
#Column
private int Valadler;
#Column
private String Typemess;
#Column
#Temporal(TemporalType.DATE)
private Date Horodatage;
#Column
private String Appli;
#Column
private String Versproto;
#Column
private String Data;
#Column
private String ACK;
private static final long serialVersionUID = 1L;
public Envoi() {
super();
}
public int getNumet() {
return this.Numet;
}
public void setNumet(int Numet) {
this.Numet = Numet;
}
public int getNumseq() {
return this.Numseq;
}
public void setNumseq(int Numseq) {
this.Numseq = Numseq;
}
public int getValadler() {
return this.Valadler;
}
public void setValadler(int Valadler) {
this.Valadler = Valadler;
}
public String getTypemess() {
return this.Typemess;
}
public void setTypemess(String Typemess) {
this.Typemess = Typemess;
}
public Date getHorodatage() {
return this.Horodatage;
}
public void setHorodatage(Date Horodatage) {
this.Horodatage = Horodatage;
}
public String getAppli() {
return this.Appli;
}
public void setAppli(String Appli) {
this.Appli = Appli;
}
public String getVersproto() {
return this.Versproto;
}
public void setVersproto(String Versproto) {
this.Versproto = Versproto;
}
public int getId() {
return this.Id;
}
public void setId(int Id) {
this.Id = Id;
}
public String getData() {
return this.Data;
}
public void setData(String Data) {
this.Data = Data;
}
public String getACK() {
return this.ACK;
}
public void setACK(String ACK) {
this.ACK = ACK;
}
}
Now here the DAO
this one is generic
package persistance.dao;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
//import javax.persistence.criteria.CriteriaQuery;
public abstract class GenericDAO<T> {
private final static String UNIT_NAME = "MestaPU";
#PersistenceContext(unitName = UNIT_NAME)
private EntityManager em;
private Class<T> entityClass;
public GenericDAO(Class<T> entityClass) {
this.entityClass = entityClass;
}
public void save(T entity) {
em.persist(entity);
}
protected void delete(Object id, Class<T> classe) {
T entityToBeRemoved = em.getReference(classe, id);
em.remove(entityToBeRemoved);
}
public T update(T entity) {
return em.merge(entity);
}
public T find(int entityID) {
return em.find(entityClass, entityID);
}
// Using the unchecked because JPA does not have a
// em.getCriteriaBuilder().createQuery()<T> method
/* #SuppressWarnings({ "unchecked", "rawtypes" })
public List<T> findAll() {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
cq.select(cq.from(entityClass));
return em.createQuery(cq).getResultList();
}*/
// Using the unchecked because JPA does not have a
// ery.getSingleResult()<T> method
/* #SuppressWarnings("unchecked")
protected T findOneResult(String namedQuery, Map<String, Object> parameters) {
T result = null;
try {
Query query = em.createNamedQuery(namedQuery);
// Method that will populate parameters if they are passed not null and empty
if (parameters != null && !parameters.isEmpty()) {
populateQueryParameters(query, parameters);
}
result = (T) query.getSingleResult();
} catch (Exception e) {
System.out.println("Error while running query: " + e.getMessage());
e.printStackTrace();
}
return result;
}*/
/* private void populateQueryParameters(Query query, Map<String, Object> parameters) {
for (Entry<String, Object> entry : parameters.entrySet()) {
query.setParameter(entry.getKey(), entry.getValue());
}
}*/
}
this one is spécifique to Envoi entity
package persistance.dao;
import javax.ejb.Stateless;
import persistance.model.*;
#Stateless
public class EnvoiDAO extends GenericDAO<Envoi> {
public EnvoiDAO() {
super(Envoi.class);
}
public void delete(Envoi envoi) {
super.delete(envoi.getId(), Envoi.class);
}
}
This is the Facade to expose the ejb
package persistance.facade;
import java.util.List;
import javax.ejb.Local;
import javax.jws.WebService;
import persistance.model.Envoi;
#WebService
#Local
public interface EnvoiFacade {
public abstract void save(Envoi envoi);
public abstract Envoi update(Envoi envoi);
public abstract void delete(Envoi envoi);
public abstract Envoi find(int entityID);
public abstract List<Envoi> findAll();
}
package persistance.facade;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.jws.WebService;
import persistance.dao.EnvoiDAO;
import persistance.model.Envoi;
#WebService
#Stateless
public class EnvoiFacadeImp implements EnvoiFacade {
#EJB
private EnvoiDAO envoiDAO;
public void save(Envoi envoi) {
envoiDAO.save(envoi);
}
public Envoi update(Envoi envoi) {
return envoiDAO.update(envoi);
}
public void delete(Envoi envoi) {
envoiDAO.delete(envoi);
}
public Envoi find(int entityID) {
// TODO Auto-generated method stub
return null;
}
public List<Envoi> findAll() {
// TODO Auto-generated method stub
return null;
}
/*public Envoi find(int entityID) {
return envoiDAO.find(entityID);
}*/
/*public List<Envoi> findAll() {
return envoiDAO.findAll();
}*/
}
Now you will find the spring bean that publishes the service
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<jaxws:endpoint
id="orderProcess"
implementor="demo.order.OrderProcessImpl"
address="/OrderProcess" />
<jaxws:endpoint
id="EnvoiFacade"
implementor="persistance.facade.EnvoiFacadeImp"
address="/EnvoiFacade" />
</beans>
Now you'll find the client and the bean associated to it
package demo.ejb.client;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import persistance.facade.EnvoiFacade;
import persistance.model.Envoi;
public final class Client {
public Client() {
}
public static void main(String args[]) throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
new String[] { "demo/ejb/client/client-beans.xml" });
EnvoiFacade client = (EnvoiFacade) context.getBean("envoiClient");
Envoi p1 = new Envoi();
p1.setNumet(3690);
p1.setNumseq(9990);
client.save(p1);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<jaxws:client id="envoiClient" serviceClass="persistance.facade.EnvoiFacade" address="http://localhost:8080/orderapp/EnvoiFacade" >
</jaxws:client>
</beans>
Now my webservice deploy just fin in JBOSS 7.1.0 AS , i created the datasources and included the driver for postgres my sql , the problem is when a run the client i get this error
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Fault occurred while processing.
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:143)
at $Proxy57.save(Unknown Source)
at demo.ejb.client.Client.main(Client.java:23)
Caused by: org.apache.cxf.binding.soap.SoapFault: Fault occurred while processing.
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.unmarshalFault(Soap11FaultInInterceptor.java:75)
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:46)
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:35)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:96)
at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:69)
at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:34)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:658)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2139)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:2022)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1947)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:632)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:472)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:302)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:254)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:123)
... 2 more
I had a similar stack trace recently and I found out I was missing a classic setter on one of my fields.