0

i need your help ... it s getting me crazy, i try to deploy a very simple application on to a websphere liberty 16.0.0.2 server. My first big problem, the rest api cant be called. Getting the error: No root resource matching request path /admin-web-1.0-SNAPSHOT/api/account has been found, Relative Path: /api/account.

The Code: 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;
     }
}

AccountREST

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 is nearly the same to AccountREST. The web.xml is:

<?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>

The POM File includes this dependencies:

<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>

I really cant see the mistake i nearly copy past it from a working project :(

Now second Problem the JDBC Drive. I downloaded the mysql-connector-java-6.0.3.jar from maven central. And added it to the 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>

Getting the error

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$1.getService(ResourceFactoryTrackerData.java:113)

at startup.

Well i cant find the mistakes but unlucky nothing works :( Thanks for your help!

2 Answers2

1

For your first issue, does liberty successfully deploy the app if you copy the war file to the dropins folder? It will usually give the your URL/port and context root that your app has been started with if the deployment was successful.

With the second issue, have you tried following the steps here? Configuring MySQL Driver in Liberty

  1. Add the MySQL JDBC driver JAR file to $LIBERTY_HOME/wlp/usr/shared/resources/mysql. If that directory does not exist, create it.

  2. Configure the data source in the $LIBERTY_HOME/usr/servers/worklightServer/server.xml file (worklightServer may be replaced in this path by the name of your server) as follows:

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

Pete
  • 1,500
  • 2
  • 16
  • 33
  • Hey Thanks, lessons learned - Dont debug config after 12h work xD i deployed my app into the template folder -.- the code is totally fine, just didnt get updated. The newest mysql connector 6.x.x seems not to work - after changing my config and downgrading the connector it worked. Ty – Dario Lötscher Aug 02 '16 at 16:50
  • Haha, we've all been there mate ;) Glad it's working – Pete Aug 02 '16 at 22:59
0

In your server.xml you have a <fileset dir="..."/> that points to a file instead of a directory.

Try the following for your <library> configuration:

<library id="MySQLLib">
    <fileset dir="/opt/ibm/wlp/clients"/>
</library>
Andy Guibert
  • 41,446
  • 8
  • 38
  • 61