Can we deploy EJB 3.x as a separate jar from war (No EAR) on JBoss EAP 6.4 for container managed transactions?
narendrarc Jan 30, 2018 4:04 AMI have application in which we do distributed deployment means restws.war, serverEjb.jar and Dao.jar separately and war has there dependency in jboss-deployment-structure.xml.
We are using RestEasy (2.3.10.Final), EJB3 and Spring JDBC Template (4.3.0.RELEASE).
Structure is:
- Rest.war
- Ejb.jar
- DAO.jar
With jboss-deployment-structure.xml
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<dependencies>
<module name="deployment. Ejb.jar"/>
<module name="deployment.DAO.jar"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
We have stateless Local session bean with CMT, there is no error in the log while deployment but when we access EJB method no rollback is happening on runtime exception rather each sql statement commits after the execution.
EJB File looks like
-------------------
@Stateless
public class ProductService {
@Inject
ProductDAO productDAO;
public Product getProduct() {
Product product =productDAO.getProduct();
return product;
}
public Product createProduct(Product product) {
return productDAO.createProduct(product);
}
}
RestEasy Service looks like
---------------------------
@Path("/json/product")
public class ProductService {
@Inject
ProductService productService;
@GET
@Path("/get")
@Produces("application/json")
public Product getProduct() {
return productService.getProduct();
}
@POST
@Path("/post")
@Consumes("application/json")
public Response createProduct(Product product) {
product=productService.createProduct(product);
String result = "Product created : " + product;
return Response.status(201).entity(result).build();
}
}
If I combine these jar in as WAR using same compiled jar by removing the MANIFEST.MF Dependencies then EJB behavior is as expected and truncation rollback.
War Structure:
- Rest.war
META-INF
WEB-INF
classes
lib
ejb.jar
DAO.jar
…. Third party jar
- beans.xml
- web.xml
I used same/similar code base to build a ear fine then also it works.
War Structure:
ear-application-1.0.ear
lib
DAO.jar
…. Third party jar
META-INF
application.xml
ejb.jar
web.war
- application.xml
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" version="6">
<display-name>ear-application</display-name>
<module>
<web>
<web-uri>web.war</web-uri>
<context-root>/rest</context-root>
</web>
</module>
<module>
<ejb>ejb.jar</ejb>
</module>
<library-directory>lib</library-directory>
</application>
Please help me understanding and resolving this issue.