How to run on GlassFish in IntelliJ? - java

I am using IntelliJ, and I have a J2EE project. I have setted up a local GlassFish server in the IDE, but how can I configure the project to run on that local GlassFish server?
My project uses Java EE's features (such as servlets), but IntelliJ says that those libraries do not exist:
I can't run my project either:
How do I associate my local GlassFish server with the project, and enable the GlassFIsh's library?

I have setted up a local GlassFish server in the IDE, but how can I configure the project to run on that local GlassFish server?
I assume that you did this using Run > Edit Configurations... in which a local or remote Glassfish server can be configured. So in the window of Glassfish edit configurations there is a tab named deployment in which you can add source(s) to be deployed at the server startup.
My project uses Java EE's features (such as servlets), but IntelliJ
says that those libraries do not exist:
Go to File > Project structure or press Ctrl+Alt+Shift+S click to open Modules > Dependencies tab press the Add (+) button select Library... and there you can find Glassfish and add it as a dependency.

Did you follow the recommended way to create your J2EE project in Intellij?
Follow the guide here: Getting Started with Java EE 7 and GlassFish 4.0

Related

Create a Gradle 7.x Java web application project in Eclipse 2021-03

I use Eclipse and Gradle for a few "desktop" / command line Java application projects, including multi-project projects.
But I haven't used Gradle for a Java web application project in Eclipse so far. My usual approach is:
Create empty workspace and configure it (JDK, Runtime environment Tomcat server)
"Create a Dynamic Web project", run through wizard
And everything works fine. The project has a proper structure (WEB-INF exists, web.xml is created etc.), it compiles and it is deployed automatically to Tomcat by Eclipse. CATALINA_BASE is set to some temp folder in the workspace.
But how do I create a Gradle project which is a "Dynamic Web project" and not just a command line Java application or java-library?
I have tried two approaches:
Create a Gradle project using the wizard in Eclipse. It seems to create a java-library project always with a lib subproject. Having created the "wrapper" project and the actual Gradle project lib, set java and war as plugins for this. Open the project properties of the Gradle project lib, Project Facets, add Dynamic Web Project Facet (4.0). Create run configuration to make it run in Tomcat server.
Create a Gradle project using gradle init in an empty directory. Create application project instead of library. Import that existing Gradle project into an empty workspace (instead of using Eclipse to create the project). And apply the same procedures as above (facet etc.).
None of the approaches gave me a working, ready-to-use web application project that has the expected folder structures (WebContent, WEB-INF, ...), that deploys correctly (no deployment or e.g. web.xml missing) ...
I spent several hours to use Gradle in a Java web application project in Eclipse. (Because I want to profit from its easy declarative dependency management.) But I didn't manage to make it work.
Also the samples in the Gradle docs do not contain a Java web application project:
https://docs.gradle.org/current/samples/index.html
Only Java Application or Java Library.
Has someone else already managed to set this up?
Gradle 7.0.x
Eclipse 2021-03
Tomcat 9 or 10 (I've tried both)
AdoptOpenJDK 11
Windows machine
Please share your approach. :)

Not able to run a service on tomcat via IntelliJ Idea

I am working on a framework "beadledom".
I am also relatively very new to IntelliJ Idea, I have used eclipse before, the beadledom framework contains the project sub-module,
api
service
client
In Eclipse if we want to run the services, I would right click on "service" sub-module Run on Server -> tomcat ; and it would run.
My webapp is stored in "service" folder.
I have no clue how do I do it on IntelliJ
I did set the Run Configuartion.
I am being asked to create a "artifact" in Edit Configuration>Tomcat
enter image description here
The artifact is an archive, built from your project sources which constitutes your application. For Java EE web projects it is usually a war achrive which you deploy to an application server (e.g. Tomcat). In case of a Maven-based poject IntelliJ IDEA automatically creates web artifact, based on Maven pom.xml configuration which then you can select to deploy in Tomcat Run/Debug Configuration Deployment tab.
You could check Developing a Java EE Application tutorial for the general workflows in JavaEE-based projects in IntelliJ IDEA.

Deploying to Weblogic 10.3.6 from Eclipse -- "There are no resources that can be added or removed from the server."

I have a Spring Boot application. I build it with Maven. I have the pom configured to produce a Weblogic-compatible .war file. I can deploy this war file manually via either the WebLogic console or via the weblogic-maven-plugin Maven command.
I have now added my WebLogic server and domain to my Eclipse servers panel. I can start and stop it just fine, but when I click "Add and Remove", I get:
There are no resources that can be added or removed from the server.
In my Project Facets, I have:
Dynamic Web Module 2.5
Java 1.7 (matches what WebLogic wants and what my pom specifies)
What else can I check or change?
Sometimes the problem might also because you did not select the dynamic web module .
To do so open your project properties then goto your Project Facets then Check/Select the Dynamic Web Module checkbox then apply & close.
So, even though I didn't have the Cloud Foundry facet checked, that was still the issue. I deleted the Cloud Foundry-related plugins from Eclipse, and it started working.

Unable to create the WAR of my web application on Jboss

I am trying to deploy my web application with Jboss AS 6.x.
The problem I am facing is when I try to export the WAR file by right clicking on the project from left menu and export, there is no such option as to export the project as WAR.
I have installed JBoss Application Tools successfully. Integrated JBoss server successfully.
Where am I missing? Am I missing some necessary tools?
This option is available only if your project is Dynamic Web Project. The Java project, which is decorated with J letter on folder icon doesn't have the capability to export as WAR archive. But to deploy a web project you might try the approach "Run as...". And choose the server configured before to run a web project.
You can't convert a Java project to a Dynamic Web Project automatically with JBoss Application Tools. But if you have MyEclipse IDE then it's easy done just by adding a web capabilities. So, choose "New..." project wizard and "Dynamic Web Project" then follow the wizard pages.

Running Maven Struts2 app on tomcat

I created a Struts2 App using Eclipse M2 Maven plugin but there is no option to run the project on my tomcat server. I tried including the server runtime libraries in the projects build path but that doesn't work. How can I solve this problem?
In order to run project on server in eclipse, project must be in faceted form with Dynamic Web Module enabled. To convert project to faceted form: right click on project -> Properties -> Project Facets -> Convert to faceted form... -> check Java and Dynamic Web Module.
When you build the project, it should create an output, a war file or extracted war file. You need to deploy this on the server then only you can see the application. In eclipse I believe you can configure an server. Once you have configured a server in eclipse you can tell it to look for your project build output and deploy it.
Right click on the project and then Run As > Run on Server.
If you do not see that option that means your project is not configured as Web Application.

Categories

Resources