-
1. Re: How to load web.xml
everjava Aug 1, 2011 3:41 PM (in response to mannuyi)you can create a web project and packing it as .war into you esb project. Maybe it works....
myEsbproject.esb
- META-INF/jboss-esb.xml, deployment.xml
- myWebproject.war
-WEB-INF/web.xml
-
2. Re: How to load web.xml
mannuyi Aug 2, 2011 2:06 AM (in response to everjava)If I difine the action class in war, and the other classes are also in war, when executing jboss-esb.xml action flow, does it work?
I will try it, thanks.
-
3. Re: How to load web.xml
everjava Aug 2, 2011 10:36 AM (in response to mannuyi)I used spring anotation to inject service bean, but I failed. Because ESB server didnot load web.xml.
what i said is that you can use a .war into your .esb, and then load your web.xml. Your esb action class still are into .esb project
is not a solution, just a suggestion
-
4. Re: How to load web.xml
mannuyi Aug 2, 2011 10:48 AM (in response to everjava)yes, action classes are in esb project, service and other classes are in war, that doesn't work.
anyway, thanks a lot.
anybody can help me?
-
5. Re: How to load web.xml
h.wolffenbuttel Aug 3, 2011 3:38 AM (in response to mannuyi)Simon,
Everson means you can build your .esb file with the .war in it. If you do that, you will have to define your war in your deployment.xml of your .esb. something like
also you will need a dependancy to spring, otherwise your .esb will be loaded before spring is loaded, like so:
<depends>jboss.esb:deployment=spring.esb</depends>
An alternative is adding a Hibernate.cfg.xml configuration to your esbcontent dir and to create a HibernateSessionFactory instance with that configuration. If you want to use annotations i.e. for hibernate, then you need to create your own HibernateSessionFactory and replace all references to the standard configuration with the AnnotationConfiguration. At least, there wasn't an implementatione when I searched for it.
Regards,
Hans -
6. Re: How to load web.xml
mannuyi Aug 3, 2011 11:47 AM (in response to h.wolffenbuttel)Hi, Hans & Everson
The following is my source coding.
1. jboss-esb.xml
<action name="transform" class="org.jboss.soa.esb.smooks.SmooksAction">
<property name="smooksConfig" value="/smooks-res.xml" />
<property name="resultType" value="JAVA" />
</action>
<action name="receiveAction" class="esb.server.action.ReceiveAction" />
<action name="soapClientAction" class="org.jboss.soa.esb.actions.soap.SOAPClient">
<property name="wsdl" value="http://127.0.0.1:8080/alice/ReimburseService?wsdl" />
<property name="responseAsOgnlMap" value="true" />
<property name="SOAPAction" value="processOrder"/>
</action>
2.ReceiveAction
public class ReceiveAction extends AbstractActionPipelineProcessor {
protected final Log logger = LogFactory.getLog(getClass());
protected ConfigTree _config;
@Resource
private ReceiveService receiveService;
public ReceiveAction(ConfigTree config) {
_config = config;
}
public Message process(Message message) throws ActionProcessingException {
Map javaRequestMap = (Map) message.getBody().get();
ReimburseRequestBO reimburseRequest = (ReimburseRequestBO) javaRequestMap.get("reimburseRequest");
List<ReimburseFile> reimburseFileList = (List<ReimburseFile>) javaRequestMap.get("reimburseFileList");
System.out.println(reimburseRequest.getTitle());
System.out.println(reimburseRequest.getTotalAmount());
System.out.println(reimburseRequest.getRequestDate());
System.out.println(reimburseRequest.getUserId());
System.out.println(reimburseRequest.getRemark());
try {
receiveService.saveReceivedMessage(reimburseRequest, reimburseFileList);
} catch (Exception e) {
e.printStackTrace();
throw new ActionProcessingException(e.getMessage(), e);
}
return message;
}
public void exceptionHandler(Message message, Throwable exception) {
exception.printStackTrace();
}
}
3.ReceiveServiceImpl.java
@Service
public class ReceiveServiceImpl implements ReceiveService {
......
}
If this is a web application project, I can define web.xml to load the spring configuration. ReceiveAction can be injected with ReceiveServiceImpl bean.
At the beginning, I try to figure out whether esb server can recognize the web.xml, but it doesn't work.
In esb project, as the esb samples, we can load spring configuration like this:
<action name="sayHello" class="org.jboss.soa.esb.samples.quickstart.spring_helloworld.MySpringEnabledAction" process="sayHelloSpring,displayMessage">
<property name="springContextXml" value="spring-context-hello.xml"/>
</action>
if there are several actions, should we have to define springContextXml property under every action?
if so, the springContextXml will be loaded several times?
all the actions use the same spring container? under the same transaction? use the same datasource?
-
7. Re: How to load web.xml
mannuyi Aug 12, 2011 12:13 PM (in response to mannuyi)By now, I just use spring + ibatis + esb.
I defined three actions in jboss-esb.xml,
one is used to transform xml to java bean by using smooks,
the second is used to perform message store(in this action, I defined sprint-context property),
the last is used to transfer message to another web service.
-
8. Re: How to load web.xml
tcunning Aug 17, 2011 3:29 PM (in response to mannuyi)Simon, did you follow Hans and everson's suggestions though? They are suggesting you package a WAR inside of your deployment.xml to your ESB archive (check how the quickstarts do it) with dependencies on your WAR and on spring.esb.
In answer to your question - check out the spring_helloworld quickstart. You do have to list the springContextXml in each one of your Spring-enabled actions.
-
9. Re: How to load web.xml
mannuyi Aug 31, 2011 10:53 AM (in response to tcunning)id you follow Hans and everson's suggestions though?
->
I followed the quickstart sample of spring_helloworld.
You do have to list the springContextXml in each one of your Spring-enabled actions.
->
So, the bean configured in the different context will in the different container, right?