managed resource available only for freshly cleaned project - sbt

I created a SBT AutoPlugin that generates resources:
https://github.com/sphereio/json-schema-inliner/
(Thx to Why doesn't a custom resourceGenerator get executed upon compile?, I could fix my first problem.)
There is a test project that generates "test/inline/category.schema.json" for example.
The test project is in GIT as well: https://github.com/sphereio/json-schema-inliner/tree/master/testProject
This generated resource is available with a freshly cleaned project:
cd testProject
▶ sbt clean run
[...]
[info] Running Main
url from test/category.schema.json: file:/Users/yannsimon/projects/json-schema/testProject/target/scala-2.10/classes/test/category.schema.json
url from test/inline/category.schema.json: file:/Users/yannsimon/projects/json-schema/testProject/target/scala-2.10/classes/test/inline/category.schema.json
When running again, the managed resource disappears from "testProject/target/scala-2.10/classes/test/inline"
▶ sbt run
[...]
[info] Running Main
url from test/category.schema.json: file:/Users/yannsimon/projects/json-schema/testProject/target/scala-2.10/classes/test/category.schema.json
url from test/inline/category.schema.json: null
Any help would be appreciated.
Thanks, Yann

Answered in sbt issue: https://github.com/sbt/sbt/issues/2168#issuecomment-144133794
The fix was this is very simple: https://github.com/sphereio/json-schema-inliner/commit/eeb490189781e93c8c6eb15b504a158ce425b653

Related

Alfresco - Custom AMPs does not show even though installed

To add my custom amps I start from the base images:
alfresco/alfresco-content-repository-community:7.1.0
alfresco/alfresco-share:7.1.0.1
Then I copy my custom AMPs on to /usr/local/tomcat/amps and /usr/local/tomcat/amps_share followed by running:
RUN java -jar /usr/local/tomcat/alfresco-mmt/alfresco-mmt*.jar install \
/usr/local/tomcat/amps_share /usr/local/tomcat/webapps/share -directory -nobackup -force
RUN java -jar $TOMCAT_DIR/alfresco-mmt/alfresco-mmt*.jar install \
$TOMCAT_DIR/amps $TOMCAT_DIR/webapps/alfresco -directory -nobackup -force
When I check the installed modules in the container with alfresco-mmt list I can see that they are installed. They also seem fine in the logs. However, when I go to: http://localhost:8080/share/page/console/admin-console/module-package it says No module packages found. Can someone explain this? How do I go about this? I have found no information at all in the official documentations or by googling.
I've also noticed that there are no .war files in the /usr/local/tomcat/webapps directory. Should there be a .war file in the docker containers or have they been replaced when deploying with containers? Any explanation is helpful. Thanks!

SBT asks for credentials when creating a project

I am completely new to Scala and SBT. I have downloaded the .tgz archive for SBT 1.3.2, extracted it and added its bin directory to my PATH on Ubuntu 18.04.
I am following the official Getting Started guide, which gives a command to create a simple project. It is supposed to run like that:
$ sbt new sbt/scala-seed.g8
....
Minimum Scala build.
name [My Something Project]: hello
Template applied in ./hello
Instead, it asks me for credentials:
$ sbt new sbt/scala_seed.g8
[info] Set current project to code (in build file:/home/user/code/)
[info] Set current project to code (in build file:/home/user/code/)
Username:
I have no idea what to enter. I can't even try to guess, since I can only enter one character before it asks for a password. If I enter one character again, I get the username prompt again. This is the output after pressing two keys:
$ sbt new sbt/scala_seed.g8
[info] Set current project to code (in build file:/home/user/code/)
[info] Set current project to code (in build file:/home/user/code/)
Username: Password:
Username:
I just want to setup a basic project. What am I doing wrong?
If you get sbt new user/some.g8 asking for the Username: then you know that you have typed the template path e.g. user/some.g8 incorrectly so it doesn't exist as a g8 template.
Please check that you have to correct template path and try again.
Even I got the same error when I tried to create a new project following the instruction from https://docs.scala-lang.org/getting-started/sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.html using sbt cli.
I ran the command as below,
sbt new hw/hello-world.g8
Following the above command I was prompted for suername and password. Then I ran it again as
sbt new scala/hello-world.g8
This time the project was successfully created.
Output:
hello-world.g8
[info] welcome to sbt 1.3.13 (Oracle Corporation Java 1.8.0_261)
[info] set current project to scala (in build file:/C:/scala/)
[info] set current project to scala (in build file:/C:/scala/)
A template to demonstrate a minimal Scala application
name [Hello World template]: hello-world
Template applied in C:\scala\.\hello-world
So the hw in the command "sbt new hw/hello-world.g8" is not correct and it has to be only "sbt new scala/hello-world.g8".
In the first, working example you have scala hyphen seed.
$ sbt new sbt/scala-seed.g8
....
In the second non-working example you have scala underscore seed.
$ sbt new sbt/scala_seed.g8
[info] Set current project to code (in build file:/home/user/code/)
[info] Set current project to code (in build file:/home/user/code/)
Username:

During an aborted deployment, some instances may have deployed the new application version

I am trying to deploy ASP.NET application to AWS. When I press deploy button I get error
During an aborted deployment, some instances may have deployed the new application version. To ensure all instances are running the same version, re-deploy the appropriate application version.
I have no idea where I made mistake and what's going wrong
Any comment ?
You can get this error message if you're trying to deploy source file zip with same name which is already deployed. ZIP FILE NAME not TAG !!!.
You should always deploy source file zip with different name.
Best practice is use version number which is increasing (eg. Project-v2) or something else.
#user2763557
I know the question is quite old, but I had a similiar issue trying to deploy my code from Github via Code Pipeline.
But I solved the problem. It was an error, which happened when composer tried to install PHP version 7.3 while I was running 7.4 on the Elastic Beanstalk.
So a good way to solve other similiar problems is to download the full logs in Elastic Beanstalk and open eb-engine.log and look for similiar errors like mine:
Problem 1
- This package requires php 7.3.* but your PHP version (7.4.4) does not satisfy that >requirement.
2020/05/08 12:38:42.162732 [INFO] Executing cleanup logic
2020/05/08 12:38:42.162814 [INFO] CommandService Response:{"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"Engine >execution has encountered an error.","returncode":1,"events":[]}]}
That was my error, which stopped the Code Pipeline Deployment process and threw the error.
I hope that can help someone.
in my case, it's bug of Microsoft.Powershell.Archive.
https://superuser.com/questions/1382839/zip-files-expand-with-backslashes-on-linux-no-subdirectories
I find these message from log file:/var/log/eb-engine.log
An error occurred during execution of command [app-deploy] - [StageJavaApplication]. Stop running the command. Error: Command /bin/sh -c /usr/bin/unzip -q -o /opt/elasticbeanstalk/deployment/app_source_bundle -d /tmp/extracted_app_source_bundle failed with error exit status 1. Stderr:warning: /opt/elasticbeanstalk/deployment/app_source_bundle appears to use backslashes as path separators
I can deploy successfully zip file - that archived by other program.
In my case, I got this error using Code Pipeline and GitHub to deploy Node.js:
2020-12-28 14:39:30 UTC+0900
ERROR
During an aborted deployment, some instances may have deployed the new application version. To ensure all instances are running the same version, re-deploy the appropriate application version.
2020-12-28 14:39:29 UTC+0900
ERROR
Failed to deploy application.
2020-12-28 14:39:29 UTC+0900
ERROR
Encountered AccessDeniedException: User: ..... is not authorized to perform: logs:DescribeLogGroups on resource: arn:aws:logs:ap-northeast-2:...
eventho I got the error the server was updated, so I add the permission for code pipeline to see logs and everything worked fine
to fix that I did:
IAM
Roles
Selected the code pipeline rule
Add AWSElasticBeanstalkFullAccess policy
I know that this is an old question posted, but the problem may never be old because it might recur due to several issues.
I faced the same issue when I was hosting my HTML based website using Docker containers.
I fixed it, by exposing the port number
Previously it was:
From nginx
WORKDIR '/app'
COPY ./html/ /usr/share/nginx/html/
This worked locally but failed during deployment on AWS Elasticbeanstalk.
I downloaded the logs and perceived that the problem might be due to not exposing the port of nginx server. So I exposed port 80, the default nginx server, and deployed it again on AWS Elasticbeanstalk.
Now this time, it works!
The Dockerfile which helped in successful deployment was as follows:
From nginx
EXPOSE 80
WORKDIR '/app'
COPY ./html/ /usr/share/nginx/html/
Try including package-lock.json in your zip or github repo if using codepipeline
in my case, i was trying to deploy from EBS Cli, ¿what i did to fix it?, Just remove the last versions from AWS Console, and upload again an new version of my app, and then this works good.
I had the same error. I checked the eb engine logs and had different versions of the same package in requirements. Eg:
flask-socketio==5.3.2
flask-socketio==5.3.1
After deleting one of them deployment went successfully.
I followed NKol's answer and they basically nailed the reason. I was running Django app on AWS and I had a Code pipeline Via GitHub. This is what it said in the eb-engine.log
2023/02/09 01:26:59.890761 [INFO] Starting...
2023/02/09 01:26:59.890810 [INFO] Starting EBPlatform-PlatformEngine
2023/02/09 01:26:59.890827 [INFO] reading event message file
2023/02/09 01:26:59.890947 [INFO] Engine received EB command cfn-hup-exec
2023/02/09 01:26:59.954386 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:eu-central-1:429834728703:stack/awseb-e-jaqzdwbxa3-stack/012e7840-1654-11ed-bd87-06a5d714e8d0 -r AWSEBAutoScalingGroup --region eu-central-1
2023/02/09 01:27:00.316934 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:eu-central-1:429834728703:stack/awseb-e-jaqzdwbxa3-stack/012e7840-1654-11ed-bd87-06a5d714e8d0 -r AWSEBBeanstalkMetadata --region eu-central-1
2023/02/09 01:27:00.618725 [INFO] checking whether command app-deploy is applicable to this instance...
2023/02/09 01:27:00.618741 [INFO] this command is not applicable to the instance, thus instance shouldn't execute command
2023/02/09 01:27:00.618744 [INFO] skip command app-deploy for this instance...
2023/02/09 01:27:00.618753 [ERROR] Ignoring not applicable command.
2023/02/09 01:27:00.618756 [INFO] Executing cleanup logic
2023/02/09 01:27:00.618825 [INFO] CommandService Response: {"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"Ignoring not applicable command.","returncode":0,"events":[]}]}
2023/02/09 01:27:00.618985 [INFO] Platform Engine finished execution on command: app-deploy
Basically, on my local server, I was running python 3.10 and in the code, I used the new Switches(Match Case), but on the server, the python version was 3.7 which did not have Switches. This is why we should use docker.

Bitbucket pipelines: The type or namespace name could not be found

I'm hoping someone can help me out. Thanks!
I'm trying to deploy my dotnet core 2.0 API
When I try and build the project with bitbucket pipelines I get multiple errors finding references. It does restore the project successfully.
However the project builds successfully on my laptop.
folder structure:
/API
/Controllers
/Migrations
/Models
/Services
API.csproj
Program.cs
Startup.cs
bitbucket-pipelines.yml
pipelines:
default:
- step:
image: microsoft/dotnet
name: Check if it builds
script:
- cd API
- dotnet build
example error:
Services/MyService.cs(18,29): error CS0246: The type or namespace name 'IRepository<>' could not be found (are you missing a using directive or an assembly reference?) [/opt/atlassian/pipelines/agent/build/API/API.csproj]
Note I have the latest version of dotnet, same as I'm using in bitbucket pipelines. I have checked via running dotnet --info
Finally i've figured out what was the cause of this issue. I feel really silly for not figuring this out sooner.
My git repository was somehow setup with ignorecase = true.
I have switched it to false (which will prevent this issue in the future).
This means that I can have two of the same files or folders.
I had renamed a folder to a different case.
My repo had
API/
API.csproj
and
api/
api.csproj
My Mac couldn't allow for both so I only saw one folder and one project on my local machine.
To fix this, I had to git rm -r --cached api
This deleted the duplicate folder
I had the project file as a duplicate as well so used git rm -f api.csproj to remove the file from the repository.
Then git pull to bring those changes into my local master branch.

SBT Build Setup for Library and Multiple Command Line Tools

I'm trying to set up a Scala project, built using SBT, that will consist of a library and several command-line tools to do various things using that library. The library and tools are going to depend on another Scala project which I've installed into my local Ivy cache with sbt publish-local.
I've never used SBT before, so I'm a bit lost as to how to set this up. I would like several Linux executables or shell scripts in my top-level project directory, each of which executes a main() methods defined in a Scala file, and all of which depend on a single library. How do I get that sort of setup with an SBT project?
The way I'm thinking this will have to work is as an SBT configuration with multiple projects, and a bunch of wrapper shell scripts that execute sbt run in the appropriate project. However, when I run sbt run in my current single-project setup, I get, in addition to my program's intended output, a bunch of SBT noise:
Loading /pod/home/anovak/build/sbt/bin/sbt-launch-lib.bash
[info] Loading project definition from /pod/home/anovak/sequence-graphs/project
[info] Set current project to Sequence Graph API (in build file:/pod/home/anovak/sequence-graphs/)
[info] Running SequenceGraphs
Sequence Graphs are great!
[success] Total time: 2 s, completed Jan 6, 2014 6:01:17 PM
I would like my wrapper scripts to be able to run my command-line tools without seeing anything from SBT on screen at all. I think the [info] and [success] messages can be suppressed by messing about with the project's log level settings, but would that eliminate the "Loading..." line as well? If not, is there some other way to run an SBT project "on its own", without much/any interference from SBT?
I think what you need is one root project - sequence-graphs - with two submodules - library and cmd-tools.
project/build.properties would be as follows:
sbt.version=0.13.1
build.sbt for the root project would be as follows:
lazy val root = project in file(".") aggregate (library, `cmd-tools`)
lazy val library = project
lazy val `cmd-tools` = project dependsOn library
With only these two files you can run sbt and do projects to see the projects available.
[root]> projects
[info] In file:/Users/jacek/sandbox/so/sequence-graphs/
[info] cmd-tools
[info] library
[info] * root
At the same time SBT will create necessary subdirectories for the submodules.
With the project layout you start developing your own command-line tools in cmd-tools submodule.
To make things simple, I assume that a simple App-extending applications are enough.
cmd-tools/Hello1.scala
object Hello1 extends App {
println("Hello1")
}
cmd-tools/Hello2.scala
object Hello2 extends App {
println("Hello2")
}
With these two Hellos you can run cmd-tools/run from SBT shell in the root project.
[root]> cmd-tools/run
[info] Compiling 2 Scala sources to /Users/jacek/sandbox/so/sequence-graphs/cmd-tools/target/scala-2.10/classes...
Multiple main classes detected, select one to run:
[1] Hello2
[2] Hello1
Enter number:
The same could be run from the command line as sbt cmd-tools/run:
jacek:~/sandbox/so/sequence-graphs
$ sbt cmd-tools/run
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Loading project definition from /Users/jacek/sandbox/so/sequence-graphs/project
[info] Set current project to root (in build file:/Users/jacek/sandbox/so/sequence-graphs/)
Multiple main classes detected, select one to run:
[1] Hello1
[2] Hello2
Enter number: 1
[info] Running Hello1
Hello1
[success] Total time: 4 s, completed Jan 9, 2014 9:44:39 PM
Let's start it over as well as disable infos and [success]es messages.
jacek:~/sandbox/so/sequence-graphs
$ sbt --error 'set showSuccess := false' cmd-tools/run
Multiple main classes detected, select one to run:
[1] Hello1
[2] Hello2
Enter number: 1
Hello1
There's also the runMain command that Runs the main class selected by the first argument, passing the remaining arguments to the main method.
With that and the other examples you could have a sample command-line script to execute Hello1 as follows:
sbt --error 'set showSuccess := false' 'cmd-tools/runMain Hello1'
It could be even simpler when you use the sbt-onejar plugin that can Package your project using One-JAR™ With the plugin you don't have to use SBT after you distribute your command-line tools.
Quoting the plugin's documentation:
sbt-onejar is a simple-build-tool plugin for building a single executable JAR containing all your code and dependencies as nested JARs.
Please note that the Officially supported packages of SBT add some additional checks and printouts, i.e. tgz comes with bin/sbt script that does the following (amongst the other things):
echo "Loading $(dirname "$(realpath "$0")")/sbt-launch-lib.bash"
It's not an integral part of SBT itself, but the script itself that wants to do as much as possible so an end user is, say, happy. In your case, you are not necessarily happy, so either remove the line from the script or follow the steps as described in Manual Installation.

Resources