deployment single ejb module with dependencies in netbeans and glassfish - maven

In NB 7.2 i have ejb module managed by maven with several dependencies. I try to run it on Glassfish 3.1.2.2 but it seems like server doesn't resolve libraries on classpath. I think arguments in deploy command ("deploy?DEFAULT=..." - i'm not sure it is command) are correct - there are all libraries in this command, but during creating ejb server throws class not found exception - although this class is in library in deploy command.
It is possible to deploy single EJB module with dependencies without enterprise application?
Thanks for advice

There are a couple of mechanisms for deploying EJBs. If the EJB has dependencies and is used in a web application, check if it can be used in the EJB lite configuration. It is easiest to deploy it in a WAR file along with a web application. There is an article Introducing the Java EE 6 Platform: Part 3 that details a number of the specifics.
Alternatively, you may deploy it as part of an EAR file which will include the dependencies.
If the EJB must be used as a standalone EJB, the dependencies must be be in the server classpath, or repackaged in the EJB jar file. NetBeans 7.2.1 can do that for you.

Related

spring boot startup fails when using war built on jenkins

We have a spring-boot application, built as a .war assembly (Maven build), which is deployed on the server with simple java -jar command.
As a part of CI/CD, the same code is being built on Jenkins. The Jenkins server is CentOS and the target deployment server is RedHat. The .war file built on Jenkins fails with Spring Beans Cyclic Dependency resolution error, while the same code when built on local(Mac OS) or on RedHat server works fine.
I tried to look through the war file, for each and every dependency, and everything looks same except for jsp-api-2.1 jar. The jsp-api-2.1.jar included in .war built on Jenkins has Created-By: 1.5.0_06-b04 in MANIFEST.MF, while the jsp-api-2.1.jar included in .war built on local (MacOs) or on Redhat has Created-By: 1.5.0_04-b05 in MANIFEST.MF. Other than this all other dependencies are the same.
The war files' sizes differ slightly, however, I could not find any difference other than what mentioned above.
The error which we are getting on Jenkins built jar is below,
Description:
The dependencies of some of the beans in the application context form a cycle:
| Class A
↑ ↓
| Class B
└─────┘
Does Maven generate any OS specific files, or are the dependencies downloaded from repository OS specific?
I can't really think of anything as both the .war files look similar. Any information on this will be helpful.

Use of spring-boot-maven-plugin

While creating a spring boot project I define property in pom.xml as <packaging>war</packaging> with which I can create a war and thereafter deploy the war into server maybe tomcat or WAS.
But I came across a plugin named spring-boot-maven-plugin whose documentation states that it's use is to package executable jar or war archives and run an application in-place.
My query is why do we need this at all ?
If my packaging can tell me what to create and then can deploy it to run, what is the used of this plugin.
I am trying to understand a new project so wanted to be sure that every line makes sense
The maven plugin will create an "executable" archive. In the case of the war packaging, you would be able to execute your app with java -jar my-app.war. If you intend to deploy your Spring Boot application in an existing Servlet container, then this plugin is, indeed, not necessary.
The maven plugin does more things like running your app from the shell or creating build information.
Check the documentation
The Spring Boot Maven Plugin provides Spring Boot support in Apache Maven, letting you package executable jar or war archives and run an application “in-place”.
Refer this - https://www.javaguides.net/2019/02/use-of-spring-boot-maven-plugin-with.html

mvn jboss:deploy fails with NoClassDefFoundError

When deploying an EJB project to JBoss using JBoss Maven Plugin, I get a NoClassDefFoundError on my JBoss' console about a class that is in one of the dependencies of this EJB project.
This dependency is declared with a Compile scope. Is there another scope that I should use so that my dependencies are also deployed to JBoss? Or how should I solve this?
The error looks like this:
DEPLOYMENTS IN ERROR:
Deployment "vfszip:/Users/hordine/projects/SoftBudget/soft-budget-ejb/target/soft-budget-ejb.jar/" is in error due to the following reason(s): java.lang.NoClassDefFoundError: br/com/pedra/j2eepatterns/facade/IEntityService
I understand that you have packaged the EJB as a jar file. This means there is no any provided dependency as same as a stand-alone jar.
AFAIU, there may be 3 possible ways as the following: -
Package them as an ear and put those dependencies inside the ear/lib. Please see Maven EAR Plugin for further information.
Package them as an war and put those dependencies inside the WEB-INF/lib. Please see Maven WAR Plugin for further information.
Package them as an jar and put those dependencies inside the classpath or application server lib. Please refer to your application server document.
EDITED:
If you are using the JavaEE 6, then it is possible to package the EJB as a war file. The The Java EE 6 Tutorial: Packaging Enterprise Beans in WAR Modules told us as
Enterprise beans often provide the business logic of a web application. In these cases, packaging the enterprise bean within the web application’s WAR module simplifies deployment and application organization. Enterprise beans may be packaged within a WAR module as Java programming language class files or within a JAR file that is bundled within the WAR module.
To include enterprise bean class files in a WAR module, the class files should be in the WEB-INF/classes directory.
To include a JAR file that contains enterprise beans in a WAR module, add the JAR to the WEB-INF/lib directory of the WAR module.
WAR modules that contain enterprise beans do not require an ejb-jar.xml deployment descriptor. If the application uses ejb-jar.xml, it must be located in the WAR module’s WEB-INF directory.
I hope this may help.

How do I deploy ejb jar in TomEE

M exploring openejb 4 beta with TomEE, could anyone explain how I deploy ejb jar on TomEE? I'm using it for testing purposes. Also, is it possible to configure tomee in eclipse and debug through ejbs??
Thanks in advance.
There are several scenarios for using EJB through the TOMEE(included OpenEJB), if you have an EAR file (consists of JARs and WAR) for deployment you need first active the APP folder in installed(means copied) TOMEE folder then you just drop your EAR file into APP folder and TOMEE unpack it and will be deployed properly.

Which way is the best to go for building a webapp as osgi bundle via maven and start them with webstart?

I am looking for a way to reach my vision. What is the best way to go?
Here is my vision:
I would like to build a captain casa app via maven (as a war file).
Then i would like to create a osgi bundle from the builded war via maven.
Next i would like build a artifact which could be downloaded and started via java webstart (jnlp).
The jnlp file should be download the osgi environment with web container support (maybe jetty osgi service), next download osgi bundled war. Then the osgi container and the jetty service should be started and my war should be deployed. Finally the app is running local in a osgi environment.
There are many questions to be answered:
How can i build a captain casa app via maven to a war?
Which maven plugin should be used to build the osgi bundle (pax, maven-bundle-plugin, tycho, ...) What are the differnce?
How to build a jnlp artifact via maven which can deployed on a site?
How must be modified the osgi bundle to support java webstart?
Known informations:
Blog entry to prepare osgi bundle for java webstart.
many pages to maven plugins, such as pax, maven-bundle-plugin, tycho, bnd, ...
It might be worth asking this as 3 separate questions, but when building Web application Bundles I use the maven-bundle-plugin version 2.2.0 (currently unreleased, so you'll need to depend on a snapshot).
Then I use the following file structure:
src/main/java - any .java files
src/main/resources - any non .java files that should be on the classpath
src/main/webapp - static content, images, html files jsps and so on
Then inside the pom once you have configured the normal data for the maven-bundle-plugin you specify the following:
<_wab>src/main/webapp</_wab>
this will cause the static content to be pulled into the bundle and the bundle to be structured with the classes and resources in the WEB-INF/classes directory.

Resources