简体   繁体   中英

Maven dependency for javax.ejb.jar into .m2 directory

I cant find javax.ejb.jar in my .m2 dirctory, I need this jar for import javax.ejb.Schedule; , here is my pom file entry.

<dependency>
            <groupId>javax.ejb</groupId>
            <artifactId>ejb-api</artifactId>
            <version>3.0</version>
            <scope>provided</scope>
        </dependency>

I am not sure if it will work or not, or its a right way to do things. Can some one please help to make a change in the POM file so that it downloads javax.ejb.jar into the .m2 directory.

Updated

  1. by .m2 I mean in the repository directory in the correct folder hierarchy (What ever it is).
  2. Why? We have multiple sub projects (In eclipse workspace), In order to resolve dependency we use M2_REPO /path/to/the/required_library_file.jar, Now theses projects are part of code bases, Every developer download the source code, Maven download all jar to the repository directory(of the developer using any OS/Platform). This relative path from M2_REPO helps developer to have consitenat code (for eclipse project). Otherwise everyone will be adding their own path.

If it still doesn't make sense, here is what I want, Please give me an entry for POM file which download the javax.ejb.jar file into .m2 directory what ever the sub path is.

I have to include this jar in every project manually (And every developer needs to them as well from what ever directory have glassfish (C: , D:, E:, or /home/glassfish/modules/)

D:\servers\glassfish-3.1.2\glassfish3\glassfish\modules\javax.ejb.jar

where rest of the jars in each project are included as M2_REPO/path/to/jar which makes less no changes in the code base to commit.

M2_REPO/javax/ejb/ejb-api/3.0/ejb-api-3.0.jar
M2_REPO/javax/enterprise/cdi-api/1.0-SP1/cdi-api-1.0-SP1.jar
M2_REPO/javax/inject/javax.inject/1/javax.inject-1.jar

etc etc

I think I hear what you mean now :)

The maven dependency you specify

<dependency>
  <groupId>javax.ejb</groupId>
  <artifactId>ejb-api</artifactId>
  <version>3.0</version>
  <scope>provided</scope>
</dependency>

which you have in .m2/repository/javax/ueb/ejb-api/3.0/ejb-api-3.0.jar does not contain the class/interface javax.ejb.Schedule .

But you found the jar-file in your glassfish server, which does contain javax.ejb.Schedule and its name is D:\\servers\\glassfish-3.1.2\\glassfish3\\glassfish\\modules\\javax.ejb.jar and now you ask how to get that into the pom?

Well, the Java EE APIs and their official jars in maven are somewhat a study in disharmony. If you run a search on maven central you will find multiple jars containing exactly that class. You will probably note that all appserver vendors provide their own edition of every aspect of every api in every version.

You should be able to find a jar with the javax.ejb module from glassfish in version 3.1.2

http://search.maven.org/#artifactdetails|org.glassfish|javax.ejb|3.1.2|jar

in which case the dependency would be

<dependency>
  <groupId>org.glassfish</groupId>
  <artifactId>javax.ejb</artifactId>
  <version>3.1.2</version>
  <scope>provided</scope>
</dependency>

I found another artifactId here , though maven has your version too. A (very) weird maven caching problem? Then it might work tomorrow.

<dependency>
    <groupId>javax.ejb</groupId>
    <artifactId>javax.ejb-api</artifactId>
    <version>3.2</version>
</dependency>

Though this is a new version, for compilation it should do.

您可能需要在 pom.xml 文件或 .m2/settings.xml 文件中提供存储库位置,以便将所需的 jar 下载到 .m2 目录中。

The dependency is declared as provided what means that the container will provide it.

What container are you using? I think Tomcat/Jetty won't provide that jar as it seems so Java EE. In that case just change the scope to compile .

<dependency>
  <groupId>javax.ejb</groupId>
  <artifactId>ejb-api</artifactId>
  <version>3.0</version>
  <scope>compile</scope>
</dependency>

More info about dependency scopes: http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM