JavaEE Websphere Liberty 没有根资源匹配请求 & 没有有效的 jdbcDriver

JavaEE Websphere Liberty No root resource matching request & No valid jdbcDriver

我需要你的帮助...这让我发疯,我尝试将一个非常简单的应用程序部署到 websphere liberty 16.0.0.2 服务器上。我的第一个大问题,其余api无法调用。报错:No root resource matching request path /admin-web-1.0-SNAPSHOT/api/account has been found, Relative Path: /api/account.

代码: AppREST

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
import java.util.HashSet;
import java.util.Set;

@ApplicationPath("api")
     public class AppREST extends Application {

     public Set<Class<?>> getClasses() {
         Set<Class<?>> resources = new HashSet<Class<?>>();
         resources.add(AccountREST.class);
         resources.add(GroupREST.class);
         return resources;
     }
}

帐户休息

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.inject.Inject;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import java.util.List;

@ManagedBean
@RequestScoped
@Path("/account")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public class AccountREST {

@Inject
private AccountFacade accountFacade;

@POST
public void createAccount(AccountRequest accountRequest){

}

@GET
public List<AccountRequest> getAccountRequests() {
    return accountFacade.getAccountRequests();
}

GroupREST 与 AccountREST 几乎相同。 web.xml 是:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
      http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
     version="3.0">
<module-name>admin-web</module-name>
<display-name>Eportal Registration Admin</display-name>

</web-app>

POM 文件包含以下依赖项:

<dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>eportal.registration.admin</groupId>
        <artifactId>admin-models</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>eportal.registration.admin</groupId>
        <artifactId>admin-usecases</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>eportal.registration.admin</groupId>
        <artifactId>admin-models</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>eportal.registration.admin</groupId>
        <artifactId>admin-repositories</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
</dependencies>

我真的看不出我差点从一个工作项目中复制过去的错误:(

现在是 JDBC 驱动器的第二个问题。我从 Maven Central 下载了 mysql-connector-java-6.0.3.jar。并将其添加到 server.xml:

<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">

<!-- Enable features -->
<featureManager>
    <feature>javaee-7.0</feature>
</featureManager>
<httpEndpoint id="defaultHttpEndpoint"
              httpPort="9080" />

<applicationManager autoExpand="true"/>

<dataSource id="RegistrationAdminDB" jndiName="jdbc/RegistrationAdminDB">
    <jdbcDriver libraryRef="MySQLLib"/>
    <properties databaseName="REGISTRATIONADMINDB" serverName="localhost" portNumber="3306"/>
</dataSource>

<library id="MySQLLib">
    <fileset dir="/opt/ibm/wlp/clients/mysql-connector-java-6.0.3.jar"/>
</library>
</server>

获取错误

java.lang.RuntimeException: java.sql.SQLNonTransientException: DSRA4000E: A valid JDBC driver implementation class was not found for the jdbcDriver dataSource[RegistrationAdminDB]/jdbcDriver[default-0] using the library MySQLLib. []
at com.ibm.ws.resource.internal.ResourceFactoryTrackerData.getService(ResourceFactoryTrackerData.java:113)

启动时。

好吧,我找不到错误,但不幸的是没有任何效果:( 感谢您的帮助!

在您的 server.xml 中,您有一个 <fileset dir="..."/> 指向文件而不是目录。

为您的 <library> 配置尝试以下操作:

<library id="MySQLLib">
    <fileset dir="/opt/ibm/wlp/clients"/>
</library>

对于您的第一个问题,如果您将 war 文件复制到 dropins 文件夹,liberty 是否会成功部署该应用程序?如果部署成功,它通常会提供您的 URL/port 和您的应用程序已启动的上下文根。

对于第二个问题,您是否尝试过按照此处的步骤操作? Configuring MySQL Driver in Liberty

  1. 将 MySQL JDBC 驱动程序 JAR 文件添加到 $LIBERTY_HOME/wlp/usr/shared/resources/mysql。如果该目录不存在,请创建它。

  2. 在$LIBERTY_HOME/usr/servers/worklightServer/server.xml文件中配置数据源(此路径中worklightServer可替换为你的服务器名称)如下:

<library id="MySQLLib"> <fileset dir="${shared.resource.dir}/mysql" includes="*.jar"/> </library>