Is there some kind of Design pattern which would make it possible to use the Same code base in EJB and non EJB context?

Jan Matèrne

A good suggestion would be using Delegation

class PieceOfCode {
    public Object myMethod() {}

class EJBImpl ... {
    PieceOfCode poc = new PieceOfCode();

    public Object myMethod() {
        return poc.myMethod();
This should not be a violation of EJB specs, since EJBs can use simple java classes for their use. Think about Dependant Objects and so on.