vaadin / flow-crm-tutorial

Demo app for the Java Web App tutorial series
The Unlicense
172 stars 184 forks source link

this tutorial doesnt seem to run - gives "java: package com.vaadin.flow.component.page does not exist" #205

Closed nutmix closed 7 months ago

nutmix commented 8 months ago

Unfortunately, the readme is missing how to run this project.

I cloned the project then tried opening it in intellij, then hitting the "run" arrow next to main in com.example.application.Application.java, and get the following error:

/Users/simon/dev/tutorials/flow-crm-tutorial/src/main/java/com/example/application/Application.java:3:38 java: package com.vaadin.flow.component.page does not exist

If I try to do the following:

$ mvn package

I get the following errors:

[ERROR] Errors: [ERROR] LoginE2ETest.loginAsInvalidUserFails » ExceptionInInitializer [ERROR] LoginE2ETest.loginAsValidUserSucceeds » NoClassDefFound Could not initialize class com.vaadin.testbench.browser.BrowserExtension [INFO]

The live demo is also broken (cant login with user/userpass) at https://crm.demo.vaadin.com/

Using M1 Mac, osx 13.2.1, with Zulu java 17, mvn version 3.8.7

mcollovati commented 8 months ago

I downloaded the project, imported in IntelliJ IDEA, the "run" arrow in Application class and the application started normally without any error. In your case, it looks like IDEA has not correctly imported the project dependencies.

Did you try to reimport the Maven project, using the Maven panel or the project tree context menu Maven -> Reload project

I can confirm the lived demo is currently broken

nutmix commented 8 months ago

It could be intellij, its not the ultimate version. It usually auto imports projects as maven project when it sees the pom. I tried maven->reload project but get the same error when I try to run the main

I used File->New->Project from existing sources. There is no option to import a maven project as such - it auto detects it.

I have imported dozens of spring boot projects in the past and not had this issue.

It doesnt seem to run form the mvn command line either - so something is wrong.

Maybe its a maven version or java version incompatibility?

mcollovati commented 8 months ago

Can you please post the logs of the command line execution?

nutmix commented 8 months ago

ERROR] Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 60.955 s <<< FAILURE! - in com.example.application.it.LoginE2ETest [ERROR] com.example.application.it.LoginE2ETest.loginAsValidUserSucceeds Time elapsed: 0.002 s <<< ERROR! java.lang.NoClassDefFoundError: Could not initialize class com.vaadin.testbench.browser.BrowserExtension at com.vaadin.testbench.browser.MultipleBrowsersExtension$CapabilitiesTestTemplateInvocationContext.getAdditionalExtensions(MultipleBrowsersExtension.java:80) at org.junit.jupiter.engine.descriptor.TestTemplateInvocationTestDescriptor.populateNewExtensionRegistry(TestTemplateInvocationTestDescriptor.java:68) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:99) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:68) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$2(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:90) at org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService$ExclusiveTask.compute(ForkJoinPoolHierarchicalTestExecutorService.java:202) at java.base/java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:194) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.ExceptionInInitializerError [in thread "ForkJoinPool-1-worker-5"] at com.vaadin.pro.licensechecker.LicenseChecker.checkLicenseFromStaticBlock(LicenseChecker.java:82) at com.vaadin.testbench.TestBenchVersion.(TestBenchVersion.java:44) at com.vaadin.testbench.TestBench.(TestBench.java:34) at com.vaadin.testbench.browser.BrowserExtension.(BrowserExtension.java:51) ... 15 more

[ERROR] com.example.application.it.LoginE2ETest.loginAsInvalidUserFails Time elapsed: 0.002 s <<< ERROR! java.lang.ExceptionInInitializerError at com.vaadin.pro.licensechecker.LicenseChecker.checkLicenseFromStaticBlock(LicenseChecker.java:82) at com.vaadin.testbench.TestBenchVersion.(TestBenchVersion.java:44) at com.vaadin.testbench.TestBench.(TestBench.java:34) at com.vaadin.testbench.browser.BrowserExtension.(BrowserExtension.java:51) at com.vaadin.testbench.browser.MultipleBrowsersExtension$CapabilitiesTestTemplateInvocationContext.getAdditionalExtensions(MultipleBrowsersExtension.java:80) at org.junit.jupiter.engine.descriptor.TestTemplateInvocationTestDescriptor.populateNewExtensionRegistry(TestTemplateInvocationTestDescriptor.java:68) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:99) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:68) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$2(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:90) at org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService$ExclusiveTask.compute(ForkJoinPoolHierarchicalTestExecutorService.java:202) at java.base/java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:194) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) Caused by: com.vaadin.pro.licensechecker.LicenseException: Unable to validate the license, please check your internet connection. If you need to work offline then please go to https://vaadin.com/pro/validate-license?getOfflineKey=mid-5fb8148d-8f88468c to retrieve an offline key. For CI/CD build servers, you need to download a server license key, which can work offline to create production builds. You can download a server license key from https://vaadin.com/myaccount/licenses. For troubleshooting steps, see https://vaadin.com/licensing-faq-and-troubleshooting. at com.vaadin.pro.licensechecker.LicenseChecker.checkLicense(LicenseChecker.java:292) at com.vaadin.pro.licensechecker.LicenseChecker.checkLicense(LicenseChecker.java:226) at com.vaadin.pro.licensechecker.LicenseChecker.checkLicense(LicenseChecker.java:129) at com.vaadin.pro.licensechecker.LicenseChecker.checkLicense(LicenseChecker.java:104) at com.vaadin.pro.licensechecker.LicenseChecker.checkLicenseFromStaticBlock(LicenseChecker.java:80) ... 18 more

[INFO] [INFO] Results: [INFO] [ERROR] Errors: [ERROR] LoginE2ETest.loginAsInvalidUserFails » ExceptionInInitializer [ERROR] LoginE2ETest.loginAsValidUserSucceeds » NoClassDefFound Could not initialize class com.vaadin.testbench.browser.BrowserExtension [INFO] [ERROR] Tests run: 5, Failures: 0, Errors: 2, Skipped: 0

nutmix commented 8 months ago

I see its complaining about a licence key in the second exception.

I didnt see any instructions in the readme

mcollovati commented 8 months ago

Yes, the project uses Vaadin Testbench that is a commercial product

nutmix commented 8 months ago

So we cant run this tutorial without paying?

mcollovati commented 8 months ago

You can remove the LoginE2ETest class

mcollovati commented 8 months ago

or just skip tests with maven -DskipTests command line option

nutmix commented 8 months ago

ok, I deleted LoginE2ETest, and project now builds. how do I run it? I still cant run it in IDE though.

nutmix commented 8 months ago

This is what it looks like when imported as existing sources into intellij community edition:

image
mcollovati commented 8 months ago

This looks like an IDE problem failing to resolve maven dependencies. Any errors when you run the "Reload All Maven projects" from the maven panel that is usually on the right side of the IDE?

nutmix commented 8 months ago

"Reload all Maven projects: doesnt seem to help. Just pops up a "sync" window with no output. The build output still shows all the errors and missing dependencies. I have no idea what the profiles section is for - or why its showing adobe-public. I didnt set or select that.

image
nutmix commented 8 months ago

Interestingly, if I now do a "rebuild", I get an error about java 17. Maybe vaadin tutiral wont work with java 17 (the projects readme is missing information).

java: warning: source release 17 requires target release 17 Module flowcrmtutorial SDK 11 is not compatible with the source version 17. Upgrade Module SDK in project settings to 17 or higher. Open project settings.

Do I have to downgrade java to 8 or 11 to get this to work?

mcollovati commented 8 months ago

No, you have to use Java 17, but it looks like the project in IDEA is configured to use JDK 11. Check the project settings

mcollovati commented 8 months ago

Also the main.iml IDEA file in src/main/java looks weird

nutmix commented 8 months ago

When I imported the project, it asked what version of java I wanted to use, 11 or 17. I chose l7. I can remove the project, start again, and select 11.

mcollovati commented 8 months ago

You have to use 17, not 11

nutmix commented 8 months ago

Ok, I did the following:

  1. rm -rf of the flow-crm-tutorial dir.
  2. git clone https://github.com/vaadin/flow-crm-tutorial.git
  3. rm .../LoginE2ETest.java
  4. cd flow-crm-tutorial
  5. mvn package // how do I run it?
  6. In intellij, File -> open -> select flow-crm-tutorial. // trying open instead of import from existing source to see if it helps.
  7. This gives "Internal error (java.io.IOException): Cannot find IntelliJ IDEA project files at /Users/simon/dev/tutorials/flow-crm-tutorial"
  8. Build-> Build project.
  9. Now it runs ok, but login still fails (like the live demo).

Something in File->New->project from existing sources fails, tried this route 3 times. Opening as a directory instead of a project from intellij, then build, AFTER doing the external $mvn package, seems to do the trick.

Next problem is that you cant actually login with user/userpass, so cant see or use the app, and there is no user/pass in the readme.

image
mcollovati commented 8 months ago

Check the SecurityConfig.java code The credential in the codebase are user/password, they are not the same as in the online demo

nutmix commented 8 months ago

user and password works, thanks for the help!

mcollovati commented 8 months ago

@nutmix we already have a ticket for checking what's wrong with the online demo. Do you think this issue can be closed?

tarekoraby commented 8 months ago

README updated