*Next task* – adding a license-based header (template) to Netbeans 7 Maven-based projects.

This dzone article seems to relate to Ant based projects as I cannot see an Important Files (Smart) folder, nor can I see a nbproject/project.properties file.

However I found this netbeans forum discussion on the topic and it says that you modify the pom.xml adding this:

<name>My Application</name>

<licenses>
  <license>
    <name>The Apache Software License, Version 2.0</name>
    <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    <distribution>repo</distribution>
    <comments>A business-friendly OSS license</comments>
  </license>
</licenses>

<properties>
  ...

To the pom.xml (I added it as a top-level element as a child of and an adjacent sibling to <name> and <properites>.

If the URL is one of the following then the appropriate template (Tools > Templates) is used.

Don’t forget to set the properties such as user as discussed in the dzone article.

Written on October 31st, 2012 , My Projects, netbeans, Spritzer Tags: , ,

I’ve been on holidays, leaving the evening after updating my Mac to the latest Java.

This update essentially (for 10.7 and 10.8) users, removed Apple’s involvement in Java for the platform completely by removing Java Preferences and making the default Java 7. More info at Cnet.com / Java Preferences missing after latest OS X Java update.

Anyway, I was receiving emails from Crash Plan telling me I haven’t backed up for days. Mmm I thought, I wonder what my wife has done :).

I got home and sure enough the CP menu-bar icon was grayed out and there was a message saying “Unable to connnect to the local backup engine”. My wife was not the cause (not that I really thought that anyway but still gotta wonder).

I opened Console and I found it saying:

26/10/12 11:07:59.610 PM com.apple.launchd: (com.crashplan.engine[2566]) Tried to setup shared memory more than once

Suggestions were that CrashPlan needed to up the -Xmx Java max memory setting. Made no difference.

I then looked a bit deeper and found /Library/Logs/CrashPlan, and in particular the engine_error.log.

It said:

java.lang.ExceptionInInitializerError
at com.code42.os.mac.io.IOPolicy.setIoPolicy(IOPolicy.java:69)
at com.backup42.service.CPService.start(CPService.java:383)
at com.backup42.service.CPService.main(CPService.java:1622)
Caused by: com.jniwrapper.LibraryNotFoundException: Cannot find JNIWrapper native library (libjniwrap.jnilib) in java.library.path: /var/root/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.:/Applications/CrashPlan.app/Contents/Resources/Java/lib

java -version

tells me its Java 1.7 which made me thing something was odd since I set 1.6 as the default.

I tried to open Java Preferences, which on the Mac let you set which version of Java is the default. It no longer existed. I found the cnet article liked to above (Cnet.com / Java Preferences missing after latest OS X Java update) telling me the Java ecosystem on the Mac is changing.

I searched on “Crash Plan mac osx java 7” and I found this java.dzone article. It said to change the version of Java used for the Crash Plan service back to 1.6 in the /Library/LaunchDaemons/com.crashplan.engine.plist Launch Daemon file. See that article for precise instructions.

Following this remedy fixed the problem. As a bonus I can drop my Java max memory (back to the 512k)!

Written on October 26th, 2012 , Java, Mac OS X Tags: , ,

I’ve added code I’ve put into my portfolio. I’ve just started growing this as its never seemed important in the past. Check out what I’ve done and let me know what you think.

See http://tintuna.com/drupal/ProjectsAndCode

Written on October 22nd, 2012 , Portfolio

I saw InjectionPoint mentioned breifly by Adam Bien in his JavaOne 2011 Presentation JavaEE 6 Cool Parts (around about 0:50).

There wasn’t much information about it though I found the Javadoc at http://docs.oracle.com/javaee/6/api/javax/enterprise/inject/spi/InjectionPoint.html and it had all I needed to know.

For example, the following producer method creates injectable Loggers. The log category of a Logger depends upon the class of the object into which it is injected.

@Produces
Logger createLogger(InjectionPoint injectionPoint) {
return Logger.getLogger( injectionPoint.getMember().getDeclaringClass().getName() );
}

And it works!

//index.xhtml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html">
  <h:head>
    <title>Facelet Title
  </h:head>
  <h:body>
    Hello from Facelets
    <h:form>
      <h:commandButton value="Injector seat!" action="#{messenger.hello}"/>
    </h:form>
  </h:body>
</html>
// Messenger.java
package boundary;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.inject.Inject;
import javax.inject.Named;

/**
 *
 * @author bsmith
 */
@Named
public class Messenger {
    @Inject String data;
    @Inject Logger log;

    public void hello() {
        System.out.println("Hello!  I want: "+data);
        log.log(Level.SEVERE, "("+log.getName()+") I am logging some data: "+data);
    }
}
// Configuration.java
package control;

import java.util.logging.Logger;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;

/**
 *
 * @author bsmith
 */
public class Configuration {
    @Produces
    public String getData(InjectionPoint ip) {
        System.out.println("ip.toString: "+ip.toString());
        System.out.println("ip.getAnnotated: "+ip.getAnnotated());
        System.out.println("ip.getBean: "+ip.getBean());
        return "data";
    }

    @Produces
    public Logger getLogger(InjectionPoint ip) {
        return Logger.getLogger( ip.getMember().getDeclaringClass().getName() );
    }
}

INFO: com.tintuna_Injection_war_1.0-SNAPSHOT was successfully deployed in 398 milliseconds.
INFO: ip.toString: [field] @Inject boundary.Messenger.data
INFO: ip.getAnnotated: [field] @Inject boundary.Messenger.data
INFO: ip.getBean: Managed Bean [class boundary.Messenger] with qualifiers [@Any @Default @Named]
INFO: Hello!  I want: data
SEVERE: (boundary.Messenger) I am logging some data: data
Written on October 13th, 2012 , EJB, Java Tags: , ,

Brooke Smith is proudly powered by WordPress and the Theme Adventure by Eric Schwarz
Entries (RSS) and Comments (RSS).

Brooke Smith

Portfolio and site of a software engineer