Table of Contents
Debug in Eclipse IDE
Open the configuration file of the JBoss standalone.conf
Uncomment the following line at the bootom of the file
# Sample JPDA settings for remote socket debugging JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
Open the configuraion file of the JBoss standalone.conf.bat
Uncomment the following line:
rem # Sample JPDA settings for remote socket debugging set "JAVA_OPTS=%JAVA_OPTS% -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
Debugging via Port 8787 is enabled after you restart the server.
Connect with the debugger:
Add debuggin points in server Code, there will be an own debugging stack:
Publishing Services over IP
The settings are located in standalone.xml To make the JBoss7 reachable not over localhost only do:
- provide a new interface (named “public” here) which opens a socket over any ip
- assing this interface to the sockets you wish to open
<interfaces> <interface name="management"> <inet-address value="${jboss.bind.address.management:127.0.0.1}"/> </interface> <interface name="public"> <any-ipv4-address/> </interface> </interfaces> <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}"> <socket-binding name="management-native" interface="public" port="${jboss.management.native.port:9999}"/> <socket-binding name="management-http" interface="public" port="${jboss.management.http.port:9990}"/> <socket-binding name="management-https" interface="public" port="${jboss.management.https.port:9443}"/> </socket-binding-group>
Deployment
To Deploy an artifact on jboss it ust be annotated as a Service or Bean:
// annotating a service as Stateless is enough to make in injectable. Here it is injectable via intrerfaces @Remote(BasicService.class) @Local(BasicServiceLocal.class) @Stateless public class BasicServiceBean{ ... } // annotating a bean maps it to a table in the DB @Entity @Table(name = "PERSONEN") @NamedQueries({@NamedQuery(name = PersonenBean.FIND_NEXT_PERSON_ID, query = "SELECT COALESCE(MAX(id.personNr)+1, 1) FROM PersonenBean") }) @FilterDef(name = HasCtxMandant.FILTER, parameters = {@ParamDef(name = HasCtxMandant.FILTER_PARAM, type = "java.lang.String") }) @Filter(name = HasCtxMandant.FILTER, condition = ":" + HasCtxMandant.FILTER_PARAM + "=mandant_id") public class PersonenBean extends AbstractEntity<PersonenId> implements Serializable, HasCtxMandant { private static final long serialVersionUID = 1L; public static final String FIND_NEXT_PERSON_ID = "PersonenBean.findNextPersonId"; @EmbeddedId public PersonenId id; @Column(name = "NACHNAME") public String name; @Column(name = "VORNAME") public String firstName; ... }
If the bean is not within the deployed war - it has to be introduced to the system manually, by adding an entry to the persistance.xml
<class>org.my.path.to.domain.TaskBean</class> <class>org.my.path.to.domain.TaskGroupBean</class> <class>org.my.path.to.domain.person.PersonenBean</class> </persistence-unit> </persistence>
Socket bindings - ports
Jboss default ports can be checked by
- starting the WildFly server
- navigating the admin console via browser http://localhost:9990/. (The default management Port is 9990)
The ports can be seen in section Socket Bindings:
JNDI - Communication between Client and Server
A technique, which allows to retrieve services via their names. This is a way to communicate between Server and Client, by retrieving server-services by their names.
public static <T> T get(Class<T> serviceClass, String moduleName, String serviceImplName, boolean ignoreNameNotFound) { try { InitialContext initCtx = createInitialContext(); return lookup(initCtx, serviceClass, LOCAL_PREFIX + moduleName, serviceImplName, ignoreNameNotFound); } catch (Throwable ex) { log.error("Error retrieving service", ex); if (ex instanceof RuntimeException) { throw (RuntimeException) ex; } else { throw new RuntimeException(ex); } } } private static InitialContext createInitialContext() throws NamingException { Properties prop = new Properties(); prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.as.naming.InitialContextFactory"); return new InitialContext(prop); }