I am new to Java EE. I use Maven, Eclipse and jBoss/WildFly.
I have a war project. When I build the project all its dependencies are packaged inside the war file in WEB-INF/lib.
Now I am trying to create a ejb project (I have <packaging>ejb</packaging> in the pom.xml). I want to deploy it as a separate project (not as a part of the war). When I build the ejb project Maven does not package any dependencies in the jar.
How can I package/deploy a ejb .jar with its dependencies?
UPDATE: I'd like to avoid packaging EJBs in an .ear if it is possible. (I do not want to create one more Maven project).
The best solution is package your project as ear. But if don't want use ear, maven assembly plugin can help you to package all needed jars in one file. This solution is only for "proof of concept" variant, and cannot be used in production mode, by licences limitation for example.
Related
I am buliding small Spring Boot app - pacakged as jar file (I'm using maven plugins).
I know that there are solutions which allow me to build jar file with all desired dependecies (e.g. maven assembly plugin).
The question is what if I don't pack maven required depedencies using those solutions? Am I correct that I will always get "NoClassDefFoundError" ? So should I always pack my project with all depedencies into jar file or there is another solution to "makes thigns work"?
we have a maven multi-module pom project with a core-module where i want to keep common application.properties, like database-access, email-gateways etc. Is it possible to integrate those application*.properties in the executable jar of the other modules as well (jars built by spring-boot-maven-plugin)?
when taking a look into the built jar, you can see that only the module's resources are integrated, all other modules are ignored.
Thanks
I have a largish project that needs to be usable either with a command-line interface or through a web-app. The core server is deployed as 10 separate jars. The web-app is currently deployed as a .war, but that is a huge file that duplicates all the individual deployments and makes updating a module a big pain - you have to re-deploy this huge .war file every time you update anything, and much of the time we don't use the web-app.
So I am trying to deploy a "skinny war", without the dependencies. However, there's no .ear file to carry them, so at runtime, I unpack the skinny war and use jetty:run, with the classesDirectory and webAppSourceDirectory pointing into the unpacked content. That all seems to work. The problem is that the dependencies from the web-app module do not make it into the classpath for jetty:run. When I use jetty:run in the web-app module, the classpath includes all parent, local, and transitive dependencies. But when I use jetty:run in the "distribution" project that depends on the web-app module, the only dependencies that get into the classpath are from the parent module, not from the web-app module. Note that the web-app module is the only local dependency in the distribution module.
What am I missing?
If I'm understanding you correctly, your problem is that Maven doesn't resolve transitive dependencies for war dependencies.
I have a Ear, war and 2 jar projects in my eclipse.
I want to automatically build 2 jars, war and ear project, when i run the pom inside ear project.
I remember doing this in maven in the past. But i forgot since i lost touch working with Maven for few years now.
Someone please remind me of that..
I used dependency compile, but it is not building jar, when i build the ear directly.
Should i first run pom in jar? does it not build that jar automatically when i build ear?
Create a multi module build that will build it all for you in the reactor. Read more about it e.g. http://www.sonatype.com/books/mvnref-book/reference/pom-relationships-sect-pom-best-practice.html#pom-relationships-sect-multi-vs-inherit
I guess you should define tha .jar and .war projects as dependencies of your .ear project. It is also advisable to have a parent pom, where all the projects are defined as modules, including the .ear project.
In this book you can find a well explained step-by-step setup of a maven multimodule project (with downloadable code).
There is also a great working example of an enterprise multimodule project in the JBoss quickstart examples.
I would like to take advantage of the features that Maven provides for managing dependencies in a project. My brief understanding of how Maven works is that it will aquire the JARs needed and then build the project with these libraries. So i have installed and configured maven on my computer. Also i have installed the me2eclipse plugin version 0.12 on my eclipse helios.
I have been created a maven project and configured the pom. I added some dependencies to maven and maven was checking out the dependend jars to %userprofile%/.me2/repository. This works fine. But i would like to import some packages from the jar files which are located at the maven dependencies at my plugin.xml which are used by running a eclipse rcp plugin. The maven dependencies are added to my classpath as well.
I don't know were the mistake is? Can any body help my. Thanks.
The answer is, thats not possible to import some packages from jars or bundles which are loaded as maven dependency (stored at the maven local repositiry) at the eclipse rcp plugin dependency or MANIFEST. You can only import bundles or packages from jars which are located at the eclipse target platform. So the solution is to add the bundles which ar located at the local maven repository to the target platform as well.
You should take a deep look at Maven-Felix which supports you in this kind of building. Furthermore i recommend you to update to Eclipse-Indigo and use the integrated (Marketplace) m2e instead of the old m2eclipse plugin.