Tagged: glassfish

Using Maven Embedded GlassFish Plugin 4.x


It seems the way I used to work with embedded-glassfish is changed.

references

maven-embedded-glassfish-plugin

<plugin>
  <groupId>org.glassfish.embedded</groupId>
  <artifactId>maven-embedded-glassfish-plugin</artifactId>
  <version>4.0</version>
  <configuration>
    <port>8080</port>
  </configuration>
  <executions>
    <execution>
      <goals>
        <goal>deploy</goal>
      </goals>
      <phase>none</phase>
      <configuration>
        <app>target/${project.build.finalName}.${project.packaging}</app>
        <contextRoot>/</contextRoot>
      </configuration>
    </execution>
  </executions>
  <dependencies>
    <dependency>
      <groupId>org.glassfish.main.extras</groupId>
      <artifactId>glassfish-embedded-all</artifactId>
      <version>4.1</version>
    </dependency>
  </dependencies>
</plugin>

embedded-glassfish:run

$ mvn embedded-glassfish:run
...
Hit ENTER to redeploy, X to exit
_

Now whenever you build your war, you just hit the Enter to redeploy.

@MatrixParam with Jersey


With, currently the newest (3.1.2.2), GlassFish, @MatrixParam doesn’t work as expected.

http://.../path1/path2;value={value} does work,
http://.../path1;value={value}/path2 does not work.

And it’s still open.

One of workarounds is, as stated at Inheritance of duplicate @MatrixParam, using PathSegment along with @PathParam.

@GET
@Path("/{path1: path1}/path2")
public Resource read(
    @PathParam("path1") final PathSegment path1) {

    assert path1 != null;
    assert path1.getPath().equals("path1");

    final MultivaluedMap<String, String> matrixParameters = path1.getMatrixParameters();
    final List<String> values = matrixParameters.get("value");
    final String value = matrixParameters.getFirst("value");

    // ...
}

installing glassfish on ubuntu


references…
http://skytteren.blogspot.com/2009/05/installing-glassfish-v3-on-ubuntu.html
http://www.nabisoft.com/tutorials/glassfish/installing-glassfish-301-on-ubuntu
http://www.lyonlabs.org/howto/howdoi-glassfish.html

$ sudo groupadd --system glassfish
$ sudo useradd --system -g glassfish -d /opt/glassfish3/ glassfish
$ sudo chgrp -R admin /opt/glassfish3/
$ sudo chown -R glassfish /opt/glassfish3/
$ sudo chmod -R +x /opt/glassfish3/bin/ /opt/glassfish3/glassfish/bin/
$ sudo emacs /etc/init.d/glassfish
$ sudo chmod a+x /etc/init.d/glassfish
$ sudo update-rc.d glassfish defaults
#!/bin/sh 
GLASSFISHPATH=/opt/glassfish3/bin 
case "$1" in 
start) 
echo "starting glassfish from $GLASSFISHPATH" 
sudo -u glassfish $GLASSFISHPATH/asadmin start-domain domain1 
;; 
restart) 
$0 stop 
$0 start 
;; 
stop) 
echo "stopping glassfish from $GLASSFISHPATH" 
sudo -u glassfish $GLASSFISHPATH/asadmin stop-domain domain1 
;; 
*) 
echo $"usage: $0 {start|stop|restart}" 
exit 3 
;; 
esac 
: 
asadmin> change-admin-password
Enter admin user name [default: admin]>
Enter admin password>
Enter new admin password>
Enter new admin password again>
Command change-admin-password executed successfully.
asadmin> enable-secure-admin
Enter admin user name>  admin
Enter admin password for user "admin">
You must restart all running servers for the change in secure admin to take effect.
Command enable-secure-admin executed successfully.