Social networks
You can find me on:
   
Open sharing content

These articles are available under Creative Commons license BY-SA-3.0

Archive for December, 2013

The new Java update on January, the 14th won´t make your applets work unless you get them signed from a certificate Authority. However you might just make a workaround if you can make your users import your own certificate.

The steps to follow are:

1. In every jar edit the MANIFEST.MF file. The “Permissions” attribute must be provided. To grant all the permissions add the following line:
Permissions: all-permissions

2. Edit the java web start file (*.jnlp). Although the latest documentation says it´s no longer necessary to include the security tag, to make it work with your self-signed jars the element must be included. For example, if you set “all-permissions” in the manifest, in the jnlp file you must insert:

<security>
   <all-permissions/>
</security>

The “Codebase” attribute in the jnlp file must match the hosting server name including the port number (ex. http://localhost:8080/”).
Once you have packed all the jars, you can sign them with your own keystore. The steps to execute are the following:

3.Make a new keystore (ex. “demoStore”) with an alias (ex. “demoAlias”):
keytool -keystore demoStore -genkey -alias demoAlias
It will ask to insert some information (name, firm, country, etc.)

4.Make a self-signed certificate (valid for 3650 days):
keytool -selfcert -alias demoAlias -genkey -keystore demoStore -validity 3650

5.Sign all the jars like:
jarsigner -keystore demoStore FileName.jar demoAlias
After running the command, the console will display ”The signer certificate will expire in six months”.

6.Export the keystore certificate:
keytool -export –keystore demoStore -alias demoAlias -file demoStore.csr

7.Import the self-signed certificate.
In MS Windows you need import certificate. Open the Java Control Panel , navigate to Security -> Manage Certificates, select Certificate Type: Signer CA  and import the new *.csr (ex. demoStore.csr) certificate.
Now you can run you Java Web Start application without warnings. You should see the following dialog : http://java.com/de/img/download/trusted_signed.jpg.

To run a test with Arquillian using Maven you might consider embedded, local or remote containers. You can set them all in your pom.xml file and specify deployment profiles like the following:

 <profile>
			<id>arquillian-glassfish-embedded</id>
			<activation>
				<activeByDefault>true</activeByDefault>
			</activation>
			<dependencies>
				<dependency>
					<groupId>org.jboss.arquillian.container</groupId>
					<artifactId>arquillian-glassfish-embedded-3.1</artifactId>
					<version>1.0.0.CR4</version>
					<scope>test</scope>
				</dependency>
				<dependency>
					<groupId>org.glassfish.main.extras</groupId>
					<artifactId>glassfish-embedded-all</artifactId>
					<version>4.0</version>
					<scope>provided</scope>
				</dependency>

				<dependency>
					<groupId>org.glassfish.jersey.core</groupId>
					<artifactId>jersey-client</artifactId>
					<version>2.4.1</version>
					<scope>provided</scope>
				</dependency>

				<dependency>
					<groupId>org.glassfish.jersey.containers</groupId>
					<artifactId>jersey-container-servlet</artifactId>
					<version>2.4.1</version>
					<scope>provided</scope>
				</dependency>

			</dependencies>
		</profile>

The container must be configured in the arquillian.xml file. A simple one might look like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns="http://jboss.org/schema/arquillian"
   xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
   <!--  this is only needed if you want to override AS7  -->
   <!--  <defaultProtocol type="Servlet 3.0"/> -->
   <container qualifier="arquillian-glassfish-embedded">
   	<configuration>
   		<property name="bindHttpPort">9090</property>
   	</configuration>
   </container>
   <!-- 
   <container qualifier="tomcat">
   	<configuration>
   		<property name="user">tomcat</property>
   		<property name="pass">tomcat</property>
   	</configuration>
   </container>
    -->
</arquillian>

Setting the container in the pom.xml and the arquillian.xml files is not enough to run the test in Eclipse.
You would get the following error:

org.jboss.arquillian.container.test.impl.client.deployment.ValidationException: DeploymentScenario contains a target (_DEFAULT_) not matching any defined Container in the registry.
Please include at least 1 Deployable Container on your Classpath.
          at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.throwNoContainerFound(DeploymentGenerator.java:250)
          at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.throwTargetNotFoundValidationException(DeploymentGenerator.java:243)
          at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.validate(DeploymentGenerator.java:102)
          at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.generateDeployment(DeploymentGenerator.java:84)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
          at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
          at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
…

To make the test run you need to set the active maven profiles in Eclipse. Simply right click on the project and select Properties>Maven and add “arquillian-glassfish-embedded” in the Active maven profiles textbox.