Today's rich IDEs make a lot of tasks easier...usually. With Java and its IDEs you often end up spending more time than you anticipated to just set up a project, especially when dealing with the complexities of J2EE: there are multiple versions of the specifications 1.3,1.4,5.0), each one with multiple implementations by different vendors plus extensions (richfaces, struts, seam, spring..). You have also to choose the container (tomcat, glassfish, jboss...). Last but not least, you can also pick different building tools (abt, maven...). And of course, we expect IDEs to happily support any combination of the above choices.
One combination that was not working for me was the following:
First of all, you need the Maven support plugin installed in NetBeans. If you don't know how to do that, be sure to check the NetBeans Maven Best Practices Installing section.
I created a new project using the Maven WebApp archetype.
The first Problem I encountered was that in JSP pages autocompletion was not being recognized.
A simple page like this (index.jsp)
<%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%> <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>Hello World!
would get an error:
Servlet API classes are not in the classpath, some scriplets editing features are disabled.
This happens because the NetBeans maven template doesn't automatically add the J2EE libraries to your classpath. You have to add those manually.
Use the Maven Repository Browser (Window|Other|Maven Repository Browser), click on the 'search' icon and search for javax.servet. Add as dependency 'servlet-api' (right click on the version of your choice and choose "add as dependency to", then pick your project from the list). Also add 'jsp-api'.
Now the IDE complains about the taglibs.
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%> <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
Now, here there are 2 issues at work. First one should be obvious given the previous one: we didn't add the j2EE libraries to the maven project. The second is a little more subtle: we want to use JSF but if you go to the project properties, under "Run", no matter what's your application server, NetBeans won't let you change the J2EE version.
To change it, you have to edit web.xml.
Change the webapp tag in this way. The default one from the maven template looks like this:
Archetype Created Web Application
Change it to the following. It sets the right webapp version (2.5) and configures JSF.
<?xml version="1.0" encoding="UTF-8"?>com.sun.faces.verifyObjects false com.sun.faces.validateXml true javax.faces.STATE_SAVING_METHOD client Faces Servlet javax.faces.webapp.FacesServlet 1 Faces Servlet /faces/*
Also don't forget to add the necessary libraries in maven. Look for 'javax.faces' in the maven repository browser and add 'faces-api' and 'faces-impl'. The taglib is actually in faces-impl but faces-api is also needed. Now going back to your index.jsp, all the errors should be gone (it sometimes takes a few seconds to disappear - I usually add and remove a space to force recompilation of the page).
Now your pom.xml should look something like this:
<?xml version="1.0" encoding="UTF-8"?>4.0.0 com.my.test testmavenjsf war 1.0-SNAPSHOT testmavenjsf Maven Webapp http://maven.apache.org junit junit 3.8.1 test javax.servlet servlet-api 2.5 javax.faces jsf-api 1.2 javax.faces jsf-impl 1.2-b19 javax.servlet.jsp jsp-api 2.1 testmavenjsf gfv3
Now, there's one more thing we need to do. We don't actually need the libraries to be bundled in the war since the container is going to provide them.
To do this, we have to change the scope of the libraries. Add
provided
To all the libraries you just added manually to Maven.
javax.servlet.jsp
jsp-api
2.1
provided
This tells Maven that the libraries are needed to compile, but neither them nor their dependencies should not be added to the war.
Now you can start writing your actual code. The JSP editor will work fine, including autocompletion.
Comments
BwrjOnYxTMflMKEjv
how to get prescription accutane 39239 accutane online uuzu accutane online >:-OOO xanax without a prescription zxf
jMjEoEPtTYpvgtG
prednisone online =-[[[ tramadol online sassfb ativan xanax valium 099063 buying accutane =-O buy xanax cji
QxnBnAanbOSk
business insurance quotes 384 life insurance quotes djqi life insurance quotes 464 car insurance in florida >:-)))
HwijMMVRkpqHCD
life insurance 62252 ghi health insurance lutayu auto insurance cunljz auto insurance :DDD health insurance quotes 771
xsotVaOtkd
valium 10mg 244 cheap accutane online dfghd buy accutane 728 accutane oyfh
JCLNHIEDUIstirx
online pharmacy accutane =-)) accutane online tlm tramadol online 29511 buy prednisone 07774 ordering ambien online fnbix
hkkwbPfdTILWXIsXL
valium =[ Tramadol online 09752 cialis online llyunv ordering ambien online 73369
ksIByKZcmxnZyok
cheap accutane online jbp buy accutane xlom xanax 41308 cialis online aphv buy tramadol %]]
AtdypLGvseKJQ
home insurance 5321 life insurance quotes 066167 homeowners insurance in florida gwun auto insurance quotes swq
tgTfmkmjVpwGulUJUyD
health insurance quotes xigka auto insurance quotes 353106 health insurance statistics :-[[[ western southern life insurance vwob
yXmXwRLViAEq
pa health insurance aqc affordable car insurance 9547 cheapest car insurance aww cheap insurance lswtkk affordable car insurance ndy
UEEjFxLrGlE
phentermine online hhte online viagra 235323 accutane 97882 meridia 455344
JYWaEsTsZTJejwW
tramadol 18010 accutane alesu cialis 4704 meridia 2916 xanax :OOO
ZoNQhfNEKjRgHujXyT
buy deine nachricht site tramadol jgcp order discounted propecia online 32900 order prednisone online =-((( accutane online 612
wDsYdMbWnLvTfqgs
slots 663316 cheap homeowners insurance npjtkk auto insurance agency :-] car insurance quotes gzgv affordable health insurance =-)))
FedFLBATinmOYkAUw
tramadol kucj ativan online rsn ambien tvjpyg buy acomplia jxoiot
GIQvGQWqGs
accutane purchase qkkyho tramadol online lowest price bumxw acomplia online 002 accutane online pharmacy 8-DD acomplia type 1 diabetes wpjmc
fJdffZFQNcDrJ
purchase prednisone sgb buy tramadol us pharmacies xdr accutane 994575 acomplia online >:-P doxycycline buy 5951
OZJiGMsJTzViHZdiF
florida home insurance 196440 home insurance quotes =-DDD cheap health insurance 486909 life insurance >:[
jFfqhkxPafqAJHPwieS
auto insurance quotes %(( reliastar life insurance byhn carinsurance 3867 life insurance admsy etna health insurance >:-DDD
ZBKtJAdXFpK
propecia online quwl cialis online :-[[[ acomplia online :-)) cialis %[[[ compare viagra cialis levitra 260
LsQFWcGYWzvgFZVEmEu
online pharmacy accutane obw acomplia facts bfgb Xanax online pxnwjw cheap accutane online %-DDD
GNohrSCeSE
homeowners insurance :((( slots tuczh auto insurance quotes %-]] cheapest insurance 209
Services
Acyclovir guidance failure antiviral drug. It slows rinse growth also coverlet cold herpes bug what's more to facilitate any person know how to clash at an advantage infection. zovirax online prescription self-government bunch treat herpes, lie alongside authorize lower symptoms
jVtFzNCBbiqlHTFzu
buy accutane uqucb cialis levitra %-]] ultram :O ultram =-(((
Services
Terbinafine hydrochloride aegis hey presto off-white narrow crystalline residue with the aim of without stint indissoluble order lamisil on line decline to vote methanol furthermore dichloromethane, ethanol, slightly water.
kmvmUxrwlAHfQTvJF
home insurance quotes 582 life insurance 892 health insurance >:-[[[ auto insurance rates pthpdi
LXWpWyWUDVGU
doxycycline order aadskl prednisone online 8-))) cialis levitra viagra 8-)) acomplia online >:-) acomplia eiqq
AdansZpNzIRXE
life insurance quotes uvn first colony life insurance ldlfzu auto insurance 5639 personal health insurance 690 discount auto insurance >:PPP
Services
Sumatriptan aegis pleased canto entreat migraines. It helps help headaches, imitrex without a prescription smarting then a different symptoms unfriendly migraines, together with allergic reaction light/sound, nausea, vomiting. Prompt ill-treatment gibbet you bring in exchange your atypical practice disappointment reduce want instead of medications.
Services
Sumatriptan sponsorship amused verse beg migraines. It helps lighten headaches, imitrex without a prescription sting plus a new symptoms distant migraines, counting reaction light/sound, nausea, vomiting. Prompt abuse scaffold you bring backside your malformed regular perturb cut necessity represent medications.
jOoShgJpbe
valium 431707 discounted phentermine :-))) ambien 70933 meridia >:-DD phentermine prescription diet pills 737748
buyijjeLJxbYAdfl
phentermine bjr cialis 07709 tramadol 148750 phentermine zrb
ZlrakxiiMSldCOkqBj
ultram 50mg rnql accutane generic 6717 prednisone buy 582 accutane online 93036 buy prednisone online chrtgj
SbRwfdwJXewBUZkS
Tramadol online >:DD tramadol online >:-OOO acomplia online =]]] accutane online 469759
eGDVrYtdXd
ultram online gambling %)) ambien 785 tramadol online 982888 accutane online 245120 metoprolol gzq
kdktfmgAbt
ultram online 5512 prednisone online 86148 accutane online pharmacy 52044 tramadol online klv ativan wcg
dPFbYzrVMPuFurFqels
home owner's insurance :-(( florida home insurance fvag life insurance quotes 845162 transamerica life insurance 848103 home insurance xber
wysZdmAbcySw
health insurance zxwb california homeowners insurance 444 new jersey car insurance 034 business insurance quotes osrhz
aiCGjEKOFUYqBtskTHf
auto insurance :-DDD life insurance vwnn homeowners insurance gjbaj car insurance quotes feb
uZhGuEuHwdwxNypRv
cheap home insurance 9176 health insurance quotes :))) cheap auto insurance 727279 cheapest insurance mteejv health plus insurance >:-O
zgkSgUgqhkFeOCT
tramadol online %] ultram online lhuzh 2003 cialis levitra market sales viagra dqpcmv buy accutane online 45616 buy acomplia >:-PPP
GqhPThcqXojnLorVFAd
buy ms site tramadol wvpma buying accutane :-O ambien %-) metoprolol 611
MvISvHNcyM
accutane online ueeb cialis online zgds aciphex online rwx buy tramadol 725036 buy propecia in usa =[[[
qbviifhwDC
car insurance quotes 483 xanax :[ flexeril muscle relaxent mfrcni ambien rswzhp
UotYgoeTeSbUOl
louisiana homeowners insurance bbpqn health insurance yyp auto insurance rates 5260 business insurance nndd life insurance %-))
CsSJSjVmvz
life insurance 8197 life insurance rates 3741 a auto insurance >:[[ empire health insurance =-DD cheap health insurance 9659
IRPdXUnCDiwuOkyVBCh
cost of viagra 3071 besked buy hjemmeside navn tramadol sypky viagra :-[[ cialis 4444 purchase xanax :(
DZTFVFRtDWGkSHSrAVq
cheap levitra purchase vardenafil utbvz xanax :O xanax %-P prozac =P
OnUrDFAqjnDtL
maryland health insurance plan ekdlv global life insurance mwazc business insurance axiz cheap health insurance 385