Hot questions for Using GlassFish in intellij idea

Top Java Programmings / GlassFish / intellij idea

Question:

I want to create a Java Servlet. I know nothing about the Java ecosystem except a tiny bit of the Java language.

I already had JDK 1.8.0_65 on my machine and JRE 6 as well.

I looked up this article. It said I could use Glassfish as the application server. Java 7 EE comes with Glashfish 4.

So, I went to this page and downloaded the Java Platform, Enterprise Edition 7 SDK Update 2 for Windows. I am running 64-bit Windows 7 Home Premium. It is presently a 128 MB download.

To install it, I looked up the very unhelpful instructions on this web page. That didn't help me because this page says almost nothing except: please unzip your download and then ???, and then profit.

But this video helped me. Here's what I did.

I unzipped the folder and placed the uncompressed folder in my %Program Files%\Java folder. Then I ran the %Program Files%\Java\java_ee_sdk-7u1\glassfish4\glassfish\bin\startserv.bat file and browsed to the Url http://localhost:4848 and the Glassfish Console started up just fine.

Then as per the instructions in the Creating a project section on this page, I opened up the IntelliJ IDEA Community Edition 2016.2.1 IDE, which I already had installed previously, and clicked the Create New Project menu item in the start-up dialog.

However, in the New Project dialog, I do not see the option Java Enterprise as the article suggested. This is what my New Project dialog looks like.

What do I do now? I just want to create a simple Web application using servlets.

One difference I note is that the article suggests that I have IntelliJ IDEA Ultimate Edition, which I do not have. Is it not possible to create servlets using the community edition of IntelliJ IDEA?


Answer:

IntelliJ IDEA Comunity Edition can't create Java Enterprise applications, but Ultimate Edition can (IntelliJ IDEA Editions comparison matrix). Use it, or some another free IDE Eclipse, Netbeans etc.

Question:

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?


Answer:

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.

Question:

I'm working with IntelliJ 2019.2 and cannot start the Glassfish Server 4.1.2 (Full Platform). I've found some solution proposals for this error, but none of them worked for me, e.g. this post or this article.

Output

C:\workspace\resources\server\glassfish4\glassfish\bin\asadmin.bat start-domain domain1
GlassFish requires Java SE version 6.  Your JDK is version 0
"C:\Program Files\Java\jdk1.8.0_221\bin\java.exe" -Dfile.encoding=windows-1252 -classpath "C:\workspace\resources\server\glassfish4\glassfish\modules\javax.ejb-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.servlet-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.servlet.jsp-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules;C:\workspace\resources\server\glassfish4\glassfish\modules\acc-config.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\admin-cli.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\admin-core.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\admin-util.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\amx-core.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\amx-javaee.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\annotation-framework.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\ant.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\antlr-repackaged.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\aopalliance-repackaged.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\api-exporter.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\appclient-connector.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\appclient-server-core.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\appclient.security.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\asm-all-repackaged.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\asm-all.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\autostart\org.apache.felix.configadmin.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\autostart\org.apache.felix.eventadmin.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\autostart\org.apache.felix.fileinstall.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\autostart\org.apache.felix.gogo.command.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\autostart\org.apache.felix.gogo.runtime.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\autostart\org.apache.felix.gogo.shell.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\autostart\org.apache.felix.scr.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\autostart\osgi-cdi.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\autostart\osgi-ee-resources.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\autostart\osgi-ejb-container.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\autostart\osgi-http.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\autostart\osgi-javaee-base.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\autostart\osgi-jdbc.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\autostart\osgi-jpa.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\autostart\osgi-jta.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\autostart\osgi-web-container.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\backup.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\bean-validator-cdi.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\bean-validator.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\cdi-api-fragment.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\cdi-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\class-model.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\cluster-admin.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\cluster-common.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\cluster-ssh.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\cmp-ejb-mapping.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\cmp-enhancer.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\cmp-generator-database.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\cmp-internal-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\cmp-model.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\cmp-support-ejb.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\cmp-support-sqlstore.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\cmp-utility.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\com.ibm.jbatch.container.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\com.ibm.jbatch.spi.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\common-util.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\concurrent-connector.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\concurrent-impl.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\config-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\config-types.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\connectors-admin.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\connectors-inbound-runtime.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\connectors-internal-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\connectors-runtime.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\console-cluster-plugin.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\console-common-full-plugin.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\console-common.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\console-community-branding-plugin.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\console-concurrent-plugin.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\console-corba-plugin.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\console-ejb-lite-plugin.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\console-ejb-plugin.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\console-jca-plugin.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\console-jdbc-plugin.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\console-jms-plugin.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\console-jts-plugin.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\console-plugin-service.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\console-updatecenter-plugin.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\console-web-plugin.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\container-common.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\dataprovider.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\dbschema-repackaged.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\deployment-admin.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\deployment-autodeploy.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\deployment-client.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\deployment-common.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\deployment-javaee-core.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\deployment-javaee-full.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\dol.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\ejb-client.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\ejb-container.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\ejb-full-container.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\ejb-internal-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\ejb.security.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\endorsed\javax.annotation-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\endorsed\jaxb-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\endorsed\webservices-api-osgi.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\entitybean-container.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\flashlight-extra-jdk-packages.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\flashlight-framework.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\gf-admingui-connector.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\gf-client-module.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\gf-connectors-connector.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\gf-ejb-connector.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\gf-jms-connector.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\gf-jms-injection.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\gf-jpa-connector.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\gf-load-balancer-connector.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\gf-restadmin-connector.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\gf-web-connector.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\gf-weld-connector.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\glassfish-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\glassfish-batch-commands.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\glassfish-batch-connector.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\glassfish-corba-csiv2-idl.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\glassfish-corba-internal-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\glassfish-corba-omgapi.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\glassfish-corba-orb.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\glassfish-ee-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\glassfish-extra-jre-packages.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\glassfish-grizzly-extra-all.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\glassfish-mbeanserver.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\glassfish-naming.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\glassfish-oracle-jdbc-driver-packages.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\glassfish-registration.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\glassfish.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\gmbal.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\gms-adapter.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\gms-bootstrap.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\guava.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\ha-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\ha-file-store.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\ha-shoal-cache-bootstrap.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\ha-shoal-cache-store.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\hk2-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\hk2-config.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\hk2-core.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\hk2-locator.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\hk2-runlevel.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\hk2-utils.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\hk2.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\inmemory.jacc.provider.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\internal-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\j-interop-repackaged.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jackson-annotations.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jackson-core.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jackson-databind.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jackson-jaxrs-base.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jackson-jaxrs-json-provider.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jaspic.provider.framework.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javaee-kernel.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javamail-connector.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javamail-runtime.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javassist.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.batch-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.el.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.enterprise.concurrent-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.enterprise.concurrent.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.enterprise.deploy-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.faces.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.inject.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.interceptor-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.jms-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.json.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.mail.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.management.j2ee-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.persistence.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.resource-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.security.auth.message-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.security.jacc-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.servlet.jsp.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.servlet.jsp.jstl-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.servlet.jsp.jstl.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.transaction-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.websocket-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.ws.rs-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.xml.registry-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\javax.xml.rpc-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jaxb-extra-osgi.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jaxb-osgi.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jboss-logging.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jdbc-admin.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jdbc-config.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jdbc-runtime.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jersey-bean-validation.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jersey-cdi1x-servlet.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jersey-cdi1x-transaction.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jersey-cdi1x.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jersey-client.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jersey-common.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jersey-container-grizzly2-http.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jersey-container-servlet-core.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jersey-container-servlet.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jersey-entity-filtering.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jersey-gf-ejb.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jersey-guava.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jersey-media-jaxb.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jersey-media-json-jackson.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jersey-media-json-jettison.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jersey-media-json-processing.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jersey-media-moxy.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jersey-media-multipart.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jersey-media-sse.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jersey-mvc-connector.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jersey-mvc-jsp.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jersey-mvc.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jersey-server.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jettison.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jms-admin.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jms-core.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jmxremote_optional-repackaged.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jpa-container.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jsf-connector.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jsftemplating.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jsonp-jaxrs.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jspcaching-connector.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jsr109-impl.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jstl-connector.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jta.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\jts.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\kernel.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\launcher.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\ldapbp-repackaged.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\libpam4j-repackaged.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\load-balancer-admin.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\logging.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\management-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\metro-glue.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\mimepull.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\monitoring-core.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\nucleus-grizzly-all.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\nucleus-resources.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\orb-connector.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\orb-enabler.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\orb-iiop.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\org.apache.felix.bundlerepository.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\org.eclipse.persistence.antlr.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\org.eclipse.persistence.asm.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\org.eclipse.persistence.core.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\org.eclipse.persistence.dbws.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\org.eclipse.persistence.jpa.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\org.eclipse.persistence.jpa.jpql.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\org.eclipse.persistence.jpa.modelgen.processor.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\org.eclipse.persistence.moxy.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\org.eclipse.persistence.oracle.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\osgi-adapter.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\osgi-cli-remote.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\osgi-container.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\osgi-jpa-extension.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\osgi-resource-locator.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\persistence-common.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\pfl-asm.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\pfl-basic-tools.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\pfl-basic.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\pfl-dynamic.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\pfl-tf-tools.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\pfl-tf.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\pkg-client.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\registration-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\registration-impl.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\resources-connector.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\resources-runtime.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\rest-client.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\rest-service.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\scattered-archive-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\schema2beans-repackaged.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\security-ee.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\security-services.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\security.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\shoal-cache.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\shoal-gms-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\shoal-gms-impl.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\simple-glassfish-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\soap-tcp.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\ssl-impl.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\stats77.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\stax2-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\transaction-internal-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\trilead-ssh2-repackaged.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\tyrus-client.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\tyrus-container-glassfish-cdi.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\tyrus-container-glassfish-ejb.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\tyrus-container-grizzly-client.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\tyrus-container-servlet.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\tyrus-core.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\tyrus-server.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\tyrus-spi.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\war-util.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\web-cli.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\web-core.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\web-embed-api.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\web-glue.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\web-gui-plugin-common.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\web-ha.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\web-naming.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\web-sse.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\websecurity.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\webservices-connector.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\webservices-extra-jdk-packages.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\webservices-osgi.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\webservices.security.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\weld-integration-fragment.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\weld-integration.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\weld-osgi-bundle.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\woodstox-core-asl.jar;C:\workspace\resources\server\glassfish4\glassfish\modules\work-management.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2019.2\plugins\JavaEE\lib\javaee-impl.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2019.2\lib\platform-api.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2019.2\lib\util.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2019.2\plugins\Glassfish\lib\specifics\glassfish3.1-specifics.jar" com.intellij.javaee.oss.process.JavaeeProcess 58993 com.intellij.javaee.oss.glassfish.agent.Glassfish31Agent
Detected server admin port: 4848
Detected server http port: 8080
  • It already worked once, but I had to change my workstation and reinstall IntelliJ
  • I also updated my JDK, it is still version 8, but now another u number (8u221, I don't know which version I used before)
  • The Application Server settings in IntelliJ are correct
  • The Glassfish logs are empty
  • My JAVA_HOME is set correctly (C:\Program Files\Java\jdk1.8.0_221)
  • I added %JAVA_HOME%\bin to the PATH variable.
  • I'm able to start the server over the cmd (asadmin.bat start-domain domain1)
  • Ensured that correct SDK is set in IntelliJ (Project Structure -> Platform Settings)
  • Tried different Java Compiler Settings (IntelliJ Settings), e.g. changed Project Byte Code version to 6 instead of 8.
  • Adding the line AS_JAVA=MY_JDK_DIRECTORY did not help
  • Reinstalling Glassfish did not help
  • Glassfish Plugin in IntelliJ is enabled (default)

    java -version
    java version "1.8.0_221"
    Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
    Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
    

I don't know what to do anymore, can someone help me please?


Answer:

Inside of your Injellij double shift (press shift twice) to open the search and type in JDK. Under actions click on switch boot JDK and make sure you have one there if not select one and then click save and restart. hope this works and helps.

Question:

I followed these steps on JetBrain's site to create a web application and get GlassFish going locally. It runs fine, I can embed output from code in the src tree of the project in the JSP and see it in the web browser. The problem starts when I add a Maven dependency. I added

<dependency>
    <groupId>com.nimbusds</groupId>
    <artifactId>oauth2-oidc-sdk</artifactId>
    <version>4.9</version>
</dependency>

to my pom.xml and use the dependency in my code. Maven installs the dependency, everything builds fine, but when I click the green arrow to run it in GlassFish I get this error when the browser opens:

org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP

PWC6199: Generated servlet error: source value 1.5 is obsolete and will be removed in a future release

PWC6199: Generated servlet error: target value 1.5 is obsolete and will be removed in a future release

PWC6199: Generated servlet error: To suppress warnings about obsolete options, use -Xlint:-options.

PWC6197: An error occurred at line: 8 in the jsp file: /index.jsp PWC6199: Generated servlet error: cannot access com.nimbusds.oauth2.sdk.SerializeException class file for com.nimbusds.oauth2.sdk.SerializeException not found

Here's the source for index.jsp:

<%@ page import="com.idsrvjpoc.IdentityServerConfiguration" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
    <head>
        <title>Redirect</title>
    </head>
    <body>
        <% String redirectUrl = new IdentityServerConfiguration().getRedirectUrl(); %>
        <a href="<%=redirectUrl%>"><%=redirectUrl%></a>
    </body>
</html>

In the Java Compiler settings for my module the target bytecode version is set to 1.8 and I'm using the latest version of the 1.8 JDK.

I found another SO answer that suggested copying the dependencies' JAR files to the glassfish4\glassfish\domains\domain1\lib folder, so I tried that and it changed the error:

java.lang.NoClassDefFoundError: com/nimbusds/oauth2/sdk/id/ClientID

No more obsolete target value or class file not found, but a NoClassDefFoundError. It's a different class now. Both SerializeException and ClientID are in the same JAR, and I can extract the JAR and see both the .class files in what appear to me to be the correct places.

Here's the source for IdentityServerConfiguration.java:

package com.idsrvjpoc;

import com.nimbusds.oauth2.sdk.*;
import com.nimbusds.oauth2.sdk.id.*;

import java.net.URI;
import java.net.URISyntaxException;

public class IdentityServerConfiguration {
    public String getRedirectUrl() throws URISyntaxException, SerializeException {
        URI authzEndpoint = new URI("myAuthEndpoint");
        ClientID clientID = new ClientID("1234");
        Scope scope = new Scope("openid");
        URI callback = new URI("http://localhost:8080/IdentityServerPoc_war_exploded/return.jsp");
        State state = new State();

        AuthorizationRequest request = new AuthorizationRequest.Builder(
                new ResponseType(ResponseType.Value.CODE), clientID).
                scope(scope).
                state(state).
                redirectionURI(callback).
                endpointURI(authzEndpoint).
                build();

        return request.toURI().toString();        
    }
}

What am I missing?

E: I just tried deleting the JARs from the GlassFish lib folder and editing the war artifact, on the Output Layout tab I moved the jars from the Available Elements to the WEB-INF/lib directory and I see that they get copied there when I build, but still the same error.

I also tried having the artifact extract the .class files from the JARs into the WEB-INF/classes folder. Again, I see them in the WEB-INF/classes folder in the out folder of my project, but still the same java.lang.NoClassDefFoundError: com/nimbusds/oauth2/sdk/id/ClientID

E2: Here is the complete pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>IdSrvJPoc</groupId>
    <artifactId>IdentityServerJavaPoc</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>com.nimbusds</groupId>
            <artifactId>oauth2-oidc-sdk</artifactId>
            <version>4.9</version>
        </dependency>
    </dependencies>
</project>

Answer:

Since you get a NoClassDefFoundError there might still be depedencies missing in your lib folder. Make sure any Numbus dependencies are included as well.

Question:

I have a Java EE app running on Glassfish, and I have Glassfish running in a container, using Docker and Docker Compose.

I want to know if it's possible to debug this app running on the Glassfish container, as you would debug a regular Java app, from Intellij IDEA.

I've tried something like this but it hasn't worked for me.

My docker-compose.yml includes (removing other private info):

services:
  glassfish:
    tty: true
    build: glassfish
    ports:
    - "8080:8080"
    - "4848:4848"
    - "80:80"
    - "9009:9009"

Dockerfile includes (removing other non related info):

EXPOSE 8080 4848 80 9009

COPY 010_entrypoint.sh /docker-entrypoint.d/

ENTRYPOINT /docker-entrypoint.d/010_entrypoint.sh

And in 010_entrypoint.sh file (removing other non related info):

/opt/glassfish4/glassfish/bin/asadmin start-domain --debug

Answer:

Running glassfish server on a docker is like running it on a remote server so you have to setup remote debugging.

You have t make sure:

a) Your Glassfish server is running in debug mode b) You have configured port 9009 on your docker so the debugger can connect to it (you need to have a line like this in your docker-compose.yml: - 9009:9009)

Then you have to configure your debugger to connect to localhost:9009

Finally if you share your Dockerfile an docker-compose.yml it will be easier to understand what is going wrong.

Question:

I am new to Intellij ide and i'm having issues running Glassfish 5 or any previous version on Intellij 2017 2.4.

After selecting New Project > Java Enterprise > Web Application i had to specify the application server, to which i selected the folder of glassfish 5, jdk is set to 1.8 and java ee to 7. So far so good, no errors and the project gets created. Then i have a greyed "play" icon next to GlassFish 5.0.0 in the upper right of the corner that says that i have to configure it, i click Edit Configurations and the Run/Debug Configurations opens up Everything seems fine and when i click the "play" green button to start the server and run the project i have projectName:war exploded under Deployment and

[2017-09-26 08:47:57,836] Artifact testfornew:war exploded: Waiting for server connection to start artifact deployment...
Detected server admin port: 4848
Detected server http port: 8080
Exception in thread "main" java.lang.NullPointerException
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.initializeServiceLocator(AbstractModulesRegistryImpl.java:152)
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.newServiceLocator(AbstractModulesRegistryImpl.java:144)
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.createServiceLocator(AbstractModulesRegistryImpl.java:218)
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.createServiceLocator(AbstractModulesRegistryImpl.java:224)
at com.sun.enterprise.module.single.StaticModulesRegistry.createServiceLocator(StaticModulesRegistry.java:88)
at com.sun.enterprise.admin.cli.CLIContainer.getServiceLocator(CLIContainer.java:217)
at com.sun.enterprise.admin.cli.CLIContainer.getLocalCommand(CLIContainer.java:255)
at com.sun.enterprise.admin.cli.CLICommand.getCommand(CLICommand.java:231)
at com.sun.enterprise.admin.cli.AdminMain.executeCommand(AdminMain.java:371)
at com.sun.enterprise.admin.cli.AdminMain.doMain(AdminMain.java:306)
at org.glassfish.admin.cli.AsadminMain.main(AsadminMain.java:57)

Under output. Coming from Netbeans setting glassfish up was pretty straightforward, i've checked a couple of solutions online including this but they don't seem to work for me.


Answer:

In my case JDK 1.8.0_152 must be installed, path and java_home variables have to be configured AND JDK 9.X must be uninstalled. Without uninstall, the error persist.

Question:

I've started using GlassFish 4.1.1 with IntelliJ and tried created a new J2EE project.

The only thing I modified was the output message written out by the facelet.

Now deploying and thus connecting to the server doesn't seem to work.

The message:

Detected server admin port: 4848
Detected server http port: 8080
[2016-04-18 10:30:58,648] Artifact FirstEE:war exploded: Server is not connected. Deploy is not available.
java.nio.file.AccessDeniedException: C:\Program Files\Java\glassfish4\glassfish\domains\domain1\logs\server.log.lck
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
at sun.nio.fs.WindowsFileSystemProvider.newFileChannel(WindowsFileSystemProvider.java:115)
at java.nio.channels.FileChannel.open(FileChannel.java:287)
at java.nio.channels.FileChannel.open(FileChannel.java:335)
at java.util.logging.FileHandler.openFiles(FileHandler.java:459)
at java.util.logging.FileHandler.<init>(FileHandler.java:326)
at com.sun.enterprise.admin.launcher.GFLauncherLogger.addLogFileHandler(GFLauncherLogger.java:99)
at com.sun.enterprise.admin.launcher.GFLauncher.setup(GFLauncher.java:192)
at com.sun.enterprise.admin.servermgmt.cli.StartDomainCommand.createLauncher(StartDomainCommand.java:228)
at com.sun.enterprise.admin.servermgmt.cli.StartDomainCommand.executeCommand(StartDomainCommand.java:124)
at com.sun.enterprise.admin.cli.CLICommand.execute(CLICommand.java:322)
at com.sun.enterprise.admin.cli.AdminMain.executeCommand(AdminMain.java:366)
at com.sun.enterprise.admin.cli.AdminMain.doMain(AdminMain.java:300)
at org.glassfish.admin.cli.AsadminMain.main(AsadminMain.java:56)

Attempting to start domain1.... Please look at the server log for more details.....
"C:\Program Files\Java\glassfish4\glassfish\bin\asadmin.bat" stop-domain --domaindir "C:\Program Files\Java\glassfish4\glassfish\

What I tried out:

  • Checking for any process listening to port 4848, there's none

  • deleted the standard domain domain1 and tried to create a new one, failed because the command asadmin is unknown.

  • added "asadmin" file from glassfish's directory to the PATH variable, still unknown.

  • Reinstalling GlassFish

  • GlassFish's and IntelliJ's version are are up to date

Has anyone an idea?


Answer:

Problem was pretty trivial... Just had to run my IDE as an administrator because elseway IntelliJ had no access to the server log file and thus couldn't make neccessary changes in it.

Be sure to check out the other solutions I named in my questions though...

Question:

I'm just starting out with JavaEE (I'm decently fluent in JavaSE) and am having trouble wrapping my brain around all the new things that are required to make even the simplest of applications. Right now I am trying to use JAX-RS annotations to generate a simple "Hello World" html page in IntelliJ using Glassfish 4. I've searched around for the proper use of these annotations, and it seems like I'm doing it correctly, but I keep getting a 404 no matter where I navigate in localhost. I'm starting to think I'm missing vital components in my code, and I don't know enough about JavaEE to know what I'm missing (perhaps it could be something in the web xml file, which I don't know too much about). Here is the code that I wrote, minus the imports:

@LocalBean
@Stateless
@Path("/hello")
@Produces("text/html")
public class Hello {

    @GET
    @Path("/world")
    public String printHelloWorld() {
        return "<html lang=\"en\"><body><h1>Hello, World!</h1></body></html>";
    }
}

The server itself is up and running and the application seems to deploy correctly. The default URL that is set up at launch time is "http://localhost:8080/HelloWorld_war_exploded/", so my understanding is that I should be going to http://localhost:8080/HelloWorld_war_exploded/hello/world to display the message.

EDIT: Here is my XML file, which I did not change at all:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>
</web-app>

Upon looking at Lutz's comment, I've investigated the base URL issue and am currently viewing the following link: http://www-01.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.nd.doc/ae/twbs_jaxrs_configwebxml.html?cp=SSAW57_8.5.5%2F1-3-0-28-2-0-1

I will update accordingly.


Answer:

You need to configure Jersey (the JAX-RS implementation in Glassfish) in your web.xml. You currently only have JSF configuration

<servlet>
    <servlet-name>jersey-serlvet</servlet-name>
    <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
    <init-param>
        <param-name>jersey.config.server.provider.packages</param-name>
        <param-value>the.package.where.your.resources.are</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>jersey-serlvet</servlet-name>
    <url-pattern>/api/*</url-pattern>
</servlet-mapping>

The <url-mapping> is the base for your Jersey app. So you would use

http://localhost:8080/HelloWorld_war_exploded/api/hello/world

If you want to use Standard JAX-RS configuration, you can do

<servlet>
    <servlet-name>javax.ws.rs.core.Application</servlet-name>
</servlet>

<servlet-mapping>
    <servlet-name>javax.ws.rs.core.Application</servlet-name>
    <url-pattern>/api/*</url-pattern>
</servlet-mapping>

This will scan your entire classpath for resources, so you don't need to specify the package, like the previous configuration.

Or you can use Java code

@javax.ws.rs.ApplicationPath("/api")
public class RestApplication extends javax.ws.rs.core.Application {

}

Leaving this class empty will also scan the entire classpath for your resources. Or you can add your classes explicitly

@javax.ws.rs.ApplicationPath("/api")
public class RestApplication extends javax.ws.rs.core.Application {
     @Override
     public Set<Class<?>> getClasess() {
         Set<Class<?>> classes = new HashSet<>();
         classes.add(Hello.class);
         return classes;
     }
}

Question:

I'm trying to add glassfish application server on Intellij IDEA but it gives an 'application server libraries not found' error.

libs not found :

I've confirmed the installation path from netbeans-which seems to work with no issues, and the path given on the web console is the same

what is it that i could be missing? Edit: The directory structure looks like this dir i've tried both a level above and one level down-whereby i tried the bin and the domains folders


Answer:

Remove the second glassfish from the path. You want:

C:\Program Files\glassfish-4.1.1

Here's how my location looks in intelliJ (my glassfish is in the the C:\ directory)

Question:

Help me please! I cannot deploy application from IDE. When I run application, glassfish was starting but cannot deploy application. I am trying set up password to domain1 but still the same.

Idea2018.1, MacOs 10.13.5, Glassfish 5.0.1, JDK 1.8.0.141

Nothing errors but: No errors except: Message: java.lang.NoSuchMethodError: com.sun.enterprise.admin.util.AuthenticationInfo.(Ljava/lang/String;Ljava/lang/String;)V Stack trace: com.intellij.javaee.process.common.JavaeeProcessUtilException: java.lang.NoSuchMethodError: com.sun.enterprise.admin.util.AuthenticationInfo.(Ljava/lang/String;Ljava/lang/String;)V at com.intellij.javaee.process.common.MethodInvocator.invoke(MethodInvocator.java:47) at com.intellij.javaee.oss.process.JavaeeProcess.processRequest(JavaeeProcess.java:112) at com.intellij.javaee.oss.process.JavaeeProcess.run(JavaeeProcess.java:52) at com.intellij.javaee.oss.process.JavaeeProcess.main(JavaeeProcess.java:31) Caused by: java.lang.NoSuchMethodError: com.sun.enterprise.admin.util.AuthenticationInfo.(Ljava/lang/String;Ljava/lang/String;)V at com.intellij.javaee.oss.glassfish.agent.Glassfish31Agent.getConnection(Glassfish31Agent.java:36) at com.intellij.javaee.oss.glassfish.agent.Glassfish3AgentBase.invoke(Glassfish3AgentBase.java:183) at com.intellij.javaee.oss.glassfish.agent.Glassfish3AgentBase.doConnect(Glassfish3AgentBase.java:39) at com.intellij.javaee.oss.agent.SimpleAgentBase$1.doJob(SimpleAgentBase.java:17) at com.intellij.javaee.oss.agent.SimpleAgentBase$1.doJob(SimpleAgentBase.java:13) at com.intellij.javaee.oss.agent.SimpleAgentJob.perform(SimpleAgentJob.java:12) at com.intellij.javaee.oss.agent.SimpleAgentBase.connect(SimpleAgentBase.java:25) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.javaee.process.common.MethodInvocator.invoke(MethodInvocator.java:41) ... 3 more


Answer:

I already have opened an issue on Jetbrains with lots of informations: https://youtrack.jetbrains.com/issue/IDEA-194181

The last functional version was GF 5.0.1 (build 20171121).

What they changed to broken the IDEA plugin is here: https://github.com/javaee/glassfish/commit/aeca5223f4ede5ea4423497c4f83e80f9cfb7185#diff-7bc38f41e6b87d51ceff9f429e1d6375

They change the contract of constructor from String -> char[] to secure passwords not using JVM's String pool.

Question:

I'm starting out learning to build a Java EE Web App and following a tutorial which uses Eclipse though I use IntelliJ.

I've build the basic structure and can run the Glassfish server successfully so I see the welcome page at localhost:8080

I'm having some trouble seeing my servlet output displayed however as I get a 404.

When I go to http://localhost:8080/web1_war_exploded/ then I see the output from the index.jsp file

What I want to see is the HTML output from my AddPassenger class when I visit: http://localhost:8080/web1/AddPassenger. Instead I get a 404:

I think I've configured everything as per IntelliJ's own instructions and have created a .war and a Manifest. I'm just unclear how to deploy and see my AddPassenger servlet which is simply:

@WebServlet(name = "/AddPassenger")
public class AddPassenger extends HttpServlet {
private static final long serialVersionUID = 1L;

public AddPassenger(){
    super();
}

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    PrintWriter out = response.getWriter();

    response.setContentType("text/html");

    out.println("<html><body>");
    out.println("</body>");
    out.println("<h2>Welcome to World Adventures Airlines!</h2>");
    out.println("</html>");
}

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

}

}

This is my project structure:


Answer:

Change @WebServlet(name = "/AddPassenger") to @WebServlet(value = "/AddPassenger"). In this case it should work on http://localhost:8080/web1_war_exploded/AddPassenger.

Also using annotations no need to declare servlets in web.xml. And make sure that your glassfish version supports servlet 3.0.

To change path of url from /web1_war_exploded/ to /web1/ go to the File->Project Structure and change output dir: