User Tools

Site Tools


jboss

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
jboss [2013/10/29 10:05] skipidarjboss [2020/12/27 20:35] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +==== Debug in Eclipse IDE ====
  
 +Open the configuration file of the JBoss **standalone.conf**
 +
 +Uncomment the following line at the bootom of the file
 +<code>
 +# Sample JPDA settings for remote socket debugging
 +JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
 +</code>
 +
 +Open the configuraion file of the JBoss **standalone.conf.bat**
 +
 +Uncomment the following line:
 +<code>
 +rem # Sample JPDA settings for remote socket debugging
 +set "JAVA_OPTS=%JAVA_OPTS% -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
 +</code>
 +
 +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
 +
 +<code>
 +    <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>
 +</code>
 +
 +
 +==== Deployment ====
 +
 +To Deploy an artifact on jboss it ust be annotated as a Service or Bean:
 +<sxh java>
 +// 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;
 +    ...
 +}
 +</sxh>
 +
 +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**
 +
 +<sxh java>
 + <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>
 +</sxh>
 +
 +
 +==== 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.
 +
 +<sxh java>
 +
 +    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);
 +    }
 +</sxh>