2

我使用码头 9.2.2.v20140723 作为服务器。我使用 jetty-maven-plugin,pom.xml 是这样的:

    <plugin>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>9.2.2.v20140723</version>
        <configuration>
            <systemProperties>
                <systemProperty>
                     <name>java.security.auth.login.config</name>
                     <value>props.conf</value>
                 </systemProperty>
            </systemProperties>
            <!-- <scanIntervalSeconds>3</scanIntervalSeconds> -->
            <connectors>
                <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
                    <port>8080</port>
                </connector>
                <connector implementation="org.eclipse.jetty.server.ssl.SslSocketConnector">
                    <port>8443</port>
                    <keystore>keystore.jks</keystore>
                    <keyPassword>password</keyPassword>
                    <password>password</password>
                    <needClientAuth>false</needClientAuth>
                    <wantClientAuth>false</wantClientAuth>
                </connector>
            </connectors>
        </configuration>
    </plugin>

jetty-env.xml 像这样:

  <Configure id="wac" class="org.eclipse.jetty.webapp.WebAppContext">
  <New id="myds" class="org.eclipse.jetty.plus.jndi.Resource">
     <Arg><Ref refid="wac"/></Arg>
     <Arg>jdbc/myds</Arg>
     <Arg>

        <New class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
           <Set name="Url">jdbc:mysql://localhost:3306/cp</Set>
           <Set name="User">root</Set>
           <Set name="Password">1234</Set>
        </New>
     </Arg>
 </New>
</Configure>

web.xml 像这样:

<resource-ref>
    <description>My DataSource Reference</description>
    <res-ref-name>jdbc/myds</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

当我这样登录时:

ctx = new LoginContext("props", new TestCallBackHandler(username, password));
ctx.login();

我得到错误:

javax.security.auth.login.LoginException: java.lang.IllegalStateException: javax.naming.NameNotFoundException; remaining name 'env/jdbc/myds'

但我可以像这样得到数据源:

InitialContext ctx = new InitialContext();
            DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/myds");
4

1 回答 1

0

Is the Vaadin problem, I changed the "@Push"

于 2015-08-28T09:41:04.747 回答