Deploying the executable jar in JBoss, the Deploy executable jar in JBoss

Source: Internet
Author: User
Tags jboss

First of all, the topic is a pseudo-proposition, the JBoss container is not supported directly deploy executable jar package, jar will only be loaded as Lib treats. A small workaround is provided here.

Today, I have a problem, the monitoring module in our project to separate into a small project deployment, monitoring logic is relatively simple, the implementation of this small project only rely on some common jar and spring JdbcTemplate.

So I always don't want to make the deployment too complicated, directly write the main () Portal deployment jar is ideal. However, as above, JBoss does not support.

can only be transformed into a Web project to fight the war package, in the tangled with which framework to implement Servet monitoring and start the entrance, brainwave, why not write a servletlistener.

Let's start by changing the project to a web structure, and then start implementing a servlet listener, which is as simple as inheriting servletcontextlistener, and then pasting the boot code into contextinitialized.

public class StartMonitor implements servletcontextlistener{
@Override
public void contextinitialized (Servletcontextevent sce) {
This writes the original executable jar's Main method logic
}
@Override
public void contextdestroyed (Servletcontextevent sce) {
}
}

Configure the Listener in Web. Xml., everything is done. You can run the war package.

<web-app>

<listener>
<listener-class>
${pakagepath}. StartMonitor
</listener-class>
</listener>

</web-app>

Looking back, in fact, this solution is very common, just because I smattering the operation of the servlet container, always feel that running a web must be inseparable from the spring listener that similar things, to introduce many components and so on. But in essence, the servlet itself is very concise? Just provide a range of standard interfaces for third-party extensions (such as listener), and anyone can implement these interfaces as needed.

Further, the components commonly used in the Web struts2, spring,spring MVC is just an implementation of the Servlet standard interface based on experience?

Because the novice first contact is a variety of frameworks, but it is easy to ignore the most basic principle. I'd like to remind you!

Deploying the executable jar in JBoss, the Deploy executable jar in JBoss

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.