jetty - JNDI not working in JUnit after upgrading Wicket from 6.20 to 7.0 -
i decided upgrade recent wicket project 6.20 7.0. quite smooth main code, had problem setup code jndi in junit environment. using :
try { // create , bind jndi resource database connection initialcontext ic = new initialcontext(); ic.createsubcontext("java:comp/env"); ic.createsubcontext("java:comp/env/jdbc"); sqlserverconnectionpooldatasource ds = new sqlserverconnectionpooldatasource(); ds.seturl("jdbc:sqlserver://localhost:1433;databasename=myproject;username=myuser;password=mypassword"); ic.bind("java:comp/env/jdbc/myproject", ds); } catch (exception e) { e.printstacktrace(); }
this worked fine wicket 6.20, throws javax.naming.noinitialcontextexception
on call createsubcontext().
after fruitless experimentation, key information in http://www.eclipse.org/jetty/documentation/current/jndi-embedded.html.
with change jetty 7 jetty 9 between wicket 6.20 , 7.0, jetty-all-server jar no longer available, wicket-quickstart-archetype depends on individual jars. these it's necessary add dependency jetty-plus (which in turn loads jetty-jndi) in project's pom.xml :
<dependencies> ... <!-- jetty dependencies testing --> ... <dependency> <groupid>org.eclipse.jetty</groupid> <artifactid>jetty-plus</artifactid> <version>${jetty9.version}</version> <scope>test</scope> </dependency> </dependencies>
Comments
Post a Comment