I am trying to create a new Laravel project on my Fedora 33 system as per:
https://laravel.com/docs/8.x/installation#getting-started-on-linux
I run the command and get the following output:
[glen#localhost gclark18]$ sudo curl -s https://laravel.build/example-app | bash
_ _
| | | |
| | __ _ _ __ __ ___ _____| |
| | / _` | '__/ _` \ \ / / _ \ |
| |___| (_| | | | (_| |\ V / __/ |
|______\__,_|_| \__,_| \_/ \___|_|
Warning: TTY mode requires /dev/tty to be read/writable.
Creating a "laravel/laravel" project at "./example-app"
Installing laravel/laravel (v8.5.14)
[ErrorException]
mkdir(): Permission denied
create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--add-repository] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--remove-vcs] [--no-install] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--ask] [--] [<package>] [<directory>] [<version>]
bash: line 16: cd: example-app: No such file or directory
Get started with: cd example-app && ./vendor/bin/sail up
I am not sure why it would not have permission as this is my a folder in my home directory that I have full permissions to.
Related
having a spring boot multi module application. Wanted to convert in spring native exe on windows. Also need to support third party lib as well. I am having 5 modules in my spring boot application:
Security (user management generates JWT and validate before each request).
Spring boot main application.
Configuration - use to do my application configuration)
UI (angular code )
Reporting (generates reports from DB)
I am able to create exe via maven AOT plugin. (did lot of configuration for initialize at run time and build time) exe is generated with following files:
target\application.exe (executable)
target\awt.dll (jdk_lib)
target\jaas.dll (jdk_lib)
target\javaaccessbridge.dll (jdk_lib)
target\jawt.dll (jdk_lib)
target\management.dll (jdk_lib)
target\sunmscapi.dll (jdk_lib)
target\w2k_lsa_auth.dll (jdk_lib)
target\java.dll (jdk_lib_shim)
target\jvm.dll (jdk_lib_shim)
target\cpos-admin-portal-application.build_artifacts.txt
target\cpos-admin-portal-application.exe
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.5.6)
but no hit goes to any controller. Not other logs of starting application is printed
When I start exe, application use to start following prints on console
Not getting why this much type of files has been generated.
After upgrading Spring Cloud libraries to newest version Spring Cloud Config client behaves differently in terms of logging.
In previous version, whenever Spring Cloud Config server was unavailable, I could see log:
Connect Timeout Exception on Url - http://localhost:8888/. Will be trying the next url if available
Currently there's no logs, application simply hangs. After Config Server is available, app also starts an emits all logs at once. It looks like it's caching somehow all logs istead of outputting it immediately.
[INFO] --- spring-boot-maven-plugin:2.5.4:run (default-cli) # gateway-service ---
[INFO] Attaching agents: []
2021-10-07 18:37:02,746 main ERROR Unrecognized format specifier [entityId]
2021-10-07 18:37:02,747 main ERROR Unrecognized conversion specifier [entityId] starting at position 146 in conversion pattern.
2021-10-07 18:38:36,172 main ERROR Unrecognized format specifier [entityId]
2021-10-07 18:38:36,172 main ERROR Unrecognized conversion specifier [entityId] starting at position 147 in conversion pattern.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.5.4)
2021-10-07 18:38:36.340 INFO 80607 --- [ main] c.y.g.GatewayApplication [%entityId] : Starting GatewayApplication using Java 11.0.12 on ...
In the example above, I was waiting for 30s, before starting Config Server (see timestamps). What is wrong?
I have a problem with a #SpringBootTest integration test that is driving me nuts, I hope there are some Spring gurus around that can shed some light on this issue:
Our integration tests need to have a fully initialized ApplicationContext so we dont run them with any special test profiles. This worked well in all environments. I've just now updated to Spring Boot 2.4.3 (from 2.3.4) and experience a really weird problem:
When I run the test locally (either from the IDE or using mvn test) it just runs as expected: As I have no profile to run specified whatsoever he's picking up the default default profile as it is also shown on the INFO log output when starting:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.4.3)
2021-02-25 14:24:29.920 INFO [service-api] [ main] d.r.i.i.s.a.ServiceApiApplicationTest : No active profile set, falling back to default profiles: default
2021-02-25 14:24:31.599 INFO [service-api] [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
...
If the same thing is run in our CI pipeline using mvn test (well actually it is Gitlab AutoDevOps which utilizes the herokuish java buildpack but i'm pretty sure it boils down to mvn test) he does not use the default default profile which is causing problems afterwards:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.4.3)
2021-03-10 15:31:03.925 INFO [service-api] [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2021-03-10 15:31:04.034 INFO [service-api] [ main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8888. Will be trying the next url if available
...
(You see the problem: we're using Spring Cloud config for every environment except default but this is just a follow-up problem, the root cause is that when running in Gitlab CI it just does not use the default profile.)
So the question is: What part of the environment makes the magic Spring Boot Context initialization process not going through the standard org.springframework.boot.SpringApplication#logStartupProfileInfo code its supposed to go every time (like it is documented in the official documentation:
The annotation works by creating the ApplicationContext used in your tests through SpringApplication.
?
This problem just occurs after updating to Spring Boot 2.4.3, with v2.3.4 it worked in Gitlab CI just as fine as locally.
(Oh and i know i can würg-around this issue by specifying the profile on the test using #ActiveProfiles("default") but dont you agree that this is horrible?)
I have a very simple Spring Cloud Functions with the AWS adapter to run it as an AWS Lambda. The source code is available on Github: https://github.com/codependent/spring-boot-authentication-function
#SpringBootApplication
class SpringBootAuthenticationFunctionApplication {
#Bean
fun kotlinSupplier(): (Credentials) -> AuthenticationResponse {
return {
if (it.user == "jose" && it.password == "MyPassword") {
//HMAC
val algorithm = Algorithm.HMAC256("secret")
val token = JWT.create()
.withIssuer("MicronautAwsAuthenticationFunction")
.withSubject(it.user)
.sign(algorithm)
AuthenticationResponse(token)
} else {
AuthenticationResponse()
}
}
}
}
fun main(args: Array<String>) {
runApplication<SpringBootAuthenticationFunctionApplication>(*args)
}
When I run this function on AWS Lambda it throws a NullPointerException. Any idea what's wrong?
{
"errorMessage": "java.lang.NullPointerException",
"errorType": "java.lang.NullPointerException",
"stackTrace": [
"org.springframework.cloud.function.context.FunctionalSpringApplication.postProcessApplicationContext(FunctionalSpringApplication.java:102)",
"org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:372)",
"org.springframework.boot.SpringApplication.run(SpringApplication.java:314)",
"org.springframework.cloud.function.adapter.aws.SpringFunctionInitializer.initialize(SpringFunctionInitializer.java:86)",
"org.springframework.cloud.function.adapter.aws.SpringBootStreamHandler.initialize(SpringBootStreamHandler.java:55)",
"org.springframework.cloud.function.adapter.aws.SpringBootStreamHandler.handleRequest(SpringBootStreamHandler.java:64)",
"sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)",
"sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)",
"sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)",
"java.lang.reflect.Method.invoke(Method.java:498)"
]
}
I have set org.springframework.cloud.function.adapter.aws.SpringBootStreamHandler as the value of the handler class in the AWS Console.
Full CloudWatch logs:
16:12:39.252 [main] INFO org.springframework.cloud.function.adapter.aws.SpringFunctionInitializer - Searching manifests: [jar:file:/var/runtime/lib/LambdaJavaRTEntry-1.0.jar!/META-INF/MANIFEST.MF, jar:file:/var/runtime/lib/aws-lambda-java-core-1.2.0.jar!/META-INF/MANIFEST.MF, file:/var/task/META-INF/MANIFEST.MF]
16:12:39.258 [main] INFO org.springframework.cloud.function.adapter.aws.SpringFunctionInitializer - Searching manifest: jar:file:/var/runtime/lib/LambdaJavaRTEntry-1.0.jar!/META-INF/MANIFEST.MF
16:12:39.259 [main] INFO org.springframework.cloud.function.adapter.aws.SpringFunctionInitializer - Searching manifest: jar:file:/var/runtime/lib/aws-lambda-java-core-1.2.0.jar!/META-INF/MANIFEST.MF
16:12:39.260 [main] INFO org.springframework.cloud.function.adapter.aws.SpringFunctionInitializer - Searching manifest: file:/var/task/META-INF/MANIFEST.MF
16:12:39.261 [main] INFO org.springframework.cloud.function.adapter.aws.SpringFunctionInitializer - Searching manifests: []
16:12:39.261 [main] INFO org.springframework.cloud.function.adapter.aws.SpringFunctionInitializer - Main class: null
START RequestId: 66460dc7-e90b-487c-a022-12c04ab72c7d Version: $LATEST
16:12:39.272 [main] INFO org.springframework.cloud.function.adapter.aws.SpringFunctionInitializer - Initializing: null
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot ::
2019-03-21 16:12:45.617 ERROR 1 --- [ main] o.s.boot.SpringApplication : Application run failed
java.lang.NullPointerException: null
at org.springframework.cloud.function.context.FunctionalSpringApplication.postProcessApplicationContext(FunctionalSpringApplication.java:102) ~[task/:na]
at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:372) ~[task/:na]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) ~[task/:na]
at org.springframework.cloud.function.adapter.aws.SpringFunctionInitializer.initialize(SpringFunctionInitializer.java:86) [task/:na]
at org.springframework.cloud.function.adapter.aws.SpringBootStreamHandler.initialize(SpringBootStreamHandler.java:55) [task/:na]
at org.springframework.cloud.function.adapter.aws.SpringBootStreamHandler.handleRequest(SpringBootStreamHandler.java:64) [task/:na]
at lambdainternal.EventHandlerLoader$2.call(EventHandlerLoader.java:888) [LambdaSandboxJava-1.0.jar:na]
at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:293) [LambdaSandboxJava-1.0.jar:na]
at lambdainternal.AWSLambda.<clinit>(AWSLambda.java:64) [LambdaSandboxJava-1.0.jar:na]
at java.lang.Class.forName0(Native Method) [na:1.8.0_181]
at java.lang.Class.forName(Class.java:348) [na:1.8.0_181]
at lambdainternal.LambdaRTEntry.main(LambdaRTEntry.java:104) [LambdaJavaRTEntry-1.0.jar:na]
java.lang.NullPointerException: java.lang.NullPointerException
java.lang.NullPointerException
at org.springframework.cloud.function.context.FunctionalSpringApplication.postProcessApplicationContext(FunctionalSpringApplication.java:102)
at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:372)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
at org.springframework.cloud.function.adapter.aws.SpringFunctionInitializer.initialize(SpringFunctionInitializer.java:86)
at org.springframework.cloud.function.adapter.aws.SpringBootStreamHandler.initialize(SpringBootStreamHandler.java:55)
at org.springframework.cloud.function.adapter.aws.SpringBootStreamHandler.handleRequest(SpringBootStreamHandler.java:64)
This looks like a bug, so please consider raising the issue here.
I recently started spending more time on Spring Boot and have the started to feel the absence of a shell (similar to Grails console) like application that I can play with the repositories, services etc... Does something like this exist in spring boot?
I recently launched the Spring Context from Groovy project, that gives you access to all beans object within the Remote Shell plugin using the repl groovy interactive console.
Looks like this:
$ ssh -p 2000 user#localhost
user#localhost's password:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.4.6.RELEASE) on myhost
> repl groovy
Using repl groovy
> ctx.App.myUserService.findUserByEmail("mrsarm#gmail.com")[0].id
100123
> ctx.App.myUserService.getById(100123).name
Mariano Ruiz
> ctx.App.contactDao.logger.effectiveLevel
INFO
> ctx.App.contactDao.logger.setLevel(ch.qos.logback.classic.Level.DEBUG)
As I mentioned in my previous post and later in a comment, you can use the Spring Context from Groovy tool for a Spring Boot 1.x project, but because changes in the Spring Boot framework, it does not work for Spring Boot 2+ projects, in that case you can use the jshell-plugin along with spring-ctx (two projects that I also created).
Quick setup following the steps here and here:
Add the following to your build.gradle:
plugins {
id "com.github.mrsarm.jshell.plugin" version "1.1.0"
}
Add the following dependency to the dependencies section:
implementation 'com.github.mrsarm:spring-ctx:1.0.0'
Add at the end of the repositories section:
maven { url 'https://jitpack.io' }
Any Spring Boot application has a class annotated with #SpringBootApplication that is the starting point of the application, with a public static void main(String[] args) method, you need to create a startup.jsh file at the root of your project calling that method, eg:
com.my.package.MyApplication.main(new String[]{})
You can also add the imports of the business classes you are going to play with, as many as you have, otherwise you can import them once the JShell started:
import com.my.package.services.MyUserService
The configuration is done. You can start the jshell session executing within a console:
$ gradle --console plain jshell
Once the session started you can play with your Spring application, accessing the bean objects from the Spring context as follow:
$ gradle --console plain jshell
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.4.RELEASE)
14:43:28.320 INFO com.my.package.MyApplication : Starting Application on kubu1910 with PID 5225 (/projects/...
14:43:28.323 DEBUG com.my.package.MyApplication : Running with Spring Boot v2.2.4.RELEASE, Spring v5.2.3.RELEASE
14:43:28.324 INFO com.my.package.MyApplication : The following profiles are active: ...
14:43:30.229 INFO boot.web.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8010 (http)
...
...
14:43:33.729 INFO tuate.endpoint.web.EndpointLinksResolver : Exposing 3 endpoint(s) beneath base path ''
14:43:33.811 INFO boot.web.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8010 (http) with context path ''
14:43:33.816 INFO com.my.package.MyApplication : Started Application in 6.995 seconds (JVM running for 10.524)
> Task :jshell
| Welcome to JShell -- Version 11.0.6
| For an introduction type: /help intro
jshell> var myUserService = ctx.App.getBean(MyUserService.class)
jshell> ctx.App.ppjson(myUserService.getByUsername("admin"))
{
"name" : "Jhon",
"lastName" : "Due",
"username" : "admin",
"age" : null
}
Final advice: in Windows / Mac you can call the command with the rlwrap to make the autocompletion to work, there is a well know issue with Gradle that cause tabs and arrow keys to not work well, so you can call the JShell as follow:
$ rlwrap gradle --console plain jshell
Also worth to note that you can use the Gradle Wrapper (./gradlew) from your project if available instead of an installed version of Gradle (gradle).