In EJB 3, however, there is a real issue with JNDI naming, which was fixed in EJB 3.1. Every application server uses its own JNDI-naming scheme. It is only a problem, if you are accessing remote beans via CORBA or RMI directly. Most application servers have reasonable and consistent naming patterns - like fully qualified remote interface names, so this problem can be very easily fixed with a ServiceLocator. Its actually the only problem with the spec regarding portability. A potential danger is the "mappedBy" attribute, which is not clearly defined by the spec. In the practice most application servers map it directly to JNDI.
Dependency Injection inside the container will work as expected - you do not have to configure anything in the default case because of Convention Over Configuration...
Classloading could be an issue if you are deploying many frameworks and libraries. It could become especially funny with AOP frameworks, which often rely on classloader tricks to be able to weave the classes at load time. In my projects I tried to reduce the amount of libraries and leverage existing JDK 1.6 stuff instead. So I never ran into classloading issues except come classic ones like Log4J or SLF4J. Funny enough the last time I had this problem with a plain WAR :-). Ironically: the heaviest classloading problems ever I encountered during Eclipse RCP development trying to properly integrate Hibernate and Log4J as plugin without Buddy-Classloading hack. ...Eclipse RCP is based on OSGI :-).
The problems were easily solved in few hours (if not minutes). In some projects we deployed the same EJB-JAR into different application servers in parallel (simple ANT-copy) - and ran the unit tests against different providers...
Security is pretty good standardized as well - with JACC. But even without this standard most application servers have similar, RBAC based security concepts. They (e.g. Glassfish, JBoss) support file, database and LDAP realms out-of-the-box.
EJB 3 is a multi-vendor abstraction, so it is leaky per nature. You shouldn't expect any miracles - but the portability of EJB 3 is comparable with the portability of a WAR. JPA is a bigger problem, because there are more qualitative differences between provider and their support of database proprietary features in particular. The real portability issue in the practice are not EJBs but the non-functional differences between different application servers (scalability, performance, administration etc.).
Actually from strategic point of view, EJB 3 are really interesting for product development - you are really independent of particular infrastructure provider.... There are even several, competing opensource EJB 3 containers available...(Glassfish, JBoss, Geronimo).