JBoss - WildFly Interview questions

User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive

Are you going for a JBoss Job ? well we cannot predict what you'll be asked but some questions are quite popular at interviews......check it here !

JBoss Domain mode interview questions

Q: What's the difference between Standalone mode and Domain mode ?

When configured in Standalone mode each distribution starts a single JVM process with its own configuration, management instruments and deployments. When configured in Domain mode, multiple servers are managed from a centralized point called Domain Controller which maintain the configuration and provisions applications for deployment on the single nodes which are part of the Domain

Q: What happens if the Domain Controller fails ?

If the Domain Controller fails, it is not possible to managed the Domain configuration anymore but applications running on the single nodes are preserved. It is however possible to choose a backup Domain Controller server as in the following configuration snippet:

   <remote host="" port="9999" security-realm="ManagementRealm" username="eap7admin">
         <static-discovery name="backup" protocol="remote" host="" port="19999"/>

Q: Do you need Domain mode in order to run a Cluster of JBoss EAP / WildFly nodes ?

No, a cluster can be both configured in Standalone mode and in Domain mode with no difference in terms of Profile configuration. The advantage of configuring a Cluster in Domain mode is that you don't need to manually synchronize the configuration on all your Servers as you would need in a cluster of Standalone Servers. The same stands for provisioning applications: in a Domain running an ha (or full-ha) profile you can provision your applications on a whole Server group with a single Operation. In standalone mode you have to deploy applications on each Server.

Q: Multiple Domains in the same cluster and Multiple clusters in the same Domain: which one of these configurations is possible ?

Both! Let's see each of them:

  • Multiple Domains in the same clusters can be achieved by starting two Domains in the same network which are sharing the same multicast address and port. This is a quite rare scenario, however it's technically possible.
  • Multiple clusters in the same Domain can be achieved by defining a different multicast address on each Server Group or even at Server Level. This way, your Servers, even if in the same Domain, will communicate through different multicast addresses so they will make up separate clusters.

Q: Porting one application from Standalone mode to Domain mode: is it guaranteed that you won't run in any issue ?

One core difference between Standalone mode and Domain mode is that Standalone mode allows manual deployment of applications by copying archives into the deployment folder. On the other hand, in Domain mode applications are managed and copied through the CLI or the Admin Console into the data folder of the single nodes. That being said, some applications might require to know the physical path where the application has been deployed: one good example is LifeRay portal which requires some workarounds to run in Domain mode. So always check the applications requirement before committing to a change from Standalone mode to Domain mode.

Q: If you have JVM Settings at Server Group Level and your Servers are configured to use the Host JVM Settings, which one prevails?

In a managed domain the JVM settings can be declared at different scopes: For a specific server group, for a host or for a particular server. If not declared, the settings are inherited from the parent scope. In this case you have the following configuration (domain.xml):

       <server-group name="main-server-group" profile="default">
           <jvm name="SGdefault">
               <heap size="64m" max-size="512m"/>
           <socket-binding-group ref="standard-sockets"/>
</server groups>

While at Host level you have (host.xml):

       <server name="server-one" group="main-server-group" auto-start="true">
           <jvm name="default"/>

In this case, the Host configuration (named default) prevails, being more specific to the Server.

Hibernate and Transaction Questions

Q:What's the difference between Hibernate and EJB 3 ? Don't you think EJB 3 is just a clone of Hibernate ?

The perception of EJB3 as being a simple clone of Hibernate is primarily based on developer familiarity with Hibernate and a similarity of naming, as well as common purpose, and that Hibernate is morphing itself into an EJB3 implementation based on the work going into the specification, not the other way around.

EJBs are supposed to be components, in the sense that they're not just one class, but a set of classes, descriptors and usage and management contracts. All of this in order to allow a container (JBoss,
Weblogic, etc.) to provide services to those components, and to be able to reuse and distribute this components. This services are, among others, transactions, concurrent access control, security, instance pooling, etcetera.
Hibernat is "just" an ORM (Object/Relational Mapping) tool. Quick and dirty, this means you can store an object tree belonging to an class hierarchy in a relational DB without writing a single SQL query. Quite cool, IMO. But no transaction control, no instance pooling, no concurrency control, and certainly no security.

Q:Which Hibernate object wraps the JDBC Connection ?

The Session interface wraps a JDBC Connection. This interface is a single threaded object which represents a single unit of work with application and persistent database. It's retrieved by the SessionFactory's openSession() method

Q:Ok, is the Session Factory Thread safe?

Yes: that is many threads can access it cuncurrentely and request for sessions. It holds cached data that has been read in one unit of work and may be reused in a future unit of work. Good practice is to create it when the application is initialized.

Q:What is the difference between load and get in Hibernate ?

The main difference between load() and get() methods is that load() throws an Exception if there is no entry for the given id while get() method returns null. The other difference is that load() method creates a placeholder object-also called proxy"-.In other words hibernate will hit database only when the proxy object is actually used.

Q:How can you start a JTA transaction from a Servlet deployed on JBoss ?

JBoss registers in the JNDI tree a JTA UserTransaction Object which can be user to manage a distributed transaction.

Q:What if you need to span your transaction across multiple Servlet invocations ?

You can't with a Servlet. A JTA transaction must start and finish within a single invocation (of the service() method). You should consider using a Stateful SB. In a SFSB with a JTA transaction, the association between the bean instance and the transaction is retained across multiple client calls.

Q:What is the diffrence between a JTA datasource and an XA Datasource ?
Let's take this example:

 <datasource jta="true"  . . . >

When JTA is true, the JCA connection pool manager knows to enlist the connection into the JTA transaction. This means that, if the Driver and the database support it, you can use JTA transaction for a single resource.

@PersistenceContext(unitName = "unit01")
private EntityManager entityManager;

public void addMovie(Movie movie) throws Exception {

In practice this means that if you try to manage a JDBC transaction by yourself when jta is set to true an exception will be raised:

12:11:17,145 SEVERE [com.sample.Bean] (http-/ null: java.sql.SQLException: You cannot set autocommit during a managed transaction!
	at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.setJdbcAutoCommit(BaseWrapperManagedConnection.java:961)
	at org.jboss.jca.adapters.jdbc.WrappedConnection.setAutoCommit(WrappedConnection.java:716)

On the other hand, an XA transaction, is usually referred as a "global transaction", that is a set of two or more related transactions that must be managed in a coordinated way. The transactions that constitute a distributed transaction might be in the same database, but more typically are in different databases and often in different locations. Each individual transaction of a distributed transaction is referred to as a transaction branch.

For example, a distributed transaction might consist of money being transferred from an account in one bank to an account in another bank. You would not want either transaction committed without assurance that both will complete successfully.may span multiple resources. A non-XA transaction always involves just one resource.

Various questions

Q:What are the differences between EJB 3.0 and EJB 2.0 ?
EJBs are now plain old Java objects (POJO) that expose regular business interfaces (POJI), and there is no requirement for home interfaces.

  • Use of metadata annotations, an extensible, metadata-driven, attribute-oriented framework that is used to generate Java code or XML deployment descriptors.

  • Removal of the requirement for specific interfaces and deployment descriptors (deployment descriptor information can be replaced by annotations).

  • Interceptor facility to invoke user methods at the invocation of business methods or at life cycle events.

  • Default values are used whenever possible (“configuration by exception” approach).

  • Reduction in the requirements for usage of checked exception.

  • A complete new persistence model (based on the JPA standard), that supersedes EJB 2.x entity beans

Q:What optimization could I use if the EJB container is the only point of write access to the database ?

You could activate the "Commit Option A" that is the container caches entity bean state between transactions. This option assumes that the container has exclusive access to the persistentstore and therefore it doesn’t need to synchronizethe in-memory bean state from the persistent store at the beginning of each transaction.

Q:Which component handles cluster communication in JBoss ?

The JGroups framework provides services to enable peer-to-peer communications between nodes in a cluster. It is built on top a stack of network communication protocols that provide transport, discovery, reliability and failure detection, and cluster membership management services.

Q:How would you convince my IT department to adopt SOA ?

In my opinion one of the biggest obstacle in the movement towards SOA adoption is the organization’s own IT department.Too many people in the IT organization conceive SOA as a technology concept only, and as such think of SOA as just a set of technologies and infrastructure for exposing, securing, running, and managing Services. Put it this way, SOA is nothing more than Web Services and standardized middleware. The critical flaw in thinking is confusing the technology that sits beneath the Services level of abstraction and the mechanism by which Services are accessed with the architectural approach that aims to decouple the implementation from the consumption and focus on sustainable architecture that allows for continuous change.

Successful SOA adoption requires a cultural shift in the way IT is done. The Service-oriented movement to agility and loose coupling demands a shift from traditional, waterfall styles of development (design-build-test-deploy-manage) to iterative approaches to continuous Service modeling

In a Service-oriented environment, governance moves from nice addon to an absolute requirement prior to the developement of the first Service. Security considerations shift from network boundaries to become context-specific, message-driven, and federated. And of course, the modus operandi of IT as a whole moves from focusing on the short-term project management to meeting the long-term sustainable needs of the business as it changes.

Web Services Questions

Q:If you have defined a web service that needs to transfer quite a lot of information, how would you do ?

You might consider using an attachment to transfer the information.Jboss JAX-WS Web services provides Attachment support with MTOM (Message Transmission Optimization Mechanism) SOAP.

Q:What's the difference between JAX-WS and JAX-RPC ?

Java API for XML-Based RPC (JAX-RPC) is a Legacy Web Services Java API, it uses SOAP and HTTP to do RPCs over the network and enables building of Web services and Web applications based on the SOAP 1.1 specification, Java SE 1.4 or lower.JAX-WS 2.0 is the successor to JAX-RPC 1.1. JAX-WS still supports SOAP 1.1 over HTTP 1.1, so interoperability will not be affected. However there are lots of differences:

  • JAX-WS maps to Java 5.0 and relies on many of the features new in Java 5.0 like Web Service annotations.

  • JAX-RPC has its own data mapping model, JAX-WS's data mapping model is JAXB. JAXB promises mappings for all XML schemas.

  • JAX-WS introduces message-oriented functionality, dynamic asynchronous functionality which are missing in JAX-RPC.

  • JAX-WS also add support, via JAXB, for MTOM, the new attachment specification.

Q:Do you know how you could add support for Web Service transactions ?

JBossTS supports Web Services transactions, including extended transaction models designed specifically for loosely-coupled, long running business processes. J2EE transactions can integrate seamlessly with Web Services transactions using our integrated, bi-directional transaction bridge. Interoperability with many other vendors is provided out-of-the-box and JBoss is an active participant in these standards.
Share your experience with us !

Do you want to share your interview experience with other people of this community ?
mail me (This email address is being protected from spambots. You need JavaScript enabled to view it.) your interview experience and I'll publish it inside this article.


Related articles available on mastertheboss.com

JBoss MBeans POJO

JMX MBean services are the core building blocks of the JBoss Appl

How to a dump of JNDI tree with JMX console ?

#2 JBoss Howto. This is the recipe of the day

How to configure JBoss to bind to a different IP ?

  If you want to change the jboss.bind.address property use the 

How to shut down JBoss from remote ?

JBoss recipe of the day

How to create multiple instances of an Mbean?

  Supposing you need two instances of an MBean, let's say one fo

JBoss classloader issues

By default JBoss (prior to version 3.2) uses a flat class loading

JBoss CheatSheet for Admins