Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Thursday, November 21, 2013

oracle and apache cxf

How to setup Ruby and new Oracle Instant Client on Leopard

http://blog.rayapps.com/2008/04/24/how-to-setup-ruby-and-new-oracle-instant-client-on-leopard/ ul>li*>a[href='$#']{$#}

Get Oracle Instant Client working on Mac. Then get it working with Ruby!

export DYLD_LIBRARY_PATH="/usr/local/oracle/instantclient_10_2"
export SQLPATH="/usr/local/oracle/instantclient_10_2"
export TNS_ADMIN="/usr/local/oracle/network/admin"
export NLS_LANG="AMERICAN_AMERICA.UTF8"
export PATH=$PATH:$DYLD_LIBRARY_PATH

RubyForge: ruby-oci8: Project Filelist

http://rubyforge.org/frs/?group_id=256

Download Ruby OCI8.

Tnsnames.ora - Oracle FAQ

http://www.orafaq.com/wiki/Tnsnames.ora

SERVICE_NAME is the same thing as SID?

ORA11 =
 (DESCRIPTION = 
   (ADDRESS_LIST =
     (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
   )
 (CONNECT_DATA =
   (SERVICE_NAME = ORA11)
 )
)

Another example

connection_label =
 (DESCRIPTION = 
   (ADDRESS_LIST =
     (ADDRESS = (PROTOCOL = TCP)(HOST = server.name.org)(PORT = 1521))
   )
 (CONNECT_DATA =
   (SERVICE_NAME = service.name)
 )
)

Class: OCI8 - Documentation by YARD 0.7.5

http://ruby-oci8.rubyforge.org/en/OCI8.html

Documentation for OCI8. What are the parameters for the constructor again?

 - (OCI8) initialize(username, password, dbname = nil, privilege = nil) constructor 

Instant Client downloads for Mac OS X (Intel x86)

http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html

You need a username/password to get access to these, but it's no big deal.

It might also be handy to have Oracle JDBC drivers around as well.

Markdown - Wikipedia, the free encyclopedia

http://en.wikipedia.org/wiki/Markdown

I finally checked out how to add markdown for SO (Stack Overflow) entries.

Text attributes *Italic*, **bold**, `monospace`.

<p>Text attributes <em>Italic</em>,
<strong>bold</strong>,
<code>monospace</code>.</p>

Bash - Manipulating Strings - Substring Extraction

http://tldp.org/LDP/abs/html/string-manipulation.html

Extracts $length characters of substring from $string at $position.

${string:position:length}

echo ${stringZ:0}                            # abcABC123ABCabc
echo ${stringZ:1}                            # bcABC123ABCabc
echo ${stringZ:7}                            # 23ABCabc

echo ${stringZ:7:3}                          # 23A
                                             # Three characters of substring.

Apache CXF -- FAQ

http://cxf.apache.org/faq.html#FAQ-HowcanIturnonschemavalidationforjaxwsendpoint%3F

It appears there is a configuration setting that can be used to have Apache CXF handle validation. It also appears that this will not be a turn-key solution for me. Something is not quite right as it seems CXF doesn't have access to the XSD files, even though they are included in the class path.

Thursday, November 14, 2013

attempts to work edit remote files locally

java

multithreading - kill -3 to get java thread dump - Stack Overflow

http://stackoverflow.com/questions/4876274/kill-3-to-get-java-thread-dump
jstack PID > outfile

css

Border-radius: create rounded corners with CSS! - CSS3 . Info

http://www.css3.info/preview/rounded-border/

Beautiful! Simple and effective. IE, why can't you conform?!

xterm

Setting up X Term

Trying to get xterm to work appears to be rather simple, even if Apple decided to not include X11 with it's OS anymore. XQuartz was simple enough to set up. I'm not currently using xterm right now, but it's there if I need it. One major bone to pick -- why can't I paste into an xterm window?! I don't have a middle mouse button (Magic Mouse) and I don't know how to overcome this obstacle.

ssh; xforward

Configuring xhost

The effort to use xhost to use an xterm session to work on remote resources should be relatively easy and straight forward. It's easy, that is, if you have control over the remote to turn the X Forward option on.

ssh

Speeding up SSH (ControlMaster) - nion's blog

http://nion.modprobe.de/blog/archives/502-Speeding-up-SSH-ControlMaster.html

Nearly two years passed and there are still people out there who don't know 'ControlMaster' which was introduced in OpenSSH 4.0.

http://nion.modprobe.de/blog/archives/502-Speeding-up-SSH-ControlMaster.html

vim - Using Macvim over ssh - Stack Overflow

http://stackoverflow.com/questions/5321594/using-macvim-over-ssh

Slick; just found out about this option. Open a single file remotely through my Vim client for editing. This works if you have already configured the remote with your ssh key.

:e scp://username@host.com/path/to/file

SSH Can Do That? Productivity Tips for Working with Remote Servers | Smylers [blogs.perl.org]

http://blogs.perl.org/users/smylers/2011/08/ssh-productivity-tips.html

Extensive resource on how ssh can be used to ease your burdens.

$ mkdir gallery_src
$ sshfs dev:projects/gallery/src gallery_src
$ cd gallery_src
$ ls

Setting up OXSFuse and SSHFS

This is just what I need to use my local editor to edit files on a remote system. I can open multiple files with a single call and I don't need to worry with scp'ing files over once I'm done editing them.

umount - Unmount the directory which is mounted by sshfs in Mac - Stack Overflow

http://stackoverflow.com/questions/14057830/unmount-the-directory-which-is-mounted-by-sshfs-in-mac

If this doesn't work, try using sudo.

umount -f <absolute pathname to the mount point>

c3p0 debugging/logging

c3p0-v0.9.5-pre5 - JDBC3 Connection and Statement Pooling - Documentation

http://www.mchange.com/projects/c3p0/#configuring_logging

Logging levels.

  • OFF
  • SEVERE
  • WARNING
  • INFO
  • CONFIG
  • FINE
  • FINER
  • FINEST
  • ALL

log4j.properties example

http://www.mkyong.com/logging/log4j-log4j-properties-examples/

Basic log4j.properties file. Log to STDOUT and to a file.

# Root logger option
log4j.rootLogger=INFO, file, stdout
 
# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=C:\\loging.log
log4j.appender.file.MaxFileSize=1MB
log4j.appender.file.MaxBackupIndex=1
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
 
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

Using Maven to execute a Java class with Java options

I needed to run a Maven script, explicitly including both java options and application arguments. My boss gave me this sample which makes it possible to do so via a Maven call.

Note that the goal is changed from java to exec. There is no mainClass; instead, use executable. Then make sure the argument values are included in the order they should appear in the command. Maven makes it easy to include the classpath with the classpath element.

The system properties in the systemProperties section become superfulous since they are being included earlier in the argument values.

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <executions>
        <execution>

            <phase>test</phase>

            <goals>
                <goal>exec</goal>
            </goals>

            <configuration>

                <!-- mainClass>jovial.Runner</mainClass -->
                <executable>java</executable>

                <arguments>
                    <argument>-classpath</argument>
                    <classpath />
                    <argument>-Dcom.mchange.v2.log.MLog=com.mchange.v2.log.log4j.Log4jMLog</argument>
                    <argument>jovial.Runner</argument>
                    <argument>${main.basedir}/jovial-config.xml</argument>
                </arguments>

                <systemProperties>
                  <systemProperty>
                    <key>com.mchange.v2.log.MLog</key>
                    <value>com.mchange.v2.log.log4j.Log4jMLog</value>
                  </systemProperty>
                </systemProperties>

            </configuration>
        </execution>
    </executions>
</plugin>

Thursday, October 3, 2013

Illegal key size and JCE

android - java.security.InvalidKeyException: Illegal key size - Stack Overflow

Java publishes the "JCE Unlimited Strength Jurisdiction Policy Files" separate from it's normal distribution so that laws around cryptography are not violated. In order to get past this error, you must update local_policy.jar and US_export_policy.jar as indicated in the installation instructions (which come packaged with the download). One place you can download these is from Oracle.

  • local_policy.jar
  • US_export_policy.jar

maven 2 - Can I change the alias of my key? - Stack Overflow

Want to change the alias for a trusted public key or private key entry? Easy, peasy.

keytool -changealias -alias "your-very-very-long-alias" -destalias "new-alias" -keypass keypass -keystore /path/to/keystore -storepass storepass

iOS 7 iMessages and Facetime won't activate! - MacRumors Forums

http://forums.macrumors.com/showthread.php?t=1594713

I was experiencing some problems on my iMac with getting iMessages to be active. I applied updates and restarted the computer and I was back in business.

Apparently other people have had problems, especially with iOS 7.

My Apple ID

https://iforgot.apple.com/password/verify/appleid?app_type=ext&app_id=1581

Hey; it's hard remembering all those passwords all the time, right?

Bash-Prog-Intro-HOWTO-8: Functions

http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-8.html

Bash functions.

   #!/bin/bash 
   function quit {
       exit
   }
   function hello {
       echo Hello!
   }
   hello
   quit
   echo foo 

Saturday, September 28, 2013

weblog; Apache CXF; getting message-level encryption to work

Bash

Bash Arrays | Linux Journal

http://www.linuxjournal.com/content/bash-arrays

Provide a list in open/close parentheses, unadorned.

array=(one two three four [5]=five)

echo "Array size: ${#array[*]}"

echo "Array items:"
for item in ${array[*]}
do
    printf "   %s\n" $item
done

Bash For Loop Examples

http://www.cyberciti.biz/faq/bash-for-loop/

The array here doesn't use parentheses.

for VARIABLE in 1 2 3 4 5 .. N
do
 command1
 command2
 commandN
done

bash - escaping newlines in sed replacement string - Stack Overflow

http://stackoverflow.com/questions/8991275/escaping-newlines-in-sed-replacement-string

Newlines will be recognized in the replace clause (the second half), but not in the match clause. Instead, you will need to use the N and D flags.

echo 'abc' | sed 's/b/\ 
> /'
a
c

Gather dependencies from pom files

http://www.grymoire.com/Unix/Sed.html#uh-51

Navigate to the root directory of Maven project with sub-modules, copy and paste the following code. The code depends on the correct order of a dependency declaration: groupId, articleId, version. Otherwise, all bets are off. This is intended to be quick and dirty; a SAX parser would be more robust.

The following temp files are used for each pom.xml in turn.

  • work.txt: contains ''
  • work2.txt: strips off '', leaving groupId:articleId:version

results.txt: The final file, providing a compilation of dependencies for all pom.xml files.

for file in $(find . -name "pom.xml")
do

cfile=$(printf '%q' $file)

sed '
# look for a <groupId>...</groupId>
/[^<]*<groupId>\([^<]*\)<\/groupId>.*$/ {
# Found one - now read in the next line
 N
# delete the <groupId>...</groupId> and replace with <maven-dependency>
 s/[^<]*<groupId>\([^<]*\)<\/groupId>[\n\r]*[^<]*/<maven-dependency>\1/
}

/<artifactId>\([^<]*\)<\/artifactId>.*$/ {
 N
 s/<artifactId>\([^<]*\)<\/artifactId>[\n\r]*[^<]*/:\1/
}

s/<version>\([^<]*\)<\/version>.*/:\1<\/maven-dependency>/

' $file > work.txt

echo -e "\n${cfile}\n===========================================" > work2.txt

cat work.txt | grep "<maven-dependency>[^<]*<\/maven-dependency>" | sed "s/<maven-dependency>\([^<]*\)<\/maven-dependency>/\1/" >> work2.txt; cat work2.txt

cat work2.txt >> results.txt

done

Along the same lines, there is also a little Ruby script for extracting out the articleId from the groupId:articleId:version:

#[Extract dependency name (Ruby)]

#E.g., 
dependencies = %w[
edu.ucmerced.ucpath.idm:ucm-ucpath-idm:0.0.2-SNAPSHOT
it.svario.xpathapi:xpathapi-jaxp:RELEASE
org.eclipse.m2e:lifecycle-mapping:1.0.0
org.apache.maven.plugins:maven-install-plugin:2.4
com.google.code.maven-replacer-plugin:replacer:1.5.2
org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2
org.apache.maven.plugins:maven-install-plugin:2.4
com.google.code.maven-replacer-plugin:replacer:1.5.2
]

puts dependencies.map{|x| first = x.index(/:/); x.slice(first+1, x.index(/:/, first+1) - first-1)}

How to reference a variable within sed? - The UNIX and Linux Forums

http://www.unix.com/shell-programming-scripting/39175-how-reference-variable-within-sed.html
tmp="abcdefg"
sed "s/${tmp}/good"

Replace the single quotes with double quotes. Single quotes prevent variable expansion.

http://www.unix.com/shell-programming-scripting/39175-how-reference-variable-within-sed.html

escape string in bash script so it can be used in command line

http://www.linuxquestions.org/questions/linux-software-2/escape-string-in-bash-script-so-it-can-be-used-in-command-line-360664/

Use double quotes.

You don't need to escape a string if you quote it - say you want to pass all the arguments to ls, instead of

ls $*

write

ls "$*"

Java; web services

Web Service Definition Language (WSDL)

http://www.w3.org/TR/wsdl#_soap:address

What purpose does soap:address serve? It appears to be the actual endpoint.

<definitions .... >
    <port .... >
        <binding .... >
           <soap:address location="uri"/> 
        </binding>
    </port>
</definitions>
? Apache CXF -- WS-SecurityPolicy http://cxf.apache.org/docs/ws-securitypolicy.html

Configuration for message-level encryption can be easily accomplished. The following server and client configurations should be loaded either in the Server/Client Java class or in the pom.xml configuration

Java Class

  SpringBusFactory bf = new SpringBusFactory();
  URL busFile = new ClassPathResource("wssec-server.xml").getURL();
  Bus bus = bf.createBus(busFile.toString());
  BusFactory.setDefaultBus(bus);

pom.xml

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <executions>
        <execution>
            <phase>test</phase>
            <goals>
                <goal>java</goal>
            </goals>
            <configuration>
                <mainClass>edu.ucmerced.ucpath.idm.Runner</mainClass>
                <arguments>
                    <argument>../ws-ora-idm-wsdl/src/main/resources/wsdl/IDMServices/IDMServices.wsdl</argument>
                </arguments>
                <systemProperties>
                  <systemProperty>
                    <key>cxf.config.file</key>
                    <value>cxf-client.xml</value>     
                  </systemProperty>
                </systemProperties>
            </configuration>
        </execution>
    </executions>
</plugin>

Server

    <jaxws:endpoint id="server"
      implementor="demo.wssec.server.GreeterImpl"
      endpointName="s:SoapPort"
      serviceName="s:SOAPService"
      address="http://localhost:9001/SoapContext/SoapPort"
      wsdlLocation="wsdl/hello_world.wsdl"
      xmlns:s="http://apache.org/hello_world_soap_http">
        
      <jaxws:properties>
         <entry key="ws-security.signature.properties" value="serviceKeystore.properties"/>
         <entry key="ws-security.signature.username" value="myservicekey"/>

         <entry key="ws-security.callback-handler" 
                value="demo.wssec.server.ServerCallbackHandler"/>

         <entry key="ws-security.encryption.properties" value="serviceKeystore.properties"/>
         <entry key="ws-security.encryption.username" value="myclientkey"/>
      </jaxws:properties> 
    </jaxws:endpoint>

Client

    <jaxws:client name="{http://apache.org/hello_world_soap_http}SoapPort" createdFromAPI="true">
       <jaxws:properties>
           <entry key="ws-security.signature.properties" value="clientKeystore.properties"/>
           <entry key="ws-security.signature.username" value="myclientkey"/>
           <entry key="ws-security.callback-handler" 
                  value="demo.wssec.client.ClientCallbackHandler"/>
           <entry key="ws-security.encryption.properties" value="clientKeystore.properties"/> 
           <entry key="ws-security.encryption.username" value="myservicekey"/>
       </jaxws:properties>
   </jaxws:client>

Propery files should include location of certificates and keystore password. The private key password cannot be provided here, but should use the callback to provide the correct private key.

Properties

org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
org.apache.ws.security.crypto.merlin.keystore.type=jks
org.apache.ws.security.crypto.merlin.keystore.password=sspass
org.apache.ws.security.crypto.merlin.keystore.alias=myservicekey
org.apache.ws.security.crypto.merlin.keystore.file=keys/servicestore.jks

Java callback-handler

public void handle(Callback[] callbacks) throws IOException,
        UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof WSPasswordCallback) {
            WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
            if ("myservicekey".equals(pc.getIdentifier())) {
                pc.setPassword("skpass");
                break;
            }
        }
    }
}

See https://github.com/dcvezzani/mustached-batman for a complete example.

Maven Repository: org.apache.ws.security » wss4j

» 1.5.6 http://mvnrepository.com/artifact/org.apache.ws.security/wss4j/1.5.6

Pom.xml dependency entry.

<dependency>
 <groupId>org.apache.ws.security</groupId>
 <artifactId>wss4j</artifactId>
 <version>1.5.6</version>
</dependency>

WS-SecurityPolicy 1.2

http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/ws-securitypolicy-1.2-spec-os.html

Documentation of the nodes in the WS-SecuirtyPolicy namespace.

XML Namespace Document for WS-Security-Policy 1.3

http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200802

Documentation of the nodes in the WS-SecuirtyPolicy namespace.

Re: Eclipse, CXF and WS-SecurityPolicy

http://mail-archives.apache.org/mod_mbox/cxf-users/201307.mbox/%3CF172D30F-6747-44B2-A4CE-7EFBD7710DEA@indivica.com%3E

An error like what follows indicates that possibly the wrong namespace is being specified or the namespace is missing altogether.

> Jul 27, 2013 12:41:56 AM org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl handleNoRegisteredBuilder
> WARNING: No assertion builder for type {http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}RequiredParts registered.

Maven Repository: org.apache.cxf » cxf-rt-ws-security

» 2.4.1 http://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-ws-security/2.4.1

Entry description

<dependency>
 <groupId>org.apache.cxf</groupId>
 <artifactId>cxf-rt-ws-security</artifactId>
 <version>2.4.1</version>
</dependency>

Java web services: WS-Security with CXF

http://www.ibm.com/developerworks/library/j-jws13/

Walk-through for creating a web service, using WS-Security with the Apache CXF web services stack

X.509 Certificates

X.509 - Wikipedia, the free encyclopedia

http://en.wikipedia.org/wiki/X.509

Was researching what exactly the significance is of signed certificates.

As far as I can tell, most of the time it's only purpose is to validate a trusted public key.

The Most Common Java Keytool Keystore Commands

http://www.sslshopper.com/article-most-common-java-keytool-keystore-commands.html

A great resource common keytool commands.

Tuesday, September 24, 2013

weblog; hello, raspberry pi

Rails

ruby on rails - Routing to static html page in /public - Stack Overflow

http://stackoverflow.com/questions/5631145/routing-to-static-html-page-in-public

Tried to host wsdl and xsd resources. This seemed to be more trouble than it was worth, so I turned to Rack to get the job done. That being said, I decided it would be more consistent to simple grab resources relatively from the file system.

Rails Routing from the Outside In — Ruby on Rails Guides

http://guides.rubyonrails.org/routing.html

I was trying to figure out how to redirect to a static page. This didn't end up helping. Ended up using Rack instead.

get '/stories', to: redirect('/posts')

get '/stories/:name', to: redirect('/posts/%{name}')

get '/stories/:name', to: redirect {|params, req| "/posts/#{params[:name].pluralize}" }

get '/stories', to: redirect {|p, req| "/posts/#{req.subdomain}" }

Layouts and Rendering in Rails — Ruby on Rails Guides

http://guides.rubyonrails.org/layouts_and_rendering.html

Tried to render xml and xsd files. Again, I ended up using Rack instead.

render xml: @product

render file: filename, content_type: "application/rss"

How can I get a rails route to keep the extension as part of the id? - Stack Overflow

http://stackoverflow.com/questions/3409395/how-can-i-get-a-rails-route-to-keep-the-extension-as-part-of-the-id
  • http://stackoverflow.com/questions/948886/rails-restful-resources-using-to-param-for-a-field-that-contains-separator-chara
  • http://poocs.net/2007/11/14/special-characters-and-nested-routes

At first, I was having success with rendering the wsdl, but the xsd files have periods throughout the file name. I wanted to be able to ignore the periods, but Rails thought what followed the period was the file extension.

map.resources :websites, :requirements => { :id => /[a-zA-Z0-9\-\.]+/ } do |websites|
    websites.with_options :requirements => { :website_id => /[a-zA-Z0-9\-\.]+/ }  do |websites_requirements|
        websites_requirements.resources :dns_records
    end
end

map.resources :users,
  :requirements => { :id => %r([^/;,?]+) }

For Rails3 use :constraints instead of :requirements

http://stackoverflow.com/questions/3409395/how-can-i-get-a-rails-route-to-keep-the-extension-as-part-of-the-id

Ruby on Rack #1 - Hello Rack! - (m.onkey.org)

http://m.onkey.org/ruby-on-rack-1-hello-rack

Lovely, little lightweight web server. I ended up using this instead of Rails to host wsdl and xsd resources.

require 'rubygems'
require 'rack'

class HelloWorld
  def call(env)
    [200, {"Content-Type" => "text/html"}, "Hello Rack!"]
  end
end

Rack::Handler::Mongrel.run HelloWorld.new, :Port => 9292

Maven

jax ws - Use CXF JaxWsServerFactoryBean exception Cannot find any registered HttpDestinationFactory from the Bus - Stack Overflow

http://stackoverflow.com/questions/13617691/use-cxf-jaxwsserverfactorybean-exception-cannot-find-any-registered-httpdestinat
Caused by: java.io.IOException: Cannot find any registered HttpDestinationFactory from the Bus.
        at org.apache.cxf.transport.http.HTTPTransportFactory.getDestination(HTTPTransportFactory.java:295)
        at org.apache.cxf.binding.soap.SoapTransportFactory.getDestination(SoapTransportFactory.java:143)
        at org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:93)
        at org.apache.cxf.endpoint.ServerImpl.<init>(ServerImpl.java:72)
        at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:160)

If this error is logged, check and make sure the Jetty library is in the classpath.

 <dependencies>

    ...

    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-transports-http-jetty</artifactId>
      <version>2.7.6</version>
    </dependency>
 </dependencies>

SLF4J Error Codes

http://www.slf4j.org/codes.html#StaticLoggerBinder

Apparently, there are way too many logging libraries. Unfortunately, some libraries package in their own perferred logging library. This poses some challenges when there are conflicts. I had to disable a javadoc generator plugin because it bundled a logging library that was compatible with another logging library in a different JAR resource.

Do your best to exclude those libraries causing conflicts.

Check the dependency tree and add excludes.
mvn dependency:tree -Dincludes=velocity:velocity
Next, exclude inner dependencies. And then if you have to, remove libraries that bundle too much for their own good.
<dependencies>

  ..

  <dependency>
    <groupId>org.apache.maven.plugin-tools</groupId>
    <artifactId>maven-plugin-tools-api</artifactId>
    <version>2.5.1</version>

    <exclusions>
      <exclusion>
        <groupId>jetty</groupId>
        <artifactId>jetty</artifactId>
      </exclusion>
    </exclusions>

  </dependency>
</dependencies>

Maven Repository: ch.qos.logback » logback-classic

» 1.0.13 http://mvnrepository.com/artifact/ch.qos.logback/logback-classic/1.0.13

Dependency entry for logback logging library. There are so many logging libraries out there; this one seems to have a greater level of popularity.


 ch.qos.logback
 logback-classic
 1.0.13

Logback should be used in conjunction with SLF4J.

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.util.StatusPrinter;

public class HelloWorld2 {

  public static void main(String[] args) {
    Logger logger = LoggerFactory.getLogger("chapters.introduction.HelloWorld2");
    logger.debug("Hello world.");

    // print internal state
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    StatusPrinter.print(lc);
  }
}

Logback is intended as a successor to the popular log4j project. [It] is faster and has a smaller footprint than all existing logging systems...

http://mvnrepository.com/artifact/ch.qos.logback/logback-classic/1.0.13

Maven - Introduction to the Build Lifecycle

http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

Without understanding the Maven lifecycle, you will be navigating the waters of Maven blindly.

java - Different dependencies for different build profiles in maven - Stack Overflow

http://stackoverflow.com/questions/166895/different-dependencies-for-different-build-profiles-in-maven

Each profile block supports the tag

<profiles>
    <profile>
     <id>debug</id>
     …
     <dependencies>
      <dependency>…</dependency>
     </dependencies>
     …
    </profile>
    <profile>
     <id>release</id>
     …
     <dependencies>
      <dependency>…</dependency>
     </dependencies>
     …
    </profile>
</profiles>

Maven Repository: org.apache.cxf » cxf-rt-transports-http-jetty

» 2.7.6 http://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-transports-http-jetty/2.7.6

Dependency entry for the Jetty web server library.

<dependency>
 <groupId>org.apache.cxf</groupId>
 <artifactId>cxf-rt-transports-http-jetty</artifactId>
 <version>2.7.6</version>
</dependency>

Maven Dependency plugin - Filtering the dependency tree

http://maven.apache.org/plugins/maven-dependency-plugin/examples/filtering-the-dependency-tree.html
  • http://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html

When there are problems with dependencies, this is a vital tool to get some insight and resolve the problem. Sometimes those issues can be resolved by including an <excludes> block. Other times dependencies need to be moved around, either in a different order in a given pom.xml or moved into a different pom.xml altogether.

Maven Repository: org.apache.maven.plugins » maven-javadoc-plugin » 2.9.1

http://mvnrepository.com/artifact/org.apache.maven.plugins/maven-javadoc-plugin/2.9.1
  • https://bitbucket.org/atlassian/maven-javadoc-plugin
  • http://stackoverflow.com/questions/tagged/maven-javadoc-plugin

Got to get my Javadocs up to par...

<dependency>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-javadoc-plugin</artifactId>
 <version>2.9.1</version>
</dependency>

Versions Maven Plugin - Checking for new plugin updates

http://mojo.codehaus.org/versions-maven-plugin/examples/display-plugin-updates.html

The display-plugin-updates goal will check all the plugins and reports used in your project and display a list of those plugins with newer versions available.

mvn versions:display-plugin-updates

CXF

Developing Web services using Apache CXF and Maven

http://www.ctrl-alt-dev.nl/Articles/CXF-Maven/CXF-Maven.html

Step-by-step instructions on how to develop a web service using CXF and Maven. Starts off by creating a web service without CXF, adds tests and then replaces non-test code with code generated by CXF. Should be a worth while walkthrough.

Java

How to get the filepath of a file in Java

http://www.mkyong.com/java/how-to-get-the-filepath-of-a-file-in-java/

Get the full path for a given file. Needed this for my Rails to static page html converter.

File file = File("C:\\abcfolder\\textfile.txt");
System.out.println("Path : " + file.getAbsolutePath());

Frequently Asked Questions about SLF4J

http://slf4j.org/faq.html

I need to get to know the SLF4J logging library a little better since it appears Log4j is ancient now.

Hibernate Annotations

http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html_single/

Authoritative reference on Hibernate annotations. With this, we don't have to juggle hundreds of Hibernate configuration files. The Hibernate configuration is combined with the java code that defines the DAOs.

CSS text-decoration property

http://www.w3schools.com/cssref/pr_text_text-decoration.asp

Needed a reminder on how to implement strike-through

h2 {text-decoration:line-through}

UCPath

UCPath:System Design:Interface FDDs

https://sp2010.ucop.edu/sites/ucpath/System%20Design/Forms/AllItems.aspx?Paged=TRUE&p_SortBehavior=0&p_FileLeafRef=DS%20140%20Functional%20Design%20I%2d601%20CONEXIS%20DirectBill%20OB%2edocx&p_ID=148&RootFolder=%2fsites%2fucpath%2fSystem%20Design%2fInterface%20FDDs&PageFirstRow=91&TreeField=Folders&TreeValue=Interface%20FDDs&ProcessQStringToCAML=1&&View={B1F1C4C1-3FDB-400F-9D41-942503D1AF92}

Functional design documents.

Raspberry Pi

CoolGear® USB 3.0 to SATA and IDE Hard Drive Adapter Universal 2.5/3.5/5.25 Drives

open http://www.amazon.com/gp/product/B009VKSNS6/ref=oh_details_o04_s00_i00?ie=UTF8&psc=1 http://www.amazon.com/gp/product/B009VKSNS6/ref=oh_details_o04_s00_i00?ie=UTF8&psc=1
  • http://www.amazon.com/SATA-Drive-Adapter-Universal-Drives/dp/B004FEQ8MG

Device that can be used to rescue data from an external or internal hard drive due to an interface gone bad. This saved many, many of my wife's photos. They were not corrupt; the hard drive simply wouldn't mount due to a faulty interface.

Check out this video for instructions on how to use the device to rescue your files.

Apache CXF -- JAX-WS Configuration

http://cxf.apache.org/docs/jax-ws-configuration.html

Configuring an Endpoint. This Spring configuration handles setting up the webservice so we don't have to write the Java code. Thank you, Apache CXF.

<jaxws:endpoint id="classImpl"
    implementor="org.apache.cxf.jaxws.service.Hello"
    endpointName="e:HelloEndpointCustomized"
    serviceName="s:HelloServiceCustomized"
    address="http://localhost:8080/test"
    xmlns:e="http://service.jaxws.cxf.apache.org/endpoint"
    xmlns:s="http://service.jaxws.cxf.apache.org/service"/>

The Only Raspberry Pi XBMC Tutorial You Will Ever Need

http://mymediaexperience.com/raspberry-pi-xbmc-with-raspbmc/

If I get around to building a home network, this is how I will cut my teeth on a Raspberry Pi.

Raspberry Pi

NETGEAR G54/N150 WiFi USB Micro Adapter WNA1000M | Staples®

http://www.staples.com/NETGEAR-G54-N150-WiFi-USB-Micro-Adapter-WNA1000M/product_927666?cid=PS:GooglePLAs:927666&KPID=927666
  • http://www.superbiiz.com/detail.php?p=IMTW311M&c=fr&pid=36a601e944c3b844313893c45c178493ad8db092420bcb54ace3c24f8cdbcf68&gclid=CNvytr7M3LkCFeV7QgodPUwA1w
  • http://www.monoprice.com/products/product.asp?seq=1&format=2&p_id=6146&CAWELAID=1329452226&catargetid=320013720000011065&cadevice=c&cagpspn=pla&gclid=CPSX6K7M3LkCFUSCQgodvmEABw
  • http://www.amazon.com/USB-Wireless-Lan-Adapter-150Mbps/dp/B002XGDU9M

Use this (or something like unto it) to provide wifi for a Raspberry Pi.

Language

Google Translate

http://translate.google.com/#pt/en/celebrar

When I need a little help with my Spanish or Portuguese.

Google Translate

Thursday, September 12, 2013

weblog; saving my neck with git-reflog and namespace conflicts

Bash

bash - how to represent multiple conditions in shell script? - Stack Overflow

http://stackoverflow.com/questions/3826425/how-to-represent-multiple-conditions-in-shell-script
if [[ ( $g == 1 && $c == 123 ) || ( $g == 2 && $c == 456 ) ]]

Only process the file entries with 'webapp-idm' and 'webapp' in their name.

if [[ ( $cp =~ "webapp-idm" ) || ( $cp =~ "webapp" ) ]]
then
echo "processing $cp"
fi

bash - how to loop list of file names returned by find - Stack Overflow

http://stackoverflow.com/questions/9612090/how-to-loop-list-of-file-names-returned-by-find
for i in $(find -name \*.iso); do
    process "$i"
done

Loop for all .classpath files found recursively from the current directory.

for cp in $(find . -name ".classpath")
do
echo $cp
done

Other Comparison Operators

http://tldp.org/LDP/abs/html/comparison-ops.html
-eq

    is equal to

    if [ "$a" -eq "$b" ]

regex - use regular expression in if-condition in bash - Stack Overflow

http://stackoverflow.com/questions/2348379/use-regular-expression-in-if-condition-in-bash
$ for file in *; do [[ $file =~ "..g" ]] && echo $file ; done
abg
degree
..g

Java

XmlType (Java EE 5 SDK)

http://docs.oracle.com/javaee/5/api/javax/xml/bind/annotation/XmlType.html#name%28%29

When processing WSDLs and XSDs to generate Java code, node name clashes could be a problem.

Git

git ready » reflog, your safety net

http://gitready.com/intermediate/2009/02/09/reflog-your-safety-net.html http://stackoverflow.com/questions/4786972/list-of-all-git-commits
git reflog

Pack up / clean up your repository (beware!)

# git reflog expire --expire=1.minute refs/heads/master
# git fsck --unreachable      
# git prune                   
# git gc                      

...you can use it as a safety net: you shouldn’t be worried that a merge, rebase, or some other action will destroy your work since you can find it again using this command.

http://gitready.com/intermediate/2009/02/09/reflog-your-safety-net.html

Tuesday, September 10, 2013

weblog; java, html, vim

Vim

How to select between brackets (or quotes or …) in vim?

http://stackoverflow.com/questions/1061933/how-to-select-between-brackets-or-quotes-or-in-vim/1062001#1062001 http://vimdoc.sourceforge.net/htmldoc/motion.html#object-select

To select between the single quotes I usually do a vi' (select inner single quotes).

Inside a parenthesis block, I use vib (select inner block)

Inside a curly braces block you can use viB (capital B)

To make the selections "inclusive" (select also the quotes, parenthesis or braces) you can use a instead of i.

You can read more about the Text object selections on the manual.

http://stackoverflow.com/questions/1061933/how-to-select-between-brackets-or-quotes-or-in-vim/1062001#1062001

Java

JAXBElement Response from WebServices

https://www.java.net//node/694561
Method m = item.getClass().getMethod("getFirstName");
JAXBElement firstName = (JAXBElement)m.invoke(item);
System.out.println(firstName.getValue());

m = item.getClass().getMethod("getLastName");
JAXBElement lastName = (JAXBElement)m.invoke(item);
System.out.println(lastName.getValue());

How do I prevent JAXBElement from being generated in a CXF Web Service client?

http://stackoverflow.com/questions/4413281/how-do-i-prevent-jaxbelementstring-from-being-generated-in-a-cxf-web-service-c http://stackoverflow.com/questions/18573468/wsdl2java-cxf-generating-jaxbelement-list-instead-of-fields
<jaxb:bindings version="2.1" 
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" 
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" 
xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
   <jaxb:globalBindings generateElementProperty="false"/> 
</jaxb:bindings> 
<jaxb:globalBindings generateElementProperty="false" fixedAttributeAsConstantProperty="true" choiceContentProperty="true">

Html

Href attribute for JavaScript links: “#” or “javascript:void(0)”?

http://stackoverflow.com/questions/134845/href-attribute-for-javascript-links-or-javascriptvoid0
javascript:void(0)

Tuesday, September 3, 2013

weblog; Hibernate, PostgreSql, Maven, JRuby

Hibernate

Hibernate opening/closing session, the correct approach for DAO

http://stackoverflow.com/questions/8841207/hibernate-opening-closing-session-the-correct-approach-for-dao

Experiencing problems with session, I think. After deleting records from the database, should the session be closed and opened again to stop getting exceptions?

Hibernate Error: a different object with the same identifier value was already associated with the session

http://stackoverflow.com/questions/16246675/hibernate-error-a-different-object-with-the-same-identifier-value-was-already-a

It seems this is where I'm having my current code hangup. Should I be closing the session between deletes and inserts? Or is there something being updated instead and that's throwing exceptions because I'm inadvertently attempting to update a record that has been destroyed in the same session?

PostgreSql

PostgreSQL: Get the second to last MAX(date)

http://stackoverflow.com/questions/16567632/postgresql-get-the-second-to-last-maxdate

Maven

Maven: Filtering the dependency tree

http://maven.apache.org/plugins/maven-dependency-plugin/examples/filtering-the-dependency-tree.html http://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html
mvn dependency:tree -Dincludes=velocity:velocity
mvn dependency:tree -Dverbose -Dincludes=commons-collections

I used this to resolve issues I was experiencing with log jars. I was including a version of one collection of jars. Another resource was pulling them in too, only a different version. This was raising some warnings anytime I ran maven. I used a call like this one to figure our where my conflicts existed.

JRuby

JRuby and Java Code Examples

https://github.com/jruby/jruby/wiki/JRubyAndJavaCodeExamples

How to call Ruby from Java code and Java from Ruby code.

JRuby limited openssl loaded - how to eliminate?

http://stackoverflow.com/questions/9017412/jruby-limited-openssl-loaded-how-to-eliminate

Moving an Existing Rails App to run on JRuby: Install JRuby locally

https://devcenter.heroku.com/articles/moving-an-existing-rails-app-to-run-on-jruby#specify-jruby-in-your-gemfile

Best way of invoking getter by reflection

http://stackoverflow.com/questions/2638590/best-way-of-invoking-getter-by-reflection

While trying to come up with my own testing utility for stubbing/mocking, I found this. Could be a good read, but I reverted back to JMockit.

Maven: Filtering the dependency tree http://maven.apache.org/plugins/maven-dependency-plugin/examples/filtering-the-dependency-tree.html

Call JRuby, Jython or other JVM scripting language from Maven

http://matschaffer.com/2009/10/call-jruby-jython-from-maven/
  <executions>
    <execution>
      <id>my_script</id>
      <phase>compile</phase>
      <configuration>
        <tasks>
          <java classname="org.jruby.Main" failonerror="yes">
            <arg value="${basedir}/src/main/ruby/myscript.rb" />
          </java>
        </tasks>
      </configuration>
    </execution>
  </executions>

Guide to installing 3rd party JARs

http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
    -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

Using JRuby with Maven

https://github.com/jruby/jruby/wiki/Using-JRuby-with-Maven
    <dependency>
      <groupId>org.jruby</groupId>
      <artifactId>jruby-core</artifactId>
      <version>1.7.0.RC1</version>
    </dependency>