How to upgrade to Servlet 3.1? - java

We have Java 7 installed on out machines but for some reason we deploy with Servlet 2.4.
Where do I download the latest version of Servlet (3.1) and are there specific steps I have to take to install it?

If you use eclipse, there is a way for doing it by auto-generating.
go to the "Properties" --> Project Facets --> Change the "Dynamic Web Module" version to 3.1 ...
Maybe you will have some problems because you have different versions, but you can solve it.
Upgrate your application server, too.
I hope this helps you

Related

Unable to create Enterprise application in NetBeans IDE 12.6

When I try to create an Enterprise application using the wizard (Ant project) I get the following error
java.lang.NullPointerException: Cannot invoke "org.netbeans.modules.j2ee.dd.api.application.Application.setDisplayName(String)" because "this.application" is null
at org.netbeans.modules.j2ee.earproject.ProjectEar.setupDDFromVirtual(ProjectEar.java:290)
at org.netbeans.modules.j2ee.earproject.ProjectEar.getApplication(ProjectEar.java:255)
at org.netbeans.modules.j2ee.earproject.ui.wizards.NewEarProjectWizardIterator.testableInstantiate(NewEarProjectWizardIterator.java:160)
at org.netbeans.modules.j2ee.earproject.ui.wizards.NewEarProjectWizardIterator.instantiate(NewEarProjectWizardIterator.java:139)
at org.openide.loaders.TemplateWizard$InstantiatingIteratorBridge.instantiate(TemplateWizard.java:1048)
at org.openide.loaders.TemplateWizard.handleInstantiate(TemplateWizard.java:602)
at org.netbeans.modules.project.ui.NewProjectWizard.handleInstantiate(NewProjectWizard.java:51)
at org.openide.loaders.TemplateWizard.instantiateNewObjects(TemplateWizard.java:436)
at org.openide.loaders.TemplateWizardIterImpl.instantiate(TemplateWizardIterImpl.java:228)
at org.openide.loaders.TemplateWizardIteratorWrapper$ProgressInstantiatingIterator.instantiate(TemplateWizardIteratorWrapper.java:155)
at org.openide.WizardDescriptor.callInstantiateOpen(WizardDescriptor.java:1602)
at org.openide.WizardDescriptor.callInstantiate(WizardDescriptor.java:1546)
at org.openide.WizardDescriptor.access$2300(WizardDescriptor.java:67)
[catch] at org.openide.WizardDescriptor$Listener$2$1.run(WizardDescriptor.java:2233)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)
Of course, all the fields in the wizard are filled. However, there are no errors when creating WAR and EJB separately. The error occurs only when an EAR is created, even if it is empty.
use
NetBeans 12.6
Windows 10 OS
GlassFish Server 6.2.1
Java 17
All paths are spelled out correctly, read / write permissions to directories are set
Screen
I can reproduce your problem, and NetBeans Bug Report 5953 "Creating a new Enterprise Application (Java with Ant) impossible (only when selecting JakartaEE9) - NPEs thrown" has already been raised.
The bug report is unresolved, but the problem only occurs when creating a Jakarta EE 9 Enterprise Application. I successfully created a Jakarta EE 8 Enterprise Application simply by selecting Jakarta EE8 from the Java EE Version drop list within the wizard.
You have several options available to resolve this, but none of them are good:
Wait for NetBeans to fix the problem. Definitely not recommended!
Create a Jakarta EE8 Enterprise Application with the Ant wizard instead, if you don't require EE 9 functionality.
Create a Jakarta EE8 Enterprise Application with the Ant wizard, then "hack" the generated projects to use EE 9.
Use another IDE which properly supports this functionality.
Create the EE 9 Enterprise Application in another IDE, then import the projects into NetBeans.
Using Maven or Gradle isnstead of Ant as the build tool doesn't help either:
I couldn't create a Maven Enterprise Application when using Jakarta EE8 or Jakarta EE9, though I didn't research why.
The project wizard doesn't even offer "Enterprise Application" as an option when using Gradle.
Notes:
NetBeans 13 will be released next month, but I don't think this issue will be fixed.
Also see the (ominous) bug report "NETBEANS-2871 Resolve Enterprise Application support" from 2019 which remains unresolved:
Need to figure out whether maybe Web Applications (in Ant, Maven, and
Gradle) might not be enough in terms of Java EE support, i.e., do we
need Enterprise Applications and EJB-specific project types, if not,
let's remove them.
It works with jakarta EE9 provided you do the following:
Plugin versions in all pom.xml files:
maven-compiler-plugin 3.9.0
maven-war-plugin 3.3.2
maven-dependency-plugin 3.2.0
In the pom.xml file of -ejb- change packaging war to jar.
Then:
Clean and build in the following order:
top, ejb, web and ear.
That's all.

Not able to create JSF 2.2 project in Eclipse/RAD 9.5 without disabling library configuration

I am using IBM RAD 9.5. I am not sure what version of Eclipse that corresponds to. This version of RAD comes with WebSphere version 8.5.
When I try to create project:
New > Web Project > Java Server Faces
Under 'JSF Settings', if I pick version 2.2, it won't allow me to create the project unless I go under 'JSF Library' and select 'Disable Library Configuration' (Version 2.0 selects 'Default JSF Implementation', this option is not available when 2.2 is picked.)
When I do select 'Disable Library Configuration', I get the message
This facet requires JSF implementation library to be present on the project
classpath. By disabling library configuration, user takes on responsibility
of configuring classpath appropriately via alternate means
What does this mean? What else do I need to do to ensure my configurations are OK.
NB: My environment would not allow me to post screenshots. So I have described the issue.
It would appear WebSphere 8.5 contains only JSF 2.0 implementation. In order to get the application work with JSF 2.2, the JSF 2.2 JARs would need to be included in the application classpath.

Project not deploying due to "Project facet Java 1.7 is not supported by this server."

I am having trouble trying to deploy a WAR project on Oracle Weblogic Server 11gR1 (10.3.5), tried both to deploy it in an EAR project, or by itself as a war.
The error I get is this:
"Project facet Java 1.7 is not supported by this server."
The problem is that there is no Project Facet Java 1.7 in this project. The facets selected are this:
Dynamic Web Module 2.5
Java 1.6
JavaScript 1.0
I only have JRE6 installed in eclipse and I'm using it as default.
Other projects are deploying succesfully.
I found a workaround, deploying the EAR empty, and then adding the WAR project to the EAR. But in that case I get other problems at runtime which shouldn't be happening, I guess caused by the tricky solution.
Any ideas?
Thank you.
I just solved the issue, I had java project facet 1.7 in a project included in the war.
Weblogic 10.3.5 only supports JDK6. If you want to use JDK 7, you'll need version 10.3.6 as outlined here (10.3.5) and here (10.3.6).
Cheers,

Tomcat version 7.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 and 6 Web modules

I'm trying to deploy a very simple HTTPServlet project using Tomcat 7 in my Eclipse J2EE perspective. I am getting the error "Tomcat version 7.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 and 6 Web modules". I have already tried modifying my org.eclipse.wst.common.project.facet.core.xml as mentioned here file but that doesn't seem to fix the issue. I'm able to deploy just fine by using file->export->.war directly to my installed tomcat server. Any ideas?
Go to Project Properties -> Project Facets and change the version of Dynamic Web Module. If it is set to 3.1 then change it to 3.0. In case it does not allow you to change the version, uncheck it and press apply. Then you can select the version, check it and apply-OK.
Worked for me!
Yes, using Maven, Spring project with Java EE compliance we face this issue with Tomcat. To fix this problem please execute the list of commands to make the project as Java EE compliance.
$ mvn eclipse:clean - to clean the eclipse files like .project .classpath
$ mvn eclipse:eclipse -Dwtpversion=2.0 to create the eclipse compatible with Java EE.
At last open the project in eclipse select the server tomcat now click run on servers(Alt+Shift+x,R) select tomcat7.0 to run.
If you are getting "Tomcat version 7.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 and 6 Web modules" error when trying to add project to Tomcat 7. Simply,
Right click on the project --> go to project facets --> uncheck the dymanic web module (which should be 3.1)--> apply --> then change the dynamic web module to 3.0 --> apply and then save.
Try to add now and it should work.
Tomcat is not a Java EE compliant application server, so you won't have EJB or CDI out-of-the-box here. Instead, use JBoss Wildfly or TomEE which are built on top of tomcat. Or, change to a complete different Java EE implementation like GlassFish.
Another option may be if you deploy directly into Tomcat. Eclipse by default deploys on a different folder and use some kind of bypass to see it deployed on Tomcat. Follow these steps:
In your Eclipse, go to the Servers view (if it's not visible in the IDE, go to Window/Show view/Servers), it will show you your tomcat server (and others), double click on it.
In the Tomcat overview window, check the Server locations panel, expand it and check where the webapp is deployed.
If selected option is Use Tomcat installation then the web app must be in <tomcat>/webapps. If not, make sure to select this option and the application will be directly deployed on Tomcat folder.
For Tomcat Version 6
In project, .settings folder OR Or CTRL+SHIFT+R :
find this file
org.eclipse.wst.common.project.facet.core.xml
change the version of facet=jst.web to 2.4 or 2.5
File : org.eclipse.wst.common.project.facet.core.xml
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="jst.java"/>
<fixed facet="jst.web"/>
<installed facet="jst.web" version="2.4"/>
<installed facet="jst.java" version="6.0"/>
</faceted-project>
Tomcat 7
You need facet="jst.web" version="3.0" to deploy on Tomcat 7.
To Solve this Issue
You will have to update your Dynamic Web Module version from 3.1 to 3.0.
Eclipse dosen't allow these updation directly via Build Path-->Configure Build Path-->Project Facets.
Follow these steps
Open file : YourPrjectFolder/.setting/org.eclipse.wst.common.project.facet.core
In project folder, goto .settings folder.
Open org.eclipse.wst.common.project.facet.core XML document.
Edit line <installed facet="jst.web" version="3.1"/> to <installed facet="jst.web" version="3.0"/>
Save the changes.
Goto Eclipse and refresh the project.
You will be able to publish the your project now on Tomcat 7.
1)Go to your project on folder in eclipse workspace.
2)Open the .setting folder
3)Open the "org.eclipse.wst.common.project.facet.core" xml file
4)Update the version in last line as 2.4 or 2.5
5)Refresh the project and try to run on server
This problem can be resolved by by changing the Dynamic Web Module version to 3.0. This can be done in 2 ways.
Goto project properties and click on project facets, now you see the option Dynamic Web Module, change it to 3.0
For those who can't change the version in the above step, open org.eclipse.wst.common.project.facet.core.xml and change the version here to something like <installed facet="jst.web" version="3.0"/>
Now go to project facets and see the Dynamic Web Module version changed to 3.0
I thought I'd add something to this question as I tried all of the above and ended up doing something different to fix my issue of:
Tomcat version 7.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 and 6 Web modules
which then also led to
Cannot change version of project facet Dynamic Web Module to version 3.0
In our project we are using Maven to build a Java 1.8 / Tomcat 8.5 application (which only supports Dynamic Web Module Version 3.0 - not 4.0)
Someone in our team made the following change in our parent pom.xml
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.0</version>
<scope>provided</scope>
</dependency>
The version had been moved from 3.0.1 to 4.0.0 and no-matter how many times I tried to manually overwrite org.eclipse.wst.common.project.facet.core.xml with the right version <installed facet="jst.web" version="3.0"/> a Maven update re-over-wrote it with 4.0.
I set the version back to 3.0.1 as shown below and since then my Project Facets are showing the correct version, my apps are deploying to my internal Tomcat Server and to to this day, no-one is owning up to making the update to version 4.0.0 :)
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
For Tomcat 8.5 if you are facing this issue, change your facet setting to 3.1
Open file : {project_Folder}/.setting/org.eclipse.wst.common.project.facet.core
Open org.eclipse.wst.common.project.facet.core XML file.
Change to version as 3.1
Save and refresh the project you will find it you can add the resource to tomcat.
This worked for me.. Thanks

JSF 2.0 project Structure

We are creating a new project using jsf2.0, richfaces 4.0, jjdk 6 and tomcat 7.0
I want to know the standard way of creating project. I mean folder structure. Any sample application or book or link will be a great help to me.
Maven uses a best practice approach for project folders. Even when you do not plan to build with maven, have a look at their structures:
Maven: Introduction to the Standard Directory Layout
I participated once in a project, which had Spring 3.5, JSF 1.2 and ICEFaces 1.8, was running on JDK6 and everything was deployed to Tomcat 6.0 - similar situation to yours. We used Apache Maven as a project management tool.
Very flexible and comfortable. You could also consider using ICEFaces instead of RichFaces.

Categories

Resources