==== 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:
{{http://i.imgur.com/xs6aqBr.png?400}}
Add debuggin points in server Code, there will be an own debugging stack:
{{http://i.imgur.com/hma0x7q.png?400}}
==== 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
==== 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 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**
org.my.path.to.domain.TaskBean
org.my.path.to.domain.TaskGroupBean
org.my.path.to.domain.person.PersonenBean
==== 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**:
{{ http://i520.photobucket.com/albums/w327/schajtan/2016-02-13_20-05-32_zpsy3b3ekcy.png }}
==== 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 get(Class 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);
}