Monday, August 6, 2012

Never forget: hostnames

From wikipedia:
Restrictions on valid host names Hostnames are composed of series of labels concatenated with dots, as are all domain names. For example, "en.wikipedia.org" is a hostname. Each label must be between 1 and 63 characters long,[1] and the entire hostname (including the delimiting dots) has a maximum of 255 characters. The Internet standards (Request for Comments) for protocols mandate that component hostname labels may contain only the ASCII letters 'a' through 'z' (in a case-insensitive manner), the digits '0' through '9', and the hyphen ('-'). The original specification of hostnames in RFC 952, mandated that labels could not start with a digit or with a hyphen, and must not end with a hyphen. However, a subsequent specification (RFC 1123) permitted hostname labels to start with digits. No other symbols, punctuation characters, or white space are permitted. While a hostname may not contain other characters, such as the underscore character (_), other DNS names may contain the underscore.[2] Systems such as DomainKeys and service records use the underscore as a means to assure that their special character is not confused with hostnames. For example, _http._sctp.www.example.com specifies a service pointer for an SCTP capable webserver host (www) in the domain example.com. Note that some applications (e.g. IE) won't work correctly if any part of the hostname will contain an underscore character[3]. One common cause of non-compliance with this specification is that neither Microsoft Windows nor Android smartphones enforce the rule against using an underscore in hostnames. Since some systems will reject invalid hostnames while others will not, the use of invalid hostname characters may cause subtle problems in systems that connect to standards-based services. For example, RFC-compliant mail servers will refuse to deliver mail for MS Windows computers with names containing underscores. The hostname en.wikipedia.org is composed of the DNS labels en (hostname or leaf domain), wikipedia (second-level domain) and org (top-level domain). Labels such as 2600 and 3abc may be used in hostnames, but -hi- and *hi* are invalid. A hostname is considered to be a fully qualified domain name (FQDN) if all the labels up to and including the top-level domain name (TLD) are specified. The hostname en.wikipedia.org terminates with the top-level domain org and is thus fully qualified. Depending on the operating system DNS software implementation, an unqualified hostname such as csail or wikipedia may be automatically combined with default domain names configured into the system, in order to determine the fully qualified domain name. As an example, a student at MIT may be able to send mail to "joe@csail" and have it automatically qualified by the mail system to be sent to joe@csail.mit.edu. General guidelines on choosing good hostnames are outlined in RFC 1178.

Friday, March 30, 2012

Eheheh just jocking with interfaces

Any other idea about how to expose a component?

ui... rest... ws... ejb...

package net.sixdeex.jpc.services;

import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebParam.Mode;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import net.sixdeex.jpc.CalculateDescendCommand;
import net.sixdeex.jpc.framework.CalculateCommand;
import net.sixdeex.jpc.framework.OutputData;

@Path("/x737")
@Produces(MediaType.APPLICATION_JSON)
@Stateless
@Local(X737Calculation.class)
@Remote(RemoteX737Calculation.class)
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
@WebService
public class X737CalculationBean implements RemoteX737Calculation {

    @GET
    @Path("/descend/{from}/{to}")
    @Override
    @WebMethod(operationName = "descend")
    public @WebResult(name = "outputData")
    OutputData descend(
            @PathParam("from") @WebParam(name = "fromLevel", mode = Mode.IN) int fromLevel,
            @PathParam("to") @WebParam(name = "toLevel", mode = Mode.IN) int toLevel) {

        final CalculateCommand calculateDescend = new CalculateDescendCommand(
                null, fromLevel, toLevel);

        return calculateDescend.execute();
    }
}

Friday, March 2, 2012

maven wsimport and deploy phase problem when behind a firewall

I did a client module that perform wsgen to get the WSDL from the server module and then the wsimport to create the client jar.

Everything works up to the install phase but fails in the deploy phase... the behavior is that mvn succed in uploading the jar but fails to upload the pom with the following error:

Failed to deploy artifacts: Could not find artifact ... in ...

To fix the problem it is required to unset the proxy when calling the wsimport goal with

<httpproxy>::</httpproxy>

as shown in the following pom:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <groupId>my.group</groupId>
        <artifactId>parent</artifactId>
        <version>0.1-SNAPSHOT</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>

    <groupId>my.group.ws</groupId>
    <artifactId>ws-client</artifactId>
    <version>0.1-SNAPSHOT</version>

    <name>WS client</name>
    <packaging>jar</packaging>

    <dependencies>
        <dependency>
            <groupId>my.group.ws</groupId>
            <artifactId>ws-server</artifactId>
            <version>0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-rt</artifactId>
            <version>2.2.6</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>${project.build.directory}/generated-sources/wsimport</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerArguments>
                        <endorseddirs>${project.build.directory}/endorsed</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jvnet.jax-ws-commons</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>2.2</version>
                <executions>
                    <execution>
                        <id>wsgen</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>wsgen</goal>
                        </goals>
                        <configuration>
                            <sei>my.group.ws.sei.SEIClass</sei>
                            <genWsdl>true</genWsdl>
                            <keep>false</keep>
                        </configuration>
                    </execution>
                    <execution>
                        <id>wsimport</id>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                        <configuration>
                            <wsdlDirectory>${project.build.directory}/generated-sources/wsdl</wsdlDirectory>
                            <sourceDestDir>${project.build.directory}/generated-sources/wsimport</sourceDestDir>
                            <keep>false</keep>
                            <httpproxy>::</httpproxy>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <excludes>
                        <exclude>my/group/ws/jaxws/*</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.3</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
                            <silent>true</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>javax.xml.bind</groupId>
                                    <artifactId>jaxb-api</artifactId>
                                    <version>2.2.4</version>
                                    <type>jar</type>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>javax.xml.ws</groupId>
                                    <artifactId>jaxws-api</artifactId>
                                    <version>2.2.8</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>