JoyOfCodingPDX / JoyOfCoding

Source code for The Joy of Coding course at Portland State University taught by David Whitlock
http://web.cecs.pdx.edu/~whitlock/
Apache License 2.0
17 stars 5 forks source link

Koans archetype not working with empty Maven repository #171

Closed DavidWhitlock closed 8 years ago

DavidWhitlock commented 8 years ago

A student just emailed me and said that he got the following error while working with the koans:

$ mvn archetype:generate \
-DarchetypeCatalog=https://dl.bintray.com/davidwhitlock/maven/ \
-DarchetypeGroupId=edu.pdx.cs410J \
-DarchetypeArtifactId=java-koans-archetype \
-DarchetypeVersion=Summer2016 \
-DgroupId=edu.pdx.cs410J.rjr4 \
-DartifactId=koans \
-Dversion=1.0-SNAPSHOT

<snip>

Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Failure to find com.sandwich:koans-lib:jar:Summer2014 in https://dl.bintray.com/davidwhitlock/maven was cached in the local repository, resolution will not be reattempted until the update interval of CS410J has elapsed or updates are forced
    at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.newException(DefaultUpdateCheckManager.java:231)
    at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.checkArtifact(DefaultUpdateCheckManager.java:206)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.gatherDownloads(DefaultArtifactResolver.java:585)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:503)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)

Geez. I've got a reference to an artifact from Summer2014. I need to fix that.

This probably worked in my environment because I've got the Summer2014 artifact in my local Maven cache. A new student wouldn't have that old jar and it's not available on bintray to download.

RJ-Russell commented 8 years ago

Tried changing Summer2014 to Summer2016 on line 55 in pom.xml. Recevied the following error.

[WARNING] 
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key interactive
    at java.util.ResourceBundle.getObject(ResourceBundle.java:450)
    at java.util.ResourceBundle.getString(ResourceBundle.java:407)
    at com.sandwich.koan.ApplicationSettings.isInteractive(ApplicationSettings.java:38)
    at com.sandwich.koan.runner.AppLauncher.main(AppLauncher.java:24)
    ... 6 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.904 s
[INFO] Finished at: 2016-06-17T19:42:40-07:00
[INFO] Final Memory: 11M/158M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project koans: An exception occured while executing the Java class. null: InvocationTargetException: Can't find resource for bundle java.util.PropertyResourceBundle, key interactive -> [Help 1]
[ERROR] 
DavidWhitlock commented 8 years ago

Oh, wow. It looks like I never updated the Koans archetype with all of the latest changes. I'm kind of surprised that the integration tests passed.

DavidWhitlock commented 8 years ago

Changes to address this issue have been merged to the master branch and have been deployed to the Maven repository.

@RJ-Russell and @kiarasht, will you guys try creating a Koans project from the latest archetype and let me know how it goes?

RJ-Russell commented 8 years ago

After removing the original koans project and going through all the steps again from scratch, I still received same errors.

[ERROR] Failed to execute goal on project koans: Could not resolve dependencies for project edu.pdx.cs410J.rjr4:koans:jar:1.0-SNAPSHOT: Could not find artifact com.sandwich:koans-lib:jar:Summer2014 in CS410J (https://dl.bintray.com/davidwhitlock/maven) -> [Help 1]

And then after changing 'Summer2014' in pom.xml to 'Summer2016':

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project koans: An exception occured while executing the Java class. null: InvocationTargetException: Can't find resource for bundle java.util.PropertyResourceBundle, key interactive -> [Help 1]```
Kiarasht commented 8 years ago

That's weird. It worked for me before / after your merge.

C:\Users\Restart\IntellijProjects>mvn archetype:generate -DarchetypeCatalog=https://dl.bintray.com/davidwhitlock/maven/ -DarchetypeGroupId=edu.pdx.cs410J -DarchetypeArtifactId=java-koans-archetype -DarchetypeVersion=Summer2016 -DgroupId=edu.pdx.cs410J.torkian -DartifactId=koans -Dversion=1.0-SNAPSHOT
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.3:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.3:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.3:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[INFO] Archetype repository not defined. Using the one from [edu.pdx.cs410J:java-koans-archetype:Summer2016] found in catalog https://dl.bintray.com/davidwhitlock/maven/
[INFO] Using property: groupId = edu.pdx.cs410J.torkian
[INFO] Using property: artifactId = koans
[INFO] Using property: version = 1.0-SNAPSHOT
[INFO] Using property: package = edu.pdx.cs410J.torkian
Confirm properties configuration:
groupId: edu.pdx.cs410J.torkian
artifactId: koans
version: 1.0-SNAPSHOT
package: edu.pdx.cs410J.torkian
 Y: : Y
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: java-koans-archetype:Summer2016
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: edu.pdx.cs410J.torkian
[INFO] Parameter: artifactId, Value: koans
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: edu.pdx.cs410J.torkian
[INFO] Parameter: packageInPathFormat, Value: edu/pdx/cs410J/torkian
[INFO] Parameter: package, Value: edu.pdx.cs410J.torkian
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: groupId, Value: edu.pdx.cs410J.torkian
[INFO] Parameter: artifactId, Value: koans
[WARNING] CP Don't override file C:\Users\Restart\IntellijProjects\koans\app\config\.gitignore
[INFO] project created from Archetype in dir: C:\Users\Restart\IntellijProjects\koans
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.985 s
[INFO] Finished at: 2016-06-18T11:30:03-07:00
[INFO] Final Memory: 15M/177M
[INFO] ------------------------------------------------------------------------

C:\Users\Restart\IntellijProjects>cd koans

C:\Users\Restart\IntellijProjects\koans>mvn exec:java
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Java Koans 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) > validate @ koans >>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-versions) @ koans ---
[INFO]
[INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) < validate @ koans <<<
[INFO]
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) @ koans ---

You need to open the file C:\Users\Restart\IntellijProjects\koans\src\beginner\AboutKoans.java. There should be a method starting with @Koan called findAboutKoansFile, look within it for your first lesson. Once you have solved that, save the file and check back for your next lesson.

Ponder what's going wrong in the: AboutKoans class's findAboutKoansFile method.

Line 11 may offer a clue as to how you may progress, now make haste!

Level: Novice
Progress [--------------------------------------------------] 0/243
Remaining Suites: AboutKoans, AboutAssertions, AboutEquality, AboutPrimitives, AboutStrings, AboutObjects, AboutLoops, AboutInheritance, AboutCasting, AboutConditionals, AboutConstructors, AboutEnums, AboutExceptions, AboutMethodPreference, AboutOperators, AboutArrays, AboutVarArgs, AboutAutoboxing,
 AboutCollections, AboutComparison, AboutDates, AboutEquality, AboutFileIO, AboutInnerClasses, AboutLocale, AboutRegularExpressions, AboutSerialization, AboutMocks, AboutJava7LiteralsEnhancements, AboutStringsInSwitch, AboutDiamondOperator, AboutTryWithResources, AboutRequireNotNull, AboutDefaultMet
hods, AboutOptional, AboutLocalTime, AboutLambdas, AboutStreams, AboutMultipleInheritance

Edit & save a koan to reload or enter 'Q' to exit
RJ-Russell commented 8 years ago

I just redid it again...and still not working. I tried this on two different systems again. Same errors.

RJ-Russell commented 8 years ago

So....after removing maven from my PATH, then then removing the .m2 maven directory from my homedir. Then removing everything koans related...and finally doing a reboot and re-symlinking the mvn exectuable back into my PATH.....and redoing all the koans archetype stuff....it works.

I'm thinking something was cached in there that was causing it to not read the new files?

Anyway..it seems to be working now. Thank you for your time and patience

DavidWhitlock commented 8 years ago

Thank you, @RJ-Russell. I really appreciate you getting a head start on the classwork and finding this critical defect. I'm glad you got it working.