Marcel Marino
Marcel Marino

Reputation: 1002

Apache Shiro JDBC Connection Issue

I am attempting to connect to a database to start a baseline user authentication program. I was able to use the shiro.ini to get user roles, but I'm getting an error when trying to run the program using a JDBC connection. I have tried using both the Microsoft sqljdbc42.jar and the jTDS jar file as well, with no difference in the result. Either way I get the following error:

[ERROR] No plugin found for prefix 'java' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\mainuser.m2\repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]

I've seen a couple of different troubleshooting questions for "No plugin found for prefix" but none for 'java', so I'm at a loss as to how to proceed.

Here is my Shiro.ini file, using the jTDS jar:

[main]
ds = net.sourceforge.jtds.jdbcx.JtdsDataSource
ds.serverName = SQL5
ds.user = myUser
ds.password = myPassword
ds.databaseName = myDatabase

jdbcRealm = org.apache.shiro.realm.jdbc.JdbcRealm
jdbcRealm.dataSource = $ds
jdbcRealm.permissionsLookupEnabled = true
jdbcRealm.authenticationQuery = "SELECT pswd FROM Users     WHERE user = ?"
jdbcRealm.userRolesQuery = "SELECT role FROM Role WHERE user = jdbcRealm.permissionsQuery = "SELECT perm FROM Person WHERE user = ?"

Here is my pom.xml file, using the jTDS jar:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.shiro.tutorials</groupId>
<artifactId>shiro-tutorial</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>First Apache Shiro Application</name>
<packaging>jar</packaging>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
                <encoding>${project.build.sourceEncoding}</encoding>
            </configuration>
        </plugin>

    <!-- This plugin is only to test run our little application.  It is not
         needed in most Shiro-enabled applications: -->
               <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.1</version>
    </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>net.sourceforge.jtds</groupId>
        <artifactId>jtds</artifactId>
        <version>1.3.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.shiro</groupId>
        <artifactId>shiro-core</artifactId>
        <version>1.1.0</version>
    </dependency>
    <!-- Shiro uses SLF4J for logging.  We'll use the 'simple' binding
         in this example app.  See http://www.slf4j.org for more info. -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.6.1</version>
        <scope>test</scope>
    </dependency>
</dependencies>

Upvotes: 0

Views: 141

Answers (1)

Brian Demers
Brian Demers

Reputation: 2080

The prefix for exec-maven-plugin is exec, so you would use: mvn exec:java. But take note, you must also set the mainClass to allow for this to work.

Upvotes: 1

Related Questions