Hey,
I'm developing a few webapps that use LDAP parameters as well as credentials to CRUD the LDAP servers. These parameters are placed on a server and accessed using JNDI.
However I want to be able to mock up the server in Jetty. I've been able to easily do this in Tomcat, all I needed was a context.xml file placed in META-INF, which gets picked up in Tomcat. This for example looks like this:
I start the server using Spring in a testcase that includes the startup and parameters of the Jetty container.Code:<Resource auth="Container" name="jndi/theapplication_resenv" type="...jndi.Config" factory="...jndi.ConfigFactory" LDAPHost="<anURL and Port>" LDAPBindDN="uid=...." LDAPPassword="<thepwd>" LDAPUserDn="<theudn>" baseUser="<thebaseuser>" ... />
I always get the error:Code:<bean id="server" class="org.mortbay.jetty.Server" init-method="start" destroy-method="stop"> <property name="connectors"> <list> <bean id="connector" class="org.mortbay.jetty.nio.SelectChannelConnector"> <property name="port" value="8080" /> </bean> </list> </property> <property name="handler"> <bean id="handlers" class="org.mortbay.jetty.handler.HandlerCollection"> <property name="handlers"> <list> <bean id="contexts" class="org.mortbay.jetty.handler.ContextHandlerCollection"> <property name="handlers"> <list> <bean class="org.mortbay.jetty.webapp.WebAppContext"> <property name="contextPath" value="/${jetty.contextPath}" /> <property name="war" value="src/main/webapp" /> <property name="configurationClasses"> <list> <value>org.mortbay.jetty.webapp.WebInfConfiguration</value> <value>org.mortbay.jetty.plus.webapp.EnvConfiguration</value> <value>org.mortbay.jetty.plus.webapp.Configuration</value> <value>org.mortbay.jetty.webapp.JettyWebXmlConfiguration</value> <value>org.mortbay.jetty.webapp.TagLibConfiguration</value> </list> </property> <property name="defaultsDescriptor" value="webservices/src/test/resources/jetty/web.xml"/> </bean> </list> </property> </bean> </list> </property> </bean> </property> </bean>
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
I'm unsure if it is either a problem in this context.xml and/or a config problem in Jetty and/or something else. I can't seem to find a lot about it on the net and most of the config i find is not done using Spring.
I run the testcase using:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/spring/applicationContext-test.xml"})
I'm not a huge JNDI expert, far from it. Any help is surely appreciated.


Reply With Quote