문제

Can we never refer any external 3rd party jar in independent ejb module (except copying the jar file in our appserver/lib)? This seems so illogical doesn't it? I don't want to create a Enterprise application. Why am i being forced to create an Enterprise application if i have to use any jar files?

Are there no alternatives available?

도움이 되었습니까?

해결책

Well, I think I gave you a pretty good explanation in my previous answer:

EJBs don't have an equivalent of WEB-INF/lib and while packaging libraries inside an EJB-JAR might work with some application server, this is not part of the JAR specification1 and does not comply with Sun's standards regarding J2EE packaging.

I don't know what to add, if you want to write portable applications, you have to follow the rules. Whether they are due to technical limitations (see footnote), that's not the question, rules are rules.

The alternative would be to unpack the library in your EJB-JAR and that's incredibly ugly (copying your library in the application server classpath is IMO not an alternative for portable applications).

That being said, if you are using Java EE 6, you can now use a WAR instead of an EAR.

1 As explained in this thread, the jar spec does not support jar files within jar files (technically Java's URL support only goes one level deep: eg jar:url/to/file!path/ in/jar is allowed, but jar:jar:url/to/file!path/in/jar!path/in/jar is not) so while you could copy the jar files inside your ejb jar, nothing will be loaded from it.

다른 팁

You've already selected an answer, but I'll mention that "installed optional packages" might offer a solution, depending on the features available in your server.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top