У меня есть локальный MS SQL Server 2017 (14.0.3006), который я хочу использовать в своем приложении Hibernate, которое я размещаю через Jetty. У меня было то же приложение, работающее с Oracle (которое работало хорошо), и теперь я пытаюсь использовать вместо него MS SQL. Поэтому у меня в jetty-env.xml
есть следующая конфигурация (я также пробовал довольно много вариантов, например этот , но все они выдавали одну и ту же ошибку):
<Arg>
<New class="net.sourceforge.jtds.jdbcx.JtdsDataSource">
<Set name="User">user</Set>
<Set name="Password">password</Set>
<Set name="DatabaseName">databaseName</Set>
<Set name="ServerName">LOCAL_COMPUTER_NAME\SQLEXPRESS</Set>
<Set name="PortNumber">1433</Set>
</New>
</Arg>
В моем pom.xml
У меня есть соответствующая зависимость:
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<version>1.3.1</version>
</dependency>
Это приводит к следующей ошибке:
Failure: net.sourceforge.jtds.jdbcx.JtdsDataSource
С предупреждением, показанным выше в журнале:
[WARNING] Config error at <New id="mydb" class="org.eclipse.jetty.plus.jndi.Resource"><Arg/><Arg>jdbc/mydb</Arg><Arg>
<New class="net.sourceforge.jtds.jdbcx.JtdsDataSource"><Set name="User">user</Set><Set name="Password">password</Set><Set name="DatabaseName">databaseName</Set><Set name="ServerName">LOCAL_COMPUTER_NAME\SQLEXPRESS</Set><Set name="PortNumber">1433</Set></New>
</Arg></New>
Что я делаю не так?
Это (упрощенное) содержание моего jetty-env.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure id="oracledb" class="org.eclipse.jetty.webapp.WebAppContext">
<New id="mydb" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg></Arg>
<Arg>jdbc/db</Arg>
<Arg>
<New class="net.sourceforge.jtds.jdbcx.JtdsDataSource">
<Set name="User">user</Set>
<Set name="Password">password</Set>
<Set name="DatabaseName">databaseName</Set>
<Set name="ServerName">LOCAL_COMPUTER_NAME\SQLEXPRESS</Set>
<Set name="PortNumber">1433</Set>
</New>
</Arg>
</New>
<New id="log4j.properties" class="org.eclipse.jetty.plus.jndi.EnvEntry">
<Arg>log4j.properties</Arg>
<Arg class="java.lang.String">C:/TMP/logs/conf/log4j.properties.xml</Arg>
</New>
<New id="servername" class="org.eclipse.jetty.plus.jndi.EnvEntry">
<Arg>servername</Arg>
<Arg class="java.lang.String">test123</Arg>
</New>
</Configure>
Я не могу показать весь оригинал jetty-env.xml
, так как содержит секретную информацию. Это похоже на трассировку стека:
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Application ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 505 resources
[INFO] Copying 14 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.0:compile (default-compile) @ Application ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 481 source files to C:\Path\Application\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ Application ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Path\Application\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.0:testCompile (default-testCompile) @ Application ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Path\Application\target\test-classes
[INFO]
[INFO] <<< jetty-maven-plugin:9.2.21.v20170120:run (default-cli) < test-compile @ Application <<<
[INFO]
[INFO]
[INFO] --- jetty-maven-plugin:9.2.21.v20170120:run (default-cli) @ Application ---
[INFO] Logging initialized @32640ms
[INFO] Configuring Jetty for project: Application
[INFO] Plugin classpath augmented with <scope>provided</scope> dependencies: [file:/C:/Users/User/.m2/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar, file:/C:/Users/User/.m2/repository/org/apache/tapestry/tapestry-javadoc/5.4.3/tapestry-javadoc-5.4.3.jar, file:/C:/Users/User/.m2/repository/com/oracle/jdbc/ojdbc7/12.1.0.2.0/ojdbc7-12.1.0.2.0.jar, file:/C:/Users/User/.m2/repository/com/db/websso-api/1.2.2/websso-api-1.2.2.jar]
[INFO] webAppSourceDirectory not set. Trying src\main\webapp
[INFO] Reload Mechanic: automatic
[INFO] Classes = C:\Path\Application\target\classes
[INFO] Configuring Jetty from xml configuration file = C:\Path\Application\target\classes\jetty-env.xml
[WARNING] Config error at <New id="mydb" class="org.eclipse.jetty.plus.jndi.Resource"><Arg/><Arg>jdbc/mydb</Arg><Arg>
<New class="net.sourceforge.jtds.jdbcx.JtdsDataSource"><Set name="User">user</Set><Set name="Password">password</Set><Set name="DatabaseName">databaseName</Set><Set name="ServerName">LOCAL_COMPUTER_NAME\SQLEXPRESS</Set><Set name="PortNumber">1433</Set></New>
</Arg></New>
[INFO] Jetty server exiting.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30.290 s
[INFO] Finished at: 2020-01-20T14:58:44+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.jetty:jetty-maven-plugin:9.2.21.v20170120:run (default-cli) on project Application: Failure: net.sourceforge.jtds.jdbcx.JtdsDataSource -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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/confluence/display/MAVEN/MojoExecutionException
Disconnected from the target VM, address: '127.0.0.1:49800', transport: 'socket'