I'm using JBoss EAP 6.0.1 (NOT JBoss AS 7.1.1 or 7.1.3!) and I'm just starting with a Maven project.
In normal Eclipse projects I set the target runtime of my project to the JBoss EAP server runtime and then all its libraries are available to my project. Available here means I can use e.g. ctrl-t to find a class in any of those libraries, and when I attach the source I can step into them when debugging.
How would I do this using Maven (m2e)?
I've found the Maven repository for JBoss EAP 6.0.1 at http://maven.repository.redhat.com/techpreview/eap6/6.0.1/
Do I need to add some root dependency (representing JBoss EAP itself) to my project, and if so, what would this dependency be?
I found a very similar question here: Adding JBoss AS 7 modules on Eclipse using Maven or JBoss Tools
But the accepted answer only says: "Take a look at these links", which doesn't tell me how to exactly do this (and it's for AS 7.1.1 not for EAP 6.0.1).
UPDATE
I wasn't entirely clear about the question. I'm not looking for a mere reference to the Java EE APIs. I know how to do that, as it's simply:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>1.6</version>
<scope>provided</scope>
</dependency>
I'm also NOT looking for any vendor versions of that spec jar. I'm absolutely NOT looking for the following one either:
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
</dependency>
What I'm looking for is having all implementation libs available in the project. The JBoss AS 6 server runtime does this by default, and with the JBoss AS 7/EAP 6 server runtime you can do this by going to Server -> Runtime Environments -> Default Classpath (you can enter individual paths there, or just add the /modules rootpath to have everything at one)
I'm looking for the equivalent of this in a Maven project.
I'M NOT LOOKING FOR SPEC JARS!!!!
As I need to step through the ACTUAL IMPLEMENTATION jars of the target server, I REALLY need the ACTUAL IMPLEMENTATION jars. I KNOW I can't deploy these, and nor do I intend to deploy them. They need to be present in my IDE, so there's source code that matches what's in the target JVM and I can use CTRL-SHIFT-T to lookup IMPLEMENTATION classes and CTRL-CLICK to navigate into them, analyse call hierarchies, etc.
AGAIN: I'M NOT LOOKING FOR SPEC JARS!!!!
You can import the dependencies manually into your repository. I did it into ours (artifactory) and it's working.
See: https://access.redhat.com/site/documentation/en-US/JBoss_Enterprise_Application_Platform/6/html/Development_Guide/Install_the_JBoss_Enterprise_Application_Platform_6_Maven_Repository_Locally.html
I found a surprisingly simple solution my self: even though libs are managed via Maven, and a target runtime is disabled by default, you can still explicitly select a target runtime.
The libraries this target runtime puts on the classpath will now also be put on the classpath for the Maven project, in addition to those Maven already puts there. You can (manually) attach the source code to those libraries.
Once you're doing with debugging and stepping through the internals of your AS, you can simply remove the target runtime again.
An answer that tells how to do this purely via Maven and for JBoss EAP 6.0.1 (not JBoss AS 7.1.1 or 7.1.3) would still be welcome, so I won't accept my own answer ;)
There is a nice explanation of the JBoss Maven repositories at: https://community.jboss.org/wiki/MavenRepository
I would guess the repository you need to use is: https://repository.jboss.org/nexus/content/groups/public-jboss/
it should contain all JBoss artifacts you're looking for.
Maybee the groupId/artifactId is not correct. There is a search feature for the repositories at: https://repository.jboss.org/nexus/index.html#welcome
I would recommend to not include the impl jars as you cannot deploy them anyway. So the spec jars should be ok:
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
</dependency>
see: http://www.andygibson.net/blog/quickbyte/jboss-java-ee-6-spec-dependency-in-maven/
The gav for the JBoss server seem to change a lot. JBoss 7 can be found at:
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-ee</artifactId>
<version>7.1.3.Final</version>
</dependency>
Take a look here:
JBoss Enterprise Application Platform Component Details
And in my pom.xml I'm using this to get dependencies from Jboss EAP 6.0.1
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<type>pom</type>
<scope>provided</scope>
<version>3.0.2.Final</version>
</dependency>
You can use Nexus or Git or Overlord to manage project artifacts in order to create a proxy virtual dependency, if i am not mistaken.
Runtime artifacts can be used:
<!-- https://mvnrepository.com/artifact/org.jboss.bom/eap-runtime-artifacts -->
<dependency>
<groupId>org.jboss.bom</groupId>
<artifactId>eap-runtime-artifacts</artifactId>
<version>7.1.0.GA</version>
<type>pom</type>
<scope>import</scope>
</dependency>
See https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.1/html/development_guide/using_maven_with_eap#manage_project_dependencies
Related
I am picking up an old project which has a lot of old dependencies.
I am using "Eclipse IDE for Enterprise Java and Web Developers".
After importing the source to Eclipse, Eclipse is complaining all my jsp files that
The superclass "jakarta.servlet.http.HttpServlet" was not found on the Java Build Path
In pom.xml, I see there is this dependency:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
I went to google about the error and read a bit of javax vs jakarta history.
The thing is, because this is an old project that is still running on the server... can I stick with javax and not jakarta?
In Eclipse, under Project Facets, I have "Dynamic Web Module" checked and it is using Apache Tomcat v9.0 locally.
Under Server settings, I have "Tomcat v9.0 Server" at localhost for running this project.
Another thing I don't know if it has anything to do with setup of my Tomcat or project settings, which is that on pom.xml, I get an error about missing a lot of artifacts, like "jini:jsk-lib:jar", "jini:reggie:jar", "jini:start:jar", etc...
just go to mavenrepository
and serach for java servlet api
then click on the version api
then scroll down copy the dependency which looks like below
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
now past this in pom.xml in your project within dependency tag which is already present.
after this
right click on the project
and select maven
select update project
then check force update
then click ok
this will solve your error
can I stick with javax and not jakarta?
Yes, certainly you can stick with the javax. naming rather than migrating to the new jakarta. namespace. Eventually you’ll want to make the migration to benefit from new and improved technologies. But not necessary this year or next.
Read the Which version? documentation page. You will see that versions 9.0.x and 10.0.x are functionally equivalent, developed in parallel. The only significant difference is that namespace change discussed above. So use Tomcat 9 if you choose to stick with javax naming.
You’ll need to get your codebase in order, to use only the javax. naming. Apparently you have some code that refers to the new jakarta. naming. Fix that. Check your import statements. Check any use of fully-qualified class names. Use your IDE’s search tools.
By the way… If using Tomcat 9, you can change that dependency on the Servlet API from 3.0.1 to the version 4.0.3 of the Servlet specification. See that Which version? page linked above, as well as the https://Jakarta.EE site, to learn the appropriate versions of specs for JSPs, etc.
In order to run javax.servlet with JSP you need two dependencies.
First one is servlet api,
<!-- https://mvnrepository.com/artifact/javax.servlet/servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
Second one is JSP api,
<!-- https://mvnrepository.com/artifact/javax.servlet.jsp/javax.servlet.jsp-api -->
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.3</version>
<scope>provided</scope>
</dependency>
Note: javax.servlet.jsp-api also include the dependency to javax.servlet-api, so you do not need it explicitly in your project.
This means that, javax.servlet-api is mendatory for JSP to work.
I'm trying to convert a "classic" JAVA EE project, using IBM websphere 8.0.0.5, into a maven multi module project and facing issues with the IBM dependecies.
We use IBM classes from the following packages:
com.ibm.websphere.asynchbeans
com.ibm.websphere.scheduler
com.ibm.websphere.ce.cm
com.ibm.ws.asynchbeans
com.ibm.ws.util.ThreadPool
To get my local project to be compiled I downloaded the was.installer-8.0.0.pm from IBM and installed it to my maven using
mvn install -f "was.installer-8.0.0.pom" -D serverInstallationFolder="C:\Program Files (x86)\IBM\WebSphere\AppServer"
This step was successfull according to command line output.
I then added the following dependencies to my project as described from IBM:
In parent:
<dependency>
<groupId>com.ibm.tools.target</groupId>
<artifactId>was</artifactId>
<version>8.0.0</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
In module:
<dependency>
<groupId>com.ibm.tools.target</groupId>
<artifactId>was</artifactId>
</dependency>
But I still can't compile my project as the IBM packages are not found.
Can anyone help me to find and correct a mistake I made?
Edit
After following BevynQ tip from the comments I copied the "was_public.jar" to "was_public-8.0.0.jar" (described at IBM here) and added it to my repository:
mvn install:install-file -Dfile="C:\Program Files (x86)\IBM\WebSphere\AppServer\dev\was_public-8.0.0.jar" -DpomFile="C:\Program Files (x86)\IBM\WebSphere\AppServer\dev\was_public-8.0.0.pom"
I then changed the dependencies to:
<dependency>
<groupId>com.ibm.websphere.appserver</groupId>
<artifactId>was_public</artifactId>
<version>8.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.ibm.websphere.appserver</groupId>
<artifactId>was</artifactId>
</dependency>
This helped to get the compiling errors for the imports to com.ibm.websphere done.
What I now have still open is the packages com.ibm.ws.* package. Anyone have an idea?
Edit 2
I added the following dependency and then I was rid of the com.ibm.ws.* import errors.
<dependency>
<groupId>com.ibm.websphere.ws</groupId>
<artifactId>com.ibm.ws.runtime</artifactId>
<version>1.0.0</version>
</dependency>
But it still does not compile as now indirectly references can not be found (in my case commonj.work.WorkManager). It seems I need to add further .jars for every single thing. Isn't there an easier way to provide all websphere jars at once as descirbe in the above linked tutorial with the com.ibm.toolsdependency (which do not work)?
In general, com.ibm.websphere are public API for use by applications (this is true of the packages you listed above) which is consistent with these being in was_public.jar
However, com.ibm.ws package is generally product internals. May I ask what interface methods you are using from the com.ibm.ws.asynchbeans package? Maybe there is a public API alternative.
Regarding commonj.work, the only place I can find this in the WebSphere Application Server product image is WAS/plugins/com.ibm.ws.prereq.commonj-twm.jar so it looks like you will need to use that to compile against.
Here's the solution so I solved my dependency problems:
I configured the company repository manager (nexus) as a mirror. In this nexus all ibm packages are present. As you can think that solved the main problem.
I then added the following dependencies according to common maven style:
Dependencies in pom.xml (version numbers extracted to properties):
<dependency>
<groupId>com.ibm.websphere.ws</groupId>
<artifactId>com.ibm.ws.runtime</artifactId>
<version>${ibm.ws.runtime.version}</version>
</dependency>
<dependency>
<groupId>com.ibm.ws.prereq</groupId>
<artifactId>commonj-twm</artifactId>
<version>${ibm.ws.prereq.commonj-twm.version}</version>
</dependency>
Sorry I can't provide a "nice" solution that's useable by all people but the answer from njr and the comment from BevynQ helped at lot to get clearer with the problem and helped to solve the problem in a "more manual" way by copying the needed jars by hand.
I was facing this issue as I tried to build a project using Maven version 3.3.9, running on Java version 1.8.0_101, as depicted in the screenshot:
This is how I resolved it: Step 1. Download the commonj.jar from here.
Step 2. Determine which JDK your Maven is using by typing mvn -version in the command prompt.
Step 3. Go to that directory and place the commonj.jar file there in the jre/lib/ext directory, as shown below. Now your project should build in maven without any issues.
In NetBeans 8, in a Maven-based project, how does one use a jar while programming but omit from build?
I need to access some specific classes in a specific JDBC driver in my Vaadin web app. But in web apps, we normally do not bundle JDBC drivers within our build (the .war file). Instead, the JDBC drivers belong in a folder controlled by the Servlet container (the runtime environment).
So, I need the JDBC driver (a jar file) to be on the classpath while I am editing my code and compiling. But that jar file must be omitted from the build.
exclusions Tag
I tried adding the exclusions and exclusion tags to my dependency element. But this did not work – The postgresql-9.4-1201.jdbc41.jar appeared in WEB-INF/lib folder.
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4-1201-jdbc41</version>
<exclusions>
<exclusion>
<groupId>org.postgresql</groupId> Exclude from build
<artifactId>postgresql</artifactId>
</exclusion>
</exclusions>
</dependency>
New Profile?
This Answer by ZNK - M on the Question, Setting custom runtime classpath for a maven project in netbeans, may be what I need.
But creating a new project profile seems like overkill what seems like small little task to me. And, I always want to exclude this jar from my build output, not just when testing or in other limited scenarios.
You should add a new profile run-with-netbeans in your pom that declares the additional dependencies (use the provided scope to not include them in the release).
Then you'll have to add the new profile to your IDE to run the pom with the -P run-with-netbeans option in the command line.
But I am familiar only with the basics of editing a POM file. If that approach is the way to go, it would be helpful if someone could expand on the details and steps needed.
<scope>provided</scope>
Use <scope> tag in POM file, with a value of provided.
Excerpt from the Dependency Scope section of the page, Introduction to the Dependency Mechanism :
compileThis is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.
providedThis is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.
runtime[…]
test[…]
system[…]
import[…]
Like this:
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4-1201-jdbc41</version>
<scope>provided</scope>
</dependency>
Use the provided scope instead of the default compile scope for this dependency. That's exactly what it's for.
<dependency>
<scope>provided</scope>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
</dependency>
I have a Java maven project on which I'm currently working on that requires an Oracle weblogic dependency for Weblogic full client (wlfullclient.jar).
I know that there is a brand new Oracle Maven repository (that is in fact already proxied by our Nexus) but unfortunately it is not browsable.
Where can I find the right dependency information in order to insert it in my project pom in terms of GAV parameters (Group ID, Artifact, Version)?
Is this information published anywhere?
At the moment, as a temporary workaround, I got this library from the Oracle Weblogic 12c server and put in into a 3rd party hosted repository on my Nexus.
I finally managed to find a site which mirrors Oracle Maven index, so I've been able to find out the right dependencies GAV parameters I have to use in my poms.
A couple of examples:
<dependency>
<groupId>com.oracle.weblogic</groupId>
<artifactId>wlfullclient</artifactId>
<version>12.1.0.1</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.1</version>
</dependency>
Notice that this index site seems quite up-to-date since it contains artifacts pertaining to version 12.1.0.2 and some of them have been updated on September 14th.
Looks like they are not having a browser viewable list - https://community.oracle.com/thread/3650312 .
you should use repository browser provided by Netbeans. See here
https://blogs.oracle.com/WebLogicServer/entry/oracle_maven_repository_index_now
I'm fairly new to the Eclipse and Maven2 worlds. I'm struggling to comprehend how to add a Maven project dependency on Apache Jena in a simple way. Specifically, I'd like to add a dependency such as
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena</artifactId>
<version>${jena.version}</version>
</dependency>
And this would automatically pull in the modules(eg. jena-arq, jena-core, etc). However, adding this dependency results in a Missing artifact org.apache.jena:jena:jar:2.11.1 error. If I add <type>pom</type> to the dependency the error is gone but I do not get the jars in my project.
In any event, as I understand it, POM is more suited to project <--modules dependencies and what I'm really looking for is project --> lib archive dependencies.
How do I establish such a relationship? I considered simply replicating the dependency for each module in Jena since it's using a property anyway. However, it is possible, and Jena is a prime example, that not all modules in a project share the same version. For example jena-core is on 2.11.1 where jena-tdb is on 1.0.1 however jena-2.11.1 encompasses jena-tdb.
Thanks
See http://jena.apache.org/download/maven.html for details.
In brief:
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>apache-jena-libs</artifactId>
<type>pom</type>
<version>2.11.1</version> <!-- Set version -->
</dependency>
Note that it is type pom.
there is not a easy way do this.
you must define every dependency jar with special version.