Som, we are not responsible for the Heroku archetypes, but that main class looks reasonable. With jetty-11, all that is necessary to enable JSPs is to put the jetty-jsp jar on the classpath and it will be discovered and available to the webapp.
On Fri, 2 Apr 2021 at 13:08, Som Lima <[email protected]> wrote: > Hi, > > using Heroku archetype jetty 11, > It appeared the jetty configurations may be different > when running mvn jetty:run compared to running > embedded jetty using the main class. (below) > That is to say I would need to add further programmatic configuration to > the embedded jetty. > > /** > * This class launches the web application in an embedded Jetty container. > * This is the entry point to your application. The Java > * command that is used for launching should fire this main method. > */ > public class Main { > > public static void main(String[] args) throws Exception{ > // The port that we should run on can be set into an environment > variable > // Look for that variable and default to 8080 if it isn't there. > String webPort = System.getenv("PORT"); > if (webPort == null || webPort.isEmpty()) { > webPort = "8080"; > } > > final Server server = new Server(Integer.valueOf(webPort)); > final WebAppContext root = new WebAppContext(); > > root.setContextPath("/"); > // Parent loader priority is a class loader setting that Jetty > accepts. > // By default Jetty will behave like most web containers in that > it will > // allow your application to replace non-server libraries that are > part of the > // container. Setting parent loader priority to true changes this > behavior. > // Read more here: > http://wiki.eclipse.org/Jetty/Reference/Jetty_Classloading > root.setParentLoaderPriority(true); > > final String webappDirLocation = "src/main/webapp/"; > root.setDescriptor(webappDirLocation + "/WEB-INF/web.xml"); > root.setResourceBase(webappDirLocation); > > server.setHandler(root); > > server.start(); > server.join(); > } > } > <http://www.backbutton.co.uk/> > > > On Thu, 1 Apr 2021, 22:14 Greg Wilkins, <[email protected]> wrote: > >> Som, >> >> Configuration.ClassList is from Jetty-9 and is no longer needed in Jetty >> 10 or 11. >> The Configuraition mechanism generally requires less classpath >> manipulation in 10 or 11, so I'd try just deleting that line. Do you know >> why you are trying to obtain a classlist ? >> >> Perhaps look for the corresponding example in the jetty 11 source code? >> >> >> On Tue, 30 Mar 2021 at 23:36, Som Lima <[email protected]> wrote: >> >>> I was hoping for some feedback on the error. >>> >>> Configuration.ClassList classlist = Configuration.ClassList >>> .setServerDefault(server); >>> >>> Multiple markers at this line >>> - ClassList cannot be resolved or is not a field >>> - Configuration.ClassList cannot be resolved to a >>> type >>> >>> I think was due to an incompatible server object. >>> >>> >>> Whether my guess was correct or not ? >>> >>> >>> >>> On Fri, 26 Mar 2021, 23:49 Som Lima, <[email protected]> wrote: >>> >>>> Problem version >>>> >>>> <groupId>org.apache.maven.plugins</groupId> >>>> <artifactId>maven-compiler-plugin</artifactId> >>>> <version>3.8.0</version> >>>> <inherited>true</inherited> >>>> <configuration> >>>> <source>11</source> >>>> <target>11</target> >>>> </configuration> >>>> >>>> >>>> <jetty.version>11.0.1</jetty.version> >>>> <http://www.backbutton.co.uk/> >>>> >>>> >>>> On Fri, 26 Mar 2021, 23:45 Som Lima, <[email protected]> wrote: >>>> >>>>> Now >>>>> <jetty.version>9.4.35.v20201120</jetty.version> >>>>> on >>>>> <maven.compiler.source>11</maven.compiler.source> >>>>> <maven.compiler.target>11</maven.compiler.target> >>>>> <http://www.backbutton.co.uk/> >>>>> >>>>> >>>>> On Fri, 26 Mar 2021, 23:40 Joakim Erdfelt, <[email protected]> wrote: >>>>> >>>>>> What version of Jetty are you using? >>>>>> >>>>>> Joakim Erdfelt / [email protected] >>>>>> >>>>>> >>>>>> On Fri, Mar 26, 2021 at 6:34 PM Som Lima <[email protected]> >>>>>> wrote: >>>>>> >>>>>>> Hi Thanks, >>>>>>> >>>>>>> I did try this Configuration.ClassList approach earlier but I was >>>>>>> getting an error " >>>>>>> Multiple markers at this line >>>>>>> - ClassList cannot be resolved or is not a field >>>>>>> - Configuration.ClassList cannot be resolved to a >>>>>>> type >>>>>>> >>>>>>> I think was due to an incompatible server object. >>>>>>> >>>>>>> I am working in another project now >>>>>>> this time I inserted the code , no eclipse IDE errors reported I >>>>>>> guess the server object is compatible. >>>>>>> My code looks like this but still I am missing JSP feature. Not sure >>>>>>> the syntax for that. >>>>>>> console error message" No JSP support. Check that JSP jars are in >>>>>>> lib/jsp and that the JSP option has been specified to start." >>>>>>> >>>>>>> >>>>>>> *I have these two dependencies in pom.xml* >>>>>>> >>>>>>> <dependency> >>>>>>> <groupId>org.eclipse.jetty</groupId> >>>>>>> <artifactId>apache-jsp</artifactId> >>>>>>> <version>${jetty.version}</version> >>>>>>> </dependency> >>>>>>> <dependency> >>>>>>> <groupId>jstl</groupId> >>>>>>> <artifactId>jstl</artifactId> >>>>>>> <version>1.2</version> >>>>>>> </dependency> >>>>>>> >>>>>>> >>>>>>> *This is what my code looks like but I don't think I have the jsp >>>>>>> configuration in either variations* >>>>>>> >>>>>>> >>>>>>> context.setBaseResource(Resource.newResource(webResourceBase)); >>>>>>> context.setConfigurations(new Configuration[] >>>>>>> { >>>>>>> new AnnotationConfiguration(), >>>>>>> new WebInfConfiguration(), >>>>>>> new WebXmlConfiguration(), >>>>>>> new MetaInfConfiguration(), >>>>>>> new FragmentConfiguration(), >>>>>>> new EnvConfiguration(), >>>>>>> new PlusConfiguration(), >>>>>>> new JettyWebXmlConfiguration() >>>>>>> }); >>>>>>> >>>>>>> // === setup jetty plus == >>>>>>> Configuration.ClassList classlist = Configuration.ClassList >>>>>>> .setServerDefault(server); >>>>>>> classlist.addAfter( >>>>>>> "org.eclipse.jetty.webapp.FragmentConfiguration", >>>>>>> "org.eclipse.jetty.plus.webapp.EnvConfiguration", >>>>>>> "org.eclipse.jetty.plus.webapp.PlusConfiguration"); >>>>>>> >>>>>>> classlist.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration", >>>>>>> "org.eclipse.jetty.annotations.AnnotationConfiguration"); >>>>>>> >>>>>>> context.setContextPath("/"); >>>>>>> >>>>>>> On Fri, 26 Mar 2021, 22:19 Joakim Erdfelt, <[email protected]> >>>>>>> wrote: >>>>>>> >>>>>>>> The order of that Configuration list is very important. >>>>>>>> >>>>>>>> It would be better to utilize the Server level component and just >>>>>>>> add the missing pieces you need. >>>>>>>> >>>>>>>> See: >>>>>>>> >>>>>>>> - >>>>>>>> >>>>>>>> https://github.com/eclipse/jetty.project/blob/jetty-9.4.38.v20210224/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java#L168-L177 >>>>>>>> - >>>>>>>> >>>>>>>> https://github.com/jetty-project/embedded-jetty-jsp/blob/4918be37b938fff9fada5910ca04c59d8969cc90/src/main/java/org/eclipse/jetty/demo/Main.java#L131-L136 >>>>>>>> >>>>>>>> >>>>>>>> // === setup jetty plus == >>>>>>>> Configuration.ClassList classlist = >>>>>>>> Configuration.ClassList.setServerDefault(server); >>>>>>>> >>>>>>>> // Add JNDI support >>>>>>>> classlist.addAfter( >>>>>>>> "org.eclipse.jetty.webapp.FragmentConfiguration", >>>>>>>> "org.eclipse.jetty.plus.webapp.EnvConfiguration", >>>>>>>> "org.eclipse.jetty.plus.webapp.PlusConfiguration"); >>>>>>>> >>>>>>>> // Add Annotation Scanning Support >>>>>>>> >>>>>>>> classlist.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration", >>>>>>>> >>>>>>>> "org.eclipse.jetty.annotations.AnnotationConfiguration"); >>>>>>>> >>>>>>>> Leave the existing Configurations in place, don't overwrite/replace >>>>>>>> the entire list like you are doing. >>>>>>>> There is no need to configure the WebAppContext directly. >>>>>>>> >>>>>>>> Joakim Erdfelt / [email protected] >>>>>>>> >>>>>>>> >>>>>>>> On Fri, Mar 26, 2021 at 4:42 PM Som Lima <[email protected]> >>>>>>>> wrote: >>>>>>>> >>>>>>>>> Hi, >>>>>>>>> >>>>>>>>> There appears to be a number of ways to configure annotations, jsp >>>>>>>>> support programmatically in the jetty embedded. i.e. >>>>>>>>> Configuration.ClassList. >>>>>>>>> >>>>>>>>> I have gone for this implementation. >>>>>>>>> Is there a one liner new class I can insert in this code to add >>>>>>>>> for JSP functionality followed by corresponding libraries in the >>>>>>>>> pom.xml ? >>>>>>>>> >>>>>>>>> context.setConfigurations(new Configuration[] >>>>>>>>> { >>>>>>>>> new AnnotationConfiguration(), >>>>>>>>> new WebInfConfiguration(), >>>>>>>>> new WebXmlConfiguration(), >>>>>>>>> new MetaInfConfiguration(), >>>>>>>>> new FragmentConfiguration(), >>>>>>>>> new EnvConfiguration(), >>>>>>>>> new PlusConfiguration(), >>>>>>>>> new JettyWebXmlConfiguration() >>>>>>>>> }); >>>>>>>>> <http://www.backbutton.co.uk/> >>>>>>>>> Regards >>>>>>>>> >>>>>>>>> >>>>>>>>> _______________________________________________ >>>>>>>>> jetty-users mailing list >>>>>>>>> [email protected] >>>>>>>>> To unsubscribe from this list, visit >>>>>>>>> https://www.eclipse.org/mailman/listinfo/jetty-users >>>>>>>>> >>>>>>>> _______________________________________________ >>>>>>>> jetty-users mailing list >>>>>>>> [email protected] >>>>>>>> To unsubscribe from this list, visit >>>>>>>> https://www.eclipse.org/mailman/listinfo/jetty-users >>>>>>>> >>>>>>> _______________________________________________ >>>>>>> jetty-users mailing list >>>>>>> [email protected] >>>>>>> To unsubscribe from this list, visit >>>>>>> https://www.eclipse.org/mailman/listinfo/jetty-users >>>>>>> >>>>>> _______________________________________________ >>>>>> jetty-users mailing list >>>>>> [email protected] >>>>>> To unsubscribe from this list, visit >>>>>> https://www.eclipse.org/mailman/listinfo/jetty-users >>>>>> >>>>> _______________________________________________ >>> jetty-users mailing list >>> [email protected] >>> To unsubscribe from this list, visit >>> https://www.eclipse.org/mailman/listinfo/jetty-users >>> >> >> >> -- >> Greg Wilkins <[email protected]> CTO http://webtide.com >> _______________________________________________ >> jetty-users mailing list >> [email protected] >> To unsubscribe from this list, visit >> https://www.eclipse.org/mailman/listinfo/jetty-users >> > _______________________________________________ > jetty-users mailing list > [email protected] > To unsubscribe from this list, visit > https://www.eclipse.org/mailman/listinfo/jetty-users > -- Greg Wilkins <[email protected]> CTO http://webtide.com
_______________________________________________ jetty-users mailing list [email protected] To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users
