8
respostas

quando tento instalar o server da erro na aplicação

MacBook-Pro-de-Yan:server yanmeneguelli$ java -jar server.jar

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.3.6.RELEASE)

2019-01-02 22:45:38.311  INFO 28797 --- [           main] br.com.caelum.alura.Application          : Starting Application v0.0.1-SNAPSHOT on MacBook-Pro-de-Yan.local with PID 28797 (/Users/yanmeneguelli/Desktop/server/server.jar started by yanmeneguelli in /Users/yanmeneguelli/Desktop/server)
2019-01-02 22:45:38.318  INFO 28797 --- [           main] br.com.caelum.alura.Application          : No active profile set, falling back to default profiles: default
2019-01-02 22:45:38.483  INFO 28797 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4f209819: startup date [Wed Jan 02 22:45:38 BRST 2019]; root of context hierarchy
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (jar:file:/Users/yanmeneguelli/Desktop/server/server.jar!/lib/spring-core-4.2.7.RELEASE.jar!/) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1
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
2019-01-02 22:45:41.301  INFO 28797 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-01-02 22:45:41.363  INFO 28797 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'appConfig' of type [class br.com.caelum.alura.config.AppConfig$$EnhancerBySpringCGLIB$$b2bdb2f] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-01-02 22:45:41.373  INFO 28797 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 
2019-01-02 22:45:41.607  INFO 28797 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$71919a38] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-01-02 22:45:42.173  WARN 28797 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.boot.autoconfigure.web.ServerProperties org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration.properties; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverProperties' defined in class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/ValidationException
2019-01-02 22:45:42.203 ERROR 28797 --- [           main] o.s.boot.SpringApplication               : Application startup failed
8 respostas

Oi Yannes,

qual versão do java vc tem instalado?

vc pode testar isso na linha de comando através do:

java -version

abs

tenho a versão java version "11.0.1" 2018-10-16 LTS

quando coloco no aplicativo java fala versão 8 atualização 191

Oi Yannes,

Para funcionar com Java 11 é preciso atualizar esse arquivo server.jar pois algumas bibliotecas foram removidas nas versões mais recente do Java. Estou vendo isso com o instrutor de curso.

No entanto tem solução baseado no Docker, mas precisa ter Docker Desktop instalado.

Uma vez instalado basta executar o comando abaixo que sobe um container baseado na imagem do java 8 e tbm já roda o servidor (o server.jar precisa estar na mesma pasta):

docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp -p 8080:8080 openjdk:8-jre java  -jar server.jar

Na primeira execução demora um pouco pois precisa baixar a imagem, a partir dai é bem rápido.

Eu acho que vale a pena investir um pouco no Docker pois ele é muito muito útil. De qq forma estou vendo com o instrutor do curso a atualização do arquivo JAR.

abs

Vou fazer a instalação e utilização dele.

Quando vou rodar o comando da o return como abaixo. MacBook-Pro-de-Yan:~ yanmeneguelli$ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp -p 8080:8080 openjdk:8-jre java Usage: java [-options] class [args...] (to execute a class) or java [-options] -jar jarfile [args...] (to execute a jar file) where options include: -d32 use a 32-bit data model if available -d64 use a 64-bit data model if available -server to select the "server" VM -zero to select the "zero" VM -dcevm to select the "dcevm" VM The default VM is server, because you are running on a server-class machine.

-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
              A : separated list of directories, JAR archives,
              and ZIP archives to search for class files.
-D<name>=<value>
              set a system property
-verbose:[class|gc|jni]
              enable verbose output
-version      print product version and exit
-version:<value>
              Warning: this feature is deprecated and will be removed
              in a future release.
              require the specified version to run
-showversion  print product version and continue
-jre-restrict-search | -no-jre-restrict-search
              Warning: this feature is deprecated and will be removed
              in a future release.
              include/exclude user private JREs in the version search
-? -help      print this help message
-X            print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
              enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
              disable assertions with specified granularity
-esa | -enablesystemassertions
              enable system assertions
-dsa | -disablesystemassertions
              disable system assertions
-agentlib:<libname>[=<options>]
              load native agent library <libname>, e.g. -agentlib:hprof
              see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
              load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
              load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
              show splash screen with specified image

See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.

Oi Yannes,

acho que faltou uma parte do comando (é comprido mesmo, faz um scroll para chegar até o fim):

docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp -p 8080:8080 openjdk:8-jre java -jar server.jar

Pelo que eu vi na sua mensagem faltou o -jar server.jar no final, mas o docker já rodou!!

abs

o problema e que não estou conseguindo colocar os dois na mesma pasta. Estou bem noob mesmo

Talvez eu me expressei mal, mas vc precisa executar o comando no mesmo lugar onde está o server.jar.

Por exemplo, coloque o server.jar na pasta Documentos do seu Mac. Depois abra um terminal e digite:

cd Documents

Verifique se o JAR realmente está nessa pasta. Para tal digite comando:

ls -l

que deve listar todos os arquivos da pasta atual. Se vc encontrou o server.jar, digite o comando Docker:

docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp -p 8080:8080 openjdk:8-jre java -jar server.jar

ok?

abs

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software