首页 > 解决方案 > 我不断收到有关 IntelliJ 中 ActiveJDBC 检测的错误消息

问题描述

我正在学习一些 Java 和 Cucumber,并试图让 MySQL 工作。我正在遵循课程书中的代码。这一切似乎都很简单,但我就是无法让它发挥作用。我不断收到错误:org.javalite.activejdbc.DBException:无法确定模型类名称,您确定模型已被检测吗?. 我确实尝试了许多不同帖子的每一个建议。我知道你们都会说在最后一次编译后它没有被检测过,但是对于我的生活,我无法弄清楚为什么或是什么导致了它。

无论我如何运行它,我都会遇到同样的错误。请,请帮助我,这让我发疯。我将使用 Maven 验证作为示例:

聚甲醛:


<plugin>
                <groupId>org.javalite</groupId>
                <artifactId>activejdbc-instrumentation</artifactId>
                <version>${activejdbc.version}</version>
                <executions>
                    <execution>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>instrument</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.liquibase</groupId>
                <artifactId>liquibase-maven-plugin</artifactId>
                <version>3.0.5</version>
                <configuration>
                    <changeLogFile>src/main/resources/bank_schema.xml</changeLogFile>
                    <driver>com.mysql.cj.jdbc.Driver</driver>
                    <url>jdbc:mysql://localhost/bank</url>
                    <username>teller</username>
                    <password>password</password>
                </configuration>
                <executions>
                    <execution>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>update</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

Java 代码:


package step_definitions.hooks;

//import cucumber.runtime.java.guice.ScenarioScoped;
//import io.cucumber.guice.ScenarioScoped;
import io.cucumber.java.Before;
import nicebank.Account;
import nicebank.TransactionQueue;
import org.javalite.activejdbc.Base;

//@ScenarioScoped
public class HooksReset {
    @Before(order = 1)
    public void reset() {
        if (!Base.hasConnection()) {
            Base.open(
                    "com.mysql.cj.jdbc.Driver",
                    "jdbc:mysql://localhost/bank",
                    "teller", "password");
        }
        System.out.println("[HooksReset] > @Before > reset() > Has Connection: " + Base.hasConnection() );
        Account.deleteAll();
        TransactionQueue.clear();
    }
}

只是更新以删除图像。

Maven 验证 - 编译消息:

在我的项目 ATM_DI[verify] 的运行窗口中 -

编译:

[INFO] 
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ ATM_DI ---
[INFO] Nothing to compile - all classes are up to date

乐器:

(它似乎已经这样做了两次 - 不确定这是否正确。可能是我在试图让仪器在每一个可能的时刻运行!)

[INFO] 
[INFO] --- activejdbc-instrumentation:1.4.1:instrument (default) @ ATM_DI ---
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.javalite.instrumentation.ActiveJdbcInstrumentationPlugin (file:/C:/Users/user/.m2/repository/org/javalite/activejdbc-instrumentation/1.4.1/activejdbc-instrumentation-1.4.1.jar) to method java.net.URLClassLoader.addURL(java.net.URL)
WARNING: Please consider reporting this to the maintainers of org.javalite.instrumentation.ActiveJdbcInstrumentationPlugin
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
**************************** START INSTRUMENTATION ****************************
Directory: C:\Workspace\Rob Java Stuff\Cucumber For Java\ATM_DI\target\classes
Found model: nicebank.Account
Instrumented class: nicebank.Account in directory: /C:/Workspace/Rob%20Java%20Stuff/Cucumber%20For%20Java/ATM_DI/target/classes/
**************************** END INSTRUMENTATION ****************************
**************************** START INSTRUMENTATION ****************************
Directory: C:\Workspace\Rob Java Stuff\Cucumber For Java\ATM_DI\target\test-classes
Found model: support.TestAccount
Instrumented class: support.TestAccount in directory: /C:/Workspace/Rob%20Java%20Stuff/Cucumber%20For%20Java/ATM_DI/target/test-classes/
**************************** END INSTRUMENTATION ****************************

测试编译:

[INFO] 
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ ATM_DI ---
[INFO] Nothing to compile - all classes are up to date

测试:

[INFO] 
[INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) @ ATM_DI ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestRunner
Scenario Outline: Successful withdrawal from an account in credit # src/test/resources/features/cash-withdrawal-outline-test.feature:11
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
1613635294139   geckodriver INFO    Listening on 127.0.0.1:48824
1613635295410   mozrunner::runner   INFO    Running command: "C:\\Program Files (x86)\\[HooksReset] > @Before > reset() > Has Connection: true
  org.javalite.activejdbc.DBException: failed to determine Model class name, are you sure models have been instrumented?
    at org.javalite.activejdbc.Model$ClassGetter.getClassName(Model.java:2214)
    at org.javalite.activejdbc.Model.getClassName(Model.java:2187)
    at org.javalite.activejdbc.Model.getDaClass(Model.java:2179)
    at org.javalite.activejdbc.Model.getMetaModel(Model.java:58)
    at org.javalite.activejdbc.Model.deleteAll(Model.java:548)
    at step_definitions.hooks.HooksReset.reset(HooksReset.java:42)
Caused by: org.javalite.activejdbc.InitException: failed to determine Model class name, are you sure models have been instrumented?
    at org.javalite.activejdbc.Model$ClassGetter.getClassName(Model.java:2214)
    at org.javalite.activejdbc.Model.getClassName(Model.java:2187)
    at org.javalite.activejdbc.Model.getDaClass(Model.java:2179)
    at org.javalite.activejdbc.Model.getMetaModel(Model.java:58)
    at org.javalite.activejdbc.Model.deleteAll(Model.java:548)
    at step_definitions.hooks.HooksReset.reset(HooksReset.java:42)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at io.cucumber.java.Invoker.doInvoke(Invoker.java:66)
    at io.cucumber.java.Invoker.invoke(Invoker.java:24)
    at io.cucumber.java.AbstractGlueDefinition.invokeMethod(AbstractGlueDefinition.java:44)
    at io.cucumber.java.JavaHookDefinition.execute(JavaHookDefinition.java:59)
    at io.cucumber.core.runner.CoreHookDefinition.execute(CoreHookDefinition.java:44)
    at io.cucumber.core.runner.HookDefinitionMatch.runStep(HookDefinitionMatch.java:21)
    at io.cucumber.core.runner.TestStep.executeStep(TestStep.java:92)
    at io.cucumber.core.runner.TestStep.run(TestStep.java:63)
    at io.cucumber.core.runner.TestCase.run(TestCase.java:94)
    at io.cucumber.core.runner.Runner.runPickle(Runner.java:71)
    at io.cucumber.junit.PickleRunners$NoStepDescriptions.run(PickleRunners.java:140)
    at io.cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:118)
    at io.cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:24)
    at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
    at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
    at io.cucumber.junit.Cucumber.runChild(Cucumber.java:192)
    at io.cucumber.junit.Cucumber.runChild(Cucumber.java:88)
    at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
    at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
    at io.cucumber.junit.Cucumber$RunCucumber.evaluate(Cucumber.java:227)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:364)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:272)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:237)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:158)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:428)
    at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
    at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:562)
Mozilla Firefox\\firefox.exe" "--marionette" "-foreground" "-no-remote" "-profile" "C:\\Users\\user\\AppData\\Local\\Temp\\rust_mozprofilexDiqjt"
Can't find symbol 'eglSwapBuffersWithDamageEXT'.
Can't find symbol 'eglSetDamageRegionKHR'.
JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory.
console.warn: SearchSettings: "get: No settings file exists, new profile?" (new Error("", "(unknown module)"))
1613635305871   Marionette  INFO    Listening on port 51762
1613635306694   Marionette  WARN    TLS certificate errors will be ignored for this session
Feb 18, 2021 8:01:47 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
1613635308204   Marionette  INFO    Stopped listening on port 51762
JavaScript error: resource://activity-stream/lib/ActivityStreamPrefs.jsm, line 27: NS_ERROR_ILLEGAL_VALUE: Component returned f at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:548)
[HooksBackgroundProcess] > [@Before] > [startBackgroundThread()] >: 1. About to start Hook.
[HooksBackgroundProcess] > [@Before] > [startBackgroundThread()] > [run()] >: 1a. About to create new TransactionProcessor called (processor).
[HooksBackgroundProcess] > [@Before] > [startBackgroundThread()] > [run()] >: 1b. about to start - processor.process()
[Account] > Account() > 1. before setInteger()
1************** [TransactionProcessor] > process() -> 1b. Base.open - Account Table Count: 0
[Account] > Account() > 2. after setInteger() -> Account Count: 0, Account Table name : accounts, Account first record :null
========================= [AtmServer] > [constructor] > Servlet's added
========================= [AtmServer] > [start] > Listening on http://192.168.0.9:8887/
  Given my savings account has been credited 100.00   # step_definitions.AccountSteps.myAccountHasBeenCredited(java.lang.String,nicebank.Money)
  When I withdraw 20  # step_definitions.TellerSteps.iWithdraw(int)
  Then 20 should be dispensed # step_definitions.CashSlotSteps.shouldBeDispensed(int)
  And the balance of my savings account should be 80.00   # step_definitions.AccountSteps.theBalanceOfMyAccountShouldBe(java.lang.String,nicebank.Money)
*********** [WebDriverHooks] > [@After] > [finish]: Take screen shot
Embedding Out_WebDriverHooks [image/png 4990 bytes]
ailure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIPrefBranch.removeObserver]
JavaScript error: resource://gre/modules/UrlClassifierListManager.jsm, line 691: TypeError: this.tablesData[table] is undefined
[Parent 10364, Gecko_IOThread] WARNING: file /builds/worker/checkouts/gecko/ipc/chromium/src/base/process_util_win.cc:166
JavaScript error: resource://activity-stream/lib/PlacesFeed.jsm, line 200: NS_ERROR_XPC_GS_RETURNED_FAILURE: ServiceManager::GetService returned failure code:
JavaScript error: resource://gre/modules/ExtensionSettingsStore.jsm, line 123: Error: The ExtensionSettingsStore was accessed before the initialize promise resolved.
*** UTM:SVC TimerManager:registerTimer called after profile-before-change notification. Ignoring timer registration for id: rs-experiment-loader-timer
console.log: "RemoteSettingsWorker error: Error: Can't import when we've started shutting down."
console.error: "Could not load engine google@search.mozilla.org: [Exception... \"AddonManager is not initialized\"  nsresult: \"0xc1f30001 (NS_ERROR_NOT_INITIALIZED)\"  location: \"JS frame :: resource://gre/modules/AddonManager.jsm :: installBuiltinAddon :: line 2550\"  data: no]"
console.error: "Could not load engine amazon@search.mozilla.org: [Exception... \"AddonManager is not initialized\"  nsresult: \"0xc1f30001 (NS_ERROR_NOT_INITIALIZED)\"  location: \"JS frame :: resource://gre/modules/AddonManager.jsm :: installBuiltinAddon :: line 2550\"  data: no]"
console.error: "Could not load engine ddg@search.mozilla.org: [Exception... \"AddonManager is not initialized\"  nsresult: \"0xc1f30001 (NS_ERROR_NOT_INITIALIZED)\"  location: \"JS frame :: resource://gre/modules/AddonManager.jsm :: installBuiltinAddon :: line 2550\"  data: no]"
console.error: "Could not load engine bing@search.mozilla.org: [Exception... \"AddonManager is not initialized\"  nsresult: \"0xc1f30001 (NS_ERROR_NOT_INITIALIZED)\"  location: \"JS frame :: resource://gre/modules/AddonManager.jsm :: installBuiltinAddon :: line 2550\"  data: no]"
console.error: "Could not load engine wikipedia@search.mozilla.org: [Exception... \"AddonManager is not initialized\"  nsresult: \"0xc1f30001 (NS_ERROR_NOT_INITIALIZED)\"  location: \"JS frame :: resource://gre/modules/AddonManager.jsm :: installBuiltinAddon :: line 2550\"  data: no]"
console.error: "Could not load engine ebay@search.mozilla.org: [Exception... \"AddonManager is not initialized\"  nsresult: \"0xc1f30001 (NS_ERROR_NOT_INITIALIZED)\"  location: \"JS frame :: resource://gre/modules/AddonManager.jsm :: installBuiltinAddon :: line 2550\"  data: no]"
console.error: "Could not load engine chambers-en-GB@search.mozilla.org: [Exception... \"AddonManager is not initialized\"  nsresult: \"0xc1f30001 (NS_ERROR_NOT_INITIALIZED)\"  location: \"JS frame :: resource://gre/modules/AddonManager.jsm :: installBuiltinAddon :: line 2550\"  data: no]"
console.warn: SearchService: "_init: abandoning init due to shutting down"
JavaScript error: resource://gre/modules/AsyncShutdown.jsm, line 554: uncaught exception: 2147500036
JavaScript error: resource://gre/modules/AsyncShutdown.jsm, line 554: uncaught exception: 2147500036
JavaScript error: resource://gre/modules/AsyncShutdown.jsm, line 554: uncaught exception: 2147500036
JavaScript error: resource://gre/modules/AsyncShutdown.jsm, line 554: uncaught exception: 2147500036
JavaScript error: resource://gre/modules/AsyncShutdown.jsm, line 554: uncaught exception: 2147500036
console.log: "RemoteSettingsWorker error: Error: Can't import when we've started shutting down."
console.log: "RemoteSettingsWorker error: Error: Can't import when we've started shutting down."
###!!! [Child][RunMessage] Error: Channel closing: too late to send/recv, messages will be lost
JavaScript error: resource://gre/modules/osfile/osfile_async_front.jsm, line 426: Error: OS.File has been shut down. Rejecting post to stat
*********** [ServerHooks] > [@After] > [afterRunningScenario] >: Just finished running scenario: FAILED
========================= [AtmServer] > [stop] > Listening on null
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 96.36 s <<< FAILURE! - in TestRunner
[ERROR] Feature - Cash Withdrawal.Successful withdrawal from an account in credit  Time elapsed: 94.115 s  <<< ERROR!
org.javalite.activejdbc.DBException: failed to determine Model class name, are you sure models have been instrumented?
Caused by: org.javalite.activejdbc.InitException: failed to determine Model class name, are you sure models have been instrumented?
[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR]   failed to determine Model class name, are you sure models have been instrumented?
[INFO] 
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
[INFO] 
[ERROR] There are test failures.
Please refer to C:\Workspace\Rob Java Stuff\Cucumber For Java\ATM_DI\target\surefire-reports for the individual test results.
Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.

非常感谢

标签: javamysqlmavenactivejdbcjavalite

解决方案


你的问题之前已经回答过很多次了。尽管如此,此文档页面:https ://javalite.io/instrumentation将指导您摆脱此错误。它甚至有一个简短的视频,将指导您完成 IntelliJ 中的过程。


推荐阅读