Endorsed dirs error

Java9 removed support for the -Djava.endorsed.dirs system property. When starting with this command I get the following error in my logs: 2017-12-11T17:36:04.50-0700 [APP/PROC/WEB/0] OUT JVM Memory...

Okay. I had a look into the Tomcat catalina.sh script. It generates a classpath string with the tomcat-juli.jar appended to it. To extend the CLASSPATH variable we can use setenv.sh. More copy & paste resulted into this patch:

--- lib/java_buildpack/container/tomcat/tomcat_logging_support.rb.orig	2017-10-17 14:12:16.000000000 +0200
+++ lib/java_buildpack/container/tomcat/tomcat_logging_support.rb	2017-12-24 15:04:48.710981716 +0100
@@ -14,23 +14,25 @@
 # limitations under the License.
 
 require 'java_buildpack/component/versioned_dependency_component'
+require 'java_buildpack/container/tomcat/tomcat_utils'
+require 'java_buildpack/container'
 
 module JavaBuildpack
   module Container
 
     # Encapsulates the detect, compile, and release functionality for Tomcat logging support.
     class TomcatLoggingSupport < JavaBuildpack::Component::VersionedDependencyComponent
+      include JavaBuildpack::Container
 
       # (see JavaBuildpack::Component::BaseComponent#compile)
       def compile
-        download_jar(jar_name, endorsed)
+        download_jar(jar_name, tomcat_lib)
+        env = "CLASSPATH=$PWD/#{tomcat_lib.relative_path_from(@droplet.root)}/#{jar_name}"
+        write_env setenv_sh, env
       end
 
       # (see JavaBuildpack::Component::BaseComponent#release)
-      def release
-        @droplet.java_opts.add_system_property 'java.endorsed.dirs',
-                                               "$PWD/#{endorsed.relative_path_from(@droplet.root)}"
-      end
+      def release; end
 
       protected
 
@@ -41,8 +43,12 @@
 
       private
 
-      def endorsed
-        @droplet.sandbox + 'endorsed'
+      def setenv_sh
+        @droplet.sandbox + 'bin/setenv.sh'
+      end
+
+      def write_env(file, document)
+        file.open('w') { |f| f.write document }
       end
 
       def jar_name

I’m not sure if everything I did is really needed or correct. But my modified 4.6 offline buildpack now runs without an endorsed directory and my outout from java.uitl.logging.Logger starts with [CONTAINER]


posted 7 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Hi running with maven 3.5.2, jdk 1.7 in freebsd 10.

compiling on a ear project with dependencies ejb and war.

It failed with the following errors:

-sourcepath /home/sam/imac-files/work/NetBeansProjects/Client/ForestsurfClient/ForestsurfClient-web/src/main/java:/home/sam/imac-files/work/NetBeansProjects/Client/ForestsurfClient/ForestsurfClient-web/target/generated-sources/annotations: -s /home/sam/imac-files/work/NetBeansProjects/Client/ForestsurfClient/ForestsurfClient-web/target/generated-sources/annotations -g -nowarn -target 1.7 -source 1.7 -endorseddirs

[WARNING] File encoding has not been set, using platform encoding US-ASCII, i.e. build is platform dependent!

[DEBUG] incrementalBuildHelper#beforeRebuildExecution

[INFO] Compiling 93 source files to /home/sam/imac-files/work/NetBeansProjects/Client/ForestsurfClient/ForestsurfClient-web/target/classes

[INFO] ————————————————————————

[INFO] BUILD FAILURE

[INFO] ————————————————————————

[INFO] Total time: 2.151 s

[INFO] Finished at: 2015-03-09T11:51:32+11:00

[INFO] Final Memory: 19M/155M

[INFO] ————————————————————————

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project ForestsurfClient-web: Fatal error compiling: -endorseddirs -> [Help 1]

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project ForestsurfClient-web: Fatal error compiling

at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)

at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)

at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)

at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)

at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)

at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)

at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)

at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)

at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)

at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)

at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)

at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)

at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)

at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)

at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

Caused by: org.apache.maven.plugin.MojoExecutionException: Fatal error compiling

at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:834)

at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)

at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)

at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)

… 19 more

Caused by: org.codehaus.plexus.compiler.CompilerException: -endorseddirs

at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:172)

at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:169)

at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:823)

… 22 more

Caused by: java.lang.IllegalArgumentException: -endorseddirs

at com.sun.tools.javac.util.BaseFileManager.handleOption(BaseFileManager.java:148)

at com.sun.tools.javac.api.JavacTool.processOptions(JavacTool.java:227)

at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:199)

at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:68)

at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:123)

… 24 more

[ERROR]

[ERROR]

[ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

[sam@DellWS ~/imac-files/work/NetBeansProjects/Client/ForestsurfClient/ForestsurfClient-web]$

Any help is very much appreciated.

Thanks

Sam


posted 7 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Have you tried to specify the maven-compiler-plugin in your pom? Can you post it here?

sam White

Ranch Hand

Posts: 229


posted 7 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Jayesh A Lalwani wrote:Have you tried to specify the maven-compiler-plugin in your pom? Can you post it here?

Here is the pom.xml in my war module:

Jayesh A Lalwani

Rancher

Posts: 2759

Eclipse IDE
Spring
Tomcat Server


posted 7 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

1) Where have you set the endorsed.dir property? Is it specified in your settings.xml? As far as I know, it’s not an inbuilt property. You can run mvn help:effective-pom, it will print out the pom with the property replaced with the value. Can you check if enorder.dir is being replaced with the folder you want the endorsed dir to point to

2) WHy are you doing it this way? You are using maven-dependency-plugin to download it to endorsed-dir, and then specifiying it in endorsed dirs during compilation. WHy don’t you just add the jar into the list of dependencies?

sam White

Ranch Hand

Posts: 229


posted 7 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Jayesh A Lalwani wrote:1) Where have you set the endorsed.dir property? Is it specified in your settings.xml? As far as I know, it’s not an inbuilt property. You can run mvn help:effective-pom, it will print out the pom with the property replaced with the value. Can you check if enorder.dir is being replaced with the folder you want the endorsed dir to point to

2) WHy are you doing it this way? You are using maven-dependency-plugin to download it to endorsed-dir, and then specifiying it in endorsed dirs during compilation. WHy don’t you just add the jar into the list of dependencies?

Oops, the «endors dir » is not being replaced when I execute thehelp command:

<plugin>

<artifactId>maven-dependency-plugin</artifactId>

<version>2.10</version>

<executions>

<execution>

<phase>validate</phase>

<goals>

<goal>copy</goal>

</goals>

<configuration>

<outputDirectory>${endorsed.dir}</outputDirectory>

<silent>true</silent>

<artifactItems>

<artifactItem>

<groupId>javax</groupId>

<artifactId>javaee-endorsed-api</artifactId>

<version>6.0</version>

<type>jar</type>

</artifactItem>

</artifactItems>

</configuration>

</execution>

</executions>

</plugin>

The ejb module is part of the ear project, and the war module is depend on the ejb module, therefore the ejb module is supposed written to the .m2/repository directory.

It was working fine in the old machine, but when I changed to the new system, it generated this error.

Thanks

sam

Jayesh A Lalwani

Rancher

Posts: 2759

Eclipse IDE
Spring
Tomcat Server


posted 7 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

You had endorsed.dir set in the old machine.

Which leads to my second question. Why are you doing things this way. If you are doing is because you want that jar for compilation and not during runtime, you can look at the scope element of the dependency tag

sam White

Ranch Hand

Posts: 229


posted 7 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Jayesh A Lalwani wrote:You had endorsed.dir set in the old machine.

Which leads to my second question. Why are you doing things this way. If you are doing is because you want that jar for compilation and not during runtime, you can look at the scope element of the dependency tag

I used dependancy tag with provided scope in the pom.xml of my ejb module.

The jar file is written to the .m2/repository, but the war module could not find it.

Jayesh A Lalwani

Rancher

Posts: 2759

Eclipse IDE
Spring
Tomcat Server


posted 7 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

What do you mean couldn’t find it? Couldn’t find it during compilation? Packaging? Deploy? Run?

sam White

Ranch Hand

Posts: 229


posted 7 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Jayesh A Lalwani wrote:What do you mean couldn’t find it? Couldn’t find it during compilation? Packaging? Deploy? Run?

The war moudle coulding find the ejb jar file in .m2/repository/xyz-ejb/1.0/ folder.

How to define it in settings.xml file so that all my modules in different project find its dependant ejb modules in the .m2/repository/…. ?

Very appreciate for your help.

sam White

Ranch Hand

Posts: 229


posted 7 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

sam White wrote:

Jayesh A Lalwani wrote:What do you mean couldn’t find it? Couldn’t find it during compilation? Packaging? Deploy? Run?

The war moudle coulding find the ejb jar file in .m2/repository/xyz-ejb/1.0/ folder.

How to define it in settings.xml file so that all my modules in different project find its dependant ejb modules in the .m2/repository/…. ?

Very appreciate for your help.

Should I confiure ejb module to save its jar file to .m2/repository folder or configure the war module to read from the target/ folder in ejb module rather than referring to the .m2 / repository ?

sam White

Ranch Hand

Posts: 229


posted 7 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

sam White wrote:

sam White wrote:

Jayesh A Lalwani wrote:What do you mean couldn’t find it? Couldn’t find it during compilation? Packaging? Deploy? Run?

The war moudle coulding find the ejb jar file in .m2/repository/xyz-ejb/1.0/ folder.

How to define it in settings.xml file so that all my modules in different project find its dependant ejb modules in the .m2/repository/…. ?

Very appreciate for your help.

Should I confiure ejb module to save its jar file to .m2/repository folder or configure the war module to read from the target/ folder in ejb module rather than referring to the .m2 / repository ?

I am wondering whether there is any samples to cnofigure sesttings or pom.xml to deal with specific ejb jar file into local .m2 repository directory and then read from there from the war module pom.xml?

In JDK 9, you can use upgradeable modules or put the JAR files on the classpath.

The Java 9 migration guide states:

The java.endorsed.dirs system property and the lib/endorsed
directory are no longer present. The javac compiler and java
launcher will exit if either one is detected.

You would end up finding the error if any of these exists as :

<JAVA_HOME>/lib/endorsed is not supported. Endorsed standards and
standalone APIs in modular form will be supported via the concept of
upgradeable modules. Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

These endorsed-standards override mechanism was removed to attain Modular Run-Time Images and would now use the modular image.

A modular image is composed of modules rather than JAR files. Going
forward, endorsed standards and standalone APIs are supported in
modular form only, via the concept of upgradeable modules.

This is a specific solution but can probably be generalized. On System Version: macOS 10.14.6 (18G3020) Kernel Version: Darwin 18.7.0 I have OpenJDK 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing) and java_ee_sdk-8u1 installed.

I encountered this error when executing xjc:

[[email protected] bin 14:47:27] sudo ./xjc
-Djava.endorsed.dirs=./../modules/endorsed is not supported. Endorsed standards and standalone APIs
in modular form will be supported via the concept of upgradeable modules.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.enter code here

I edited the last line in ~/glassfish5/glassfish/bin/xjc to remove the -Djava.endorsed.dirs bit:
BEFORE

exec "$JAVA" -Djava.endorsed.dirs="$AS_INSTALL_LIB/endorsed" -cp "$AS_INSTALL_LIB/webservices-osgi.jar:$AS_INSTALL_LIB/javax.xml.rpc-api.jar:$AS_INSTALL_LIB/jaxb-osgi.jar" com.sun.tools.xjc.Driver "[email protected]"

AFTER

exec "$JAVA" -cp "$AS_INSTALL_LIB/webservices-osgi.jar:$AS_INSTALL_LIB/javax.xml.rpc-api.jar:$AS_INSTALL_LIB/jaxb-osgi.jar" com.sun.tools.xjc.Driver "[email protected]"

After which ~/glassfish5/glassfish/bin/xjc worked as expected

Tags:

Java

Java 9

Endorsed

Related

Понравилась статья? Поделить с друзьями:
  • Endless space 2 has detected an issue related to freetype dll как исправить
  • Endless legend как изменить язык
  • Ending error cs go
  • Endever effecting ideas ошибка е0
  • Enderal skse trampoline h 187 failed to handle allocation request ошибка