[servlet]

2023-01-16 Thread Peter Scharf
I just installed NetBeans 16 on a MacBook Pro with an M chip:

Product Version: Apache NetBeans IDE 16
Java: 19.0.1; OpenJDK 64-Bit Server VM 19.0.1
Runtime: OpenJDK Runtime Environment 19.0.1
System: Mac OS X version 13.0.1 running on aarch64; UTF-8; en_US (nb)

I am trying to create a minimal servlet and war file to use with Tomcat

apache-tomcat-10.0.23

I worked through half of the demo How to create a webapp tutorial at: 
https://www.youtube.com/watch?v=eP9oz6ZKUXM
which, however, uses NetBeans 12 and other older software than I have installed.
I was able to do the first item successfully with minor adaptations:
1. Create a Jave Web project with Maven
Got build error:
https://stackoverflow.com/questions/66920567/error-injecting-org-apache-maven-plugin-war-warmojo
Went to: https://maven.apache.org/plugins/
Answer: manually configuring one of the recent war plug-ins in POM.xml
Changed 2.3 to 3.3.2
Then got the form.
I successfully created the Unit Conversion form which opens in Safari (Version 
16.1) in tomcat: http://localhost:8080/mavenproject3/

But trying the second—third items:
2. Create Java Servlet & JavaServer Page (JSP)
3. Run Java Web App on Tomcat inside NetBeans

I got stuck.
When I fill in a value in the miles box and click Convert to kilometers, Safari 
gives me a
HTTP Status 404 – Not Found
Message The requested resource [/mavenproject3/convert] is not available
Description The origin server did not find a current representation for the 
target resource or is not willing to disclose that one exists.

After a couple of days trying to fix it, I’m still at a loss.
I did get rid of a problem not finding the native tomcat libraries:
INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The 
Apache Tomcat Native library which allows using OpenSSL was not found on the 
java.library.path: ...
by dowloading and installing The Apache Tomcat Native library
following instructions here: https://formulae.brew.sh/formula/tomcat-native

However, I still get the 404 not found in Safari.
Can anyone help me?

I wonder whether these debugger messages indicate a problem using a symbolic 
link to my real tomcat directory from /Library/Tomcat

16-Jan-2023 11:15:13.009 INFO [main] 
org.apache.catalina.startup.VersionLoggerListener.log Command line argument: 
-Dignore.endorsed.dirs=
16-Jan-2023 11:15:13.010 INFO [main] 
org.apache.catalina.startup.VersionLoggerListener.log Command line argument: 
-Dcatalina.base=/Library/Tomcat
16-Jan-2023 11:15:13.010 INFO [main] 
org.apache.catalina.startup.VersionLoggerListener.log Command line argument: 
-Dcatalina.home=/Library/Tomcat

but the infos in the debugger do tell me that it is using the real directories:
CATALINA_BASE: /usr/local/apache-tomcat-10.0.23
CATALINA_HOME: /usr/local/apache-tomcat-10.0.23

I get the following debugger WARNING:
WARNING [http-nio-8080-exec-10] 
org.apache.catalina.startup.HostConfig.deployDescriptor The path attribute with 
value [/mavenproject3] in deployment descriptor 
[/usr/local/apache-tomcat-10.0.23/conf/Catalina/localhost/mavenproject3.xml] 
has been ignored

Trying to follow suggestions at: 
https://stackoverflow.com/questions/11731377/servlet-returns-http-status-404-the-requested-resource-servlet-is-not-availa
I’m lost.  I can’t even figure out which versions of Servlet I’m using, and the 
instructions to find out at.: 
https://stackoverflow.com/questions/3913485/how-do-i-know-what-version-of-servlet-api-jar-i-have

don’t provide enough context for me to know where to put the commands suggested.

===
Can anyone help me either (a) work through this tutorial with current versions 
of software, or (b) give me an example of how to create a servlet or portable 
war file in NetBeans to use with Tomcat by copying it to its webapps directory 
using current versions of NetBeans and other software?

Thank you in advance.
Yours,

**
Peter M. Scharf, President
The Sanskrit Library
sch...@sanskritlibrary.org
https://sanskritlibrary.org
**



Re: New Gradle project creates the wrong sort of project

2023-01-16 Thread Scott Palmer
As you've noted, this is what you get from 'gradle init --type
java-application'.  I was happy with that behaviour too.
I would rather not have the extra layer of an 'empty' parent project for
simple things.

I personally feel this is an issue to be brought up with Gradle.  Gradle
init could have an option to make a simple, root project only, project
structure.  That said, the use of an 'empty' root project and a sub-project
appears to be a Gradle best-practice.  In fact if you don't give a project
type on the command line, the prompts will explicitly ask you if you want
multiple subprojects or not - if you choose yes you can have a project with
an application and library as subprojects, but if you say no, you get the
same structure but simply with one subproject, exactly like when you use
'--type java-application'

However, 'gradle init --type basic' doesn't add the 'java' plugin to the
Gradle build script at all.
I just tried it and the resulting build.gradle file contains only a
comment.  Using '--type basic' is effectively useless, all you really get
from it is a settings.gradle file that sets the root project name, and it
initializes the Gradle Wrapper.  That's too basic to be useful.  No default
source folders, no plugins (not 'java' or 'application'), so there is
little point.

As a work-around, I would create the project, then move 'app/src' and
'app/build.gradle' up a level, delete the app folder, fix settings.gradle,
and get on with my day.  However, rather than fight it, I'm getting used to
the idea of using an empty parent project.
I just wish the 'application' plug would configure the jar manifest so I
don't have to always add that manually!

Regards,

Scott

On Mon, Jan 16, 2023 at 10:51 AM Emma Atkinson 
wrote:

> I'm not sure if this is a bug or intended functionality.
>
> If I want to create a simple Java SE application Gradle project I do the
> following:
> Select New Project
> Select Java with Gradle
> Select *Java Application  *for a simple application
> Click the Next button
> Enter a project name
> Click the Finish button
>
> However, this creates a multi-project application with a single subproject
> called *app*.  One has to change this default name to something
> meaningful by hand. There is no refactoring support that I could find to
> rename the subproject.
>
> This is equivalent to
> *> gradle init --type java-application*
>
> NB IDE 16 has a better way to create a multi-project with a single
> subproject if that is what one wants: just select *Multi-Project Build*
> instead of *Java Application* , which allows one to give one or more
> subprojects and give them sensible names.
>
> According to the Gradle 6.7 Release Notes, where this behaviour was first
> released, if one wants to create a simple Java SE project in NB IDE 16
> selecting Java Application should use the *basic *project type equivalent
> to:
> *> gradle init --type basic*
>
> Do you agree or am I missing something?
>
>
> *References*
> Gradle 6.7 introduced this behaviour. Documentation for the build init
> plugin may be found at
> https://docs.gradle.org/6.7/userguide/build_init_plugin.html
>
> The release notes may be found at
> https://docs.gradle.org/6.7/release-notes.html.  The release notes say to
> use project type *basic* if one does not need the complexity of a
> multi-project build.
>
> Regards
>
>


New Gradle project creates the wrong sort of project

2023-01-16 Thread Emma Atkinson
I'm not sure if this is a bug or intended functionality.

If I want to create a simple Java SE application Gradle project I do the
following:
Select New Project
Select Java with Gradle
Select *Java Application  *for a simple application
Click the Next button
Enter a project name
Click the Finish button

However, this creates a multi-project application with a single subproject
called *app*.  One has to change this default name to something meaningful
by hand. There is no refactoring support that I could find to rename the
subproject.

This is equivalent to
*> gradle init --type java-application*

NB IDE 16 has a better way to create a multi-project with a single
subproject if that is what one wants: just select *Multi-Project Build*
instead of *Java Application* , which allows one to give one or more
subprojects and give them sensible names.

According to the Gradle 6.7 Release Notes, where this behaviour was first
released, if one wants to create a simple Java SE project in NB IDE 16
selecting Java Application should use the *basic *project type equivalent
to:
*> gradle init --type basic*

Do you agree or am I missing something?


*References*
Gradle 6.7 introduced this behaviour. Documentation for the build init
plugin may be found at
https://docs.gradle.org/6.7/userguide/build_init_plugin.html

The release notes may be found at
https://docs.gradle.org/6.7/release-notes.html.  The release notes say to
use project type *basic* if one does not need the complexity of a
multi-project build.

Regards


GlassFish6 with Netbeans16 - No root permission

2023-01-16 Thread Amn Ojee Uw
Glassfish6 is installed in /opt/glassfish6, with '/*root*/' as group and 
owner id. Having stated that, when trying to add Glassfish6 to the list 
of servers in Netbeans16, the server cannot be found, since NB (me) does 
not have root permission.
Should I reinstall GF6 in a local directory, as NB16 recommends when 
trying to add GF6? should I change the owner/group permission of 
/opt/glassfish6? What other choices do I have here?


Thanks in advance.


New Simple Gradle Java Application with TestNG

2023-01-16 Thread Emma Atkinson
When NB IDE 16.0 creates a "simple" new Gradle Java project I presume it
executes *gradle init *with some command line options.

The *gradle init* command offers a choice of test frameworks.  Netbeans
chooses *JUnit Jupiter*.  However, the *gradle init* command also
offers  *JUnit
4* (gradle's default), *TestNG* and *Spock*.

Is there a way for me to get NB IDE to choose the TestNG option?

More generally speaking, what are the best ways to create projects in NB 16
using the other *gradle init* choices?

Thank you