Where to put a shared library in JBoss AS 5?

Classloading: You’re right, put the .jars to JBOSS/server/<configuration>/lib, or JBOSS/lib. JBoss AS comes with bundled Hibernate libs which are tested with that AS version. See jboss-6.0.0-SNAPSHOT\server\default\conf\jboss-service.xml: <server> <!– Load all jars from the JBOSS_HOME/server/<config>/lib directory and the shared JBOSS_HOME/common/lib directory. This can be restricted to specific jars by specifying them in the archives attribute. TODO: … Read more

RESTeasy and Returning to a JSP page with a model

Okay, I figured it out for anyone who is interested. It was actually fairly trivial once I found an example. @GET @Path(“{eventid}”) @Produces(“text/html”) public void getEvent(@Context HttpServletResponse response, @Context HttpServletRequest request, @PathParam(“eventid”) Long eventid) throws ServletException, IOException { EventDao eventdao = DaoFactory.getEventDao(); Event event = eventdao.find(eventid); request.setAttribute(“event”, event); request.getRequestDispatcher(“eventView.jsp”).forward(request, response); }

Access Spring beans from a servlet in JBoss

There is a much more sophisticated way to do that. There is SpringBeanAutowiringSupportinside org.springframework.web.context.support that allows you building something like this: public class MyServlet extends HttpServlet { @Autowired private MyService myService; public void init(ServletConfig config) { super.init(config); SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(this, config.getServletContext()); } } This will cause Spring to lookup the ApplicationContext tied to that ServletContext (e.g. created … Read more

Is there any way to have the JBoss connection pool reconnect to Oracle when connections go bad?

Whilst you can use the old “select 1 from dual” trick, the downside with this is that it issues an extra query each and every time you borrow a connection from the pool. For high volumes, this is wasteful. JBoss provides a special connection validator which should be used for Oracle: <valid-connection-checker-class-name> org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker </valid-connection-checker-class-name> This … Read more

Override logging in WildFly

You can use logback to configure logging in your application. You can’t use logback to configure logging for the server. To use logback in your configuration you’ll need to change the add-logging-api-dependencies to false or create a jboss-deployment-structure.xml that excludes the subsystem. You’ll also need to include logback and slf4j in your deployment. The first … Read more

PSQLException: current transaction is aborted, commands ignored until end of transaction block

I got this error using Java and PostgreSQL doing an insert on a table. I will illustrate how you can reproduce this error: org.postgresql.util.PSQLException: ERROR: current transaction is aborted, commands ignored until end of transaction block Summary: The reason you get this error is because you have entered a transaction and one of your SQL … Read more

How to use BOM file with Maven?

A bom is a so called bill of materials – it bundles several dependencies to assure that the versions will work together. JBoss has boms for many of it’s projects, including Arquillian and the JBoss AS itself. There is an explanation of the bom usage in the maven docs – it is hidden well below. … Read more