Oops. did not see Jan's answers in my mail client. Sorry for duplicate
posting.

On Fri, Aug 5, 2016 at 12:38 PM, Andreas Schöneck <[email protected]> wrote:

> Your XML is not correct. Seems you are missing the Arg around the New.
> Should read like:
>
> ...
> <Arg>
>   <New class="com.zaxxer.hikari.HikariDataSource">
>      ....
>   </New>
> </Arg>
> ...
>
> Check http://www.eclipse.org/jetty/documentation/9.4.x/
> jndi-datasource-examples.html for examples.
>
> On Thu, Aug 4, 2016 at 12:56 PM, Paul Römer <[email protected]> wrote:
>
>> Hi,
>>
>> I try to set up my databases via JNDI for our development environment
>> which emulates the productive configuration. I decided to configure the
>> embedded Jetty server that is used by the Maven Jetty plugin.
>> As I we have 3 webapps I would like to configure the datasources in the
>> server context. So I added a custom jetty.xml which I reference in Mavens
>> plugin configuration:
>>
>> <plugin>
>>                 <groupId>org.eclipse.jetty</groupId>
>>                 <artifactId>jetty-maven-plugin</artifactId>
>>                 <version>9.3.11.v20160721</version>
>>                 <configuration>
>>                                 <jettyXml>${basedir}/src/main/
>> etc/jetty.xml</jettyXml>
>>
>> Well, for easy stuff it works like expected and Jetty starts:
>>
>> <?xml version="1.0"?>
>> <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "
>> http://www.eclipse.org/jetty/configure.dtd";>
>>
>> <Configure id="Server" class="org.eclipse.jetty.server.Server">
>>         <Set name="stopTimeout">5000</Set>
>> </Configure>
>>
>> But if I add some more serious stuff it fails:
>>
>> <?xml version="1.0"?>
>> <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "
>> http://www.eclipse.org/jetty/configure.dtd";>
>>
>> <Configure id="Server" class="org.eclipse.jetty.server.Server">
>>         <Set name="stopTimeout">5000</Set>
>>         <New id="myds" class="org.eclipse.jetty.plus.jndi.Resource">
>>                 <Arg></Arg>
>>                 <Arg>jdbc/myds</Arg>
>>                 <New class="com.zaxxer.hikari.HikariDataSource">
>>                         <Arg>
>>                                 <New class="com.zaxxer.hikari.Hikar
>> iConfig">
>>                                         <Set
>> name="minimumPoolSize">5</Set>
>>                                         <Set
>> name="maximumPoolSize">20</Set>
>>                                         <Set
>> name="dataSourceClassName">com.mysql.jdbc.jdbc2.optional.Mys
>> qlDataSource</Set>
>>                                         <Set name="username">root</Set>
>>                                         <Set name="password">test</Set>
>>                                         <Call
>> name="addDataSourceProperty">
>>                                                 <Arg>url</Arg>
>>
>> <Arg>jdbc:mysql://localhost:3306/lportal</Arg>
>>                                         </Call>
>>                                 </New>
>>                         </Arg>
>>                 </New>
>>         </New>
>> </Configure>
>>
>>
>> Of course I added the mysql-connector and HikariCP as plugin dependencies:
>>
>> <plugin>
>>         <groupId>org.eclipse.jetty</groupId>
>>         <artifactId>jetty-maven-plugin</artifactId>
>>         <version>9.3.11.v20160721</version>
>>         <dependencies>
>>                 <dependency>
>>                         <groupId>com.zaxxer</groupId>
>>                         <artifactId>HikariCP</artifactId>
>>                         <version>2.4.6</version>
>>                 </dependency>
>>                 <dependency>
>>                         <groupId>mysql</groupId>
>>                         <artifactId>mysql-connector-java</artifactId>
>>                         <version>5.1.36</version>
>>                 </dependency>
>>                 <dependency>
>>                         <groupId>org.eclipse.jetty</groupId>
>>                         <artifactId>jetty-plus</artifactId>
>>                         <version>9.3.11.v20160721</version>
>>                 </dependency>
>>                 <dependency>
>>                         <groupId>org.eclipse.jetty</groupId>
>>                         <artifactId>jetty-jndi</artifactId>
>>                         <version>9.3.11.v20160721</version>
>>                 </dependency>
>>         </dependencies>
>>
>> But I still get:
>>
>> [INFO] --- jetty-maven-plugin:9.3.11.v20160721:run (default-cli) @
>> webpage-frontend ---
>> [INFO] Logging initialized @6888ms
>> [INFO] Configuring Jetty for project: Webpage frontend
>> [INFO] webAppSourceDirectory not set. Trying src/main/webapp
>> [INFO] Reload Mechanic: automatic
>> [INFO] Classes = /home/vaadin/repos/webpage/web
>> page-frontend/target/classes
>> [INFO] Configuring Jetty from xml configuration file =
>> /home/vaadin/repos/webpage/webpage-frontend/src/main/etc/jetty.xml
>> [WARNING] Config error at <New id="myds" class="org.eclipse.jetty.plus.
>> jndi.Resource"><Arg/><Arg>jdbc/myds</Arg><New
>> class="com.zaxxer.hikari.HikariDataSource"><Arg>
>>                                 <New 
>> class="com.zaxxer.hikari.HikariConfig"><Set
>> name="minimumPoolSize">5</Set><Set name="maximumPoolSize">20</Set><Set
>> name="dataSourceClassName">com.mysql.jdbc.jdbc2.optional.MysqlDataSource</Set><Set
>> name="username">root</Set><Set name="password">test</Set><Call
>> name="addDataSourceProperty"><Arg>url</Arg><Arg>jdbc:mysql:/
>> /localhost:3306/lportal</Arg></Call></New>
>>                         </Arg></New></New>
>> [INFO] Jetty server exiting.
>> [INFO] ------------------------------------------------------------
>> ------------
>> [INFO] BUILD FAILURE
>> [INFO] ------------------------------------------------------------
>> ------------
>> [INFO] Total time: 5.890 s
>> [INFO] Finished at: 2016-08-04T12:54:51+02:00
>> [INFO] Final Memory: 23M/263M
>> [INFO] ------------------------------------------------------------
>> ------------
>> [ERROR] Failed to execute goal 
>> org.eclipse.jetty:jetty-maven-plugin:9.3.11.v20160721:run
>> (default-cli) on project webpage-frontend: Failure:
>> InvocationTargetException: NullPointerException -> [Help 1]
>> org.apache.maven.lifecycle.LifecycleExecutionException: Failed to
>> execute goal org.eclipse.jetty:jetty-maven-plugin:9.3.11.v20160721:run
>> (default-cli) on project webpage-frontend: Failure
>>         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(Moj
>> oExecutor.java:212)
>>         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(Moj
>> oExecutor.java:153)
>>         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(Moj
>> oExecutor.java:145)
>>         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.b
>> uildProject(LifecycleModuleBuilder.java:116)
>>         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.b
>> uildProject(LifecycleModuleBuilder.java:80)
>>         at org.apache.maven.lifecycle.internal.builder.singlethreaded.S
>> ingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
>>         at org.apache.maven.lifecycle.internal.LifecycleStarter.execute
>> (LifecycleStarter.java:128)
>>         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
>>         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
>>         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
>>         at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
>>         at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
>>         at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
>>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce
>> ssorImpl.java:62)
>>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe
>> thodAccessorImpl.java:43)
>>         at java.lang.reflect.Method.invoke(Method.java:498)
>>         at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnha
>> nced(Launcher.java:289)
>>         at org.codehaus.plexus.classworlds.launcher.Launcher.launch(
>> Launcher.java:229)
>>         at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithEx
>> itCode(Launcher.java:415)
>>         at org.codehaus.plexus.classworlds.launcher.Launcher.main(
>> Launcher.java:356)
>> Caused by: org.apache.maven.plugin.MojoExecutionException: Failure
>>         at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty(
>> AbstractJettyMojo.java:488)
>>         at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.execute(
>> AbstractJettyMojo.java:328)
>>         at org.eclipse.jetty.maven.plugin.JettyRunMojo.execute(JettyRun
>> Mojo.java:170)
>>         at org.apache.maven.plugin.DefaultBuildPluginManager.executeMoj
>> o(DefaultBuildPluginManager.java:134)
>>         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(Moj
>> oExecutor.java:207)
>>         ... 20 more
>> Caused by: java.lang.reflect.InvocationTargetException
>>         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>> Method)
>>         at sun.reflect.NativeConstructorAccessorImpl.newInstance(Native
>> ConstructorAccessorImpl.java:62)
>>         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(De
>> legatingConstructorAccessorImpl.java:45)
>>         at java.lang.reflect.Constructor.newInstance(Constructor.java:4
>> 23)
>>         at org.eclipse.jetty.util.TypeUtil.construct(TypeUtil.java:580)
>>         at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration
>> .newObj(XmlConfiguration.java:787)
>>         at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration
>> .configure(XmlConfiguration.java:423)
>>         at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration
>> .configure(XmlConfiguration.java:358)
>>         at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfigur
>> ation.java:259)
>>         at org.eclipse.jetty.maven.plugin.ServerSupport.applyXmlConfigu
>> rations(ServerSupport.java:211)
>>         at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.applyJettyX
>> ml(AbstractJettyMojo.java:404)
>>         at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty(
>> AbstractJettyMojo.java:427)
>>         ... 24 more
>> Caused by: java.lang.NullPointerException
>>         at org.eclipse.jetty.plus.jndi.NamingEntry.save(NamingEntry.jav
>> a:191)
>>         at org.eclipse.jetty.plus.jndi.Resource.<init>(Resource.java:39)
>>         ... 36 more
>> [ERROR]
>> [ERROR] Re-run Maven using the -X switch to enable full debug logging.
>> [ERROR]
>> [ERROR] For more information about the errors and possible solutions,
>> please read the following articles:
>> [ERROR] [Help 1] http://cwiki.apache.org/conflu
>> ence/display/MAVEN/MojoExecutionException
>>
>> Any ideas?
>>
>> Cheers,
>>   Paul
>> _______________________________________________
>> jetty-users mailing list
>> [email protected]
>> To change your delivery options, retrieve your password, or unsubscribe
>> from this list, visit
>> https://dev.eclipse.org/mailman/listinfo/jetty-users
>>
>
>
_______________________________________________
jetty-users mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to