Coder Social home page Coder Social logo

Problems with Java 17 about orika HOT 20 OPEN

ptahchiev avatar ptahchiev commented on June 20, 2024 32
Problems with Java 17

from orika.

Comments (20)

jangatt avatar jangatt commented on June 20, 2024 28

Encountered the same issue, as a workaround you can set the following VM option

--add-opens java.base/java.lang=ALL-UNNAMED

from orika.

lordlamer avatar lordlamer commented on June 20, 2024 25

Hi,
any news here?
People are still waiting for this.

from orika.

cheekymonkat avatar cheekymonkat commented on June 20, 2024 16

Any plans on releasing 1.6.0? We use this library extensively and although the workaround is fine its not ideal.

from orika.

aman-singla30 avatar aman-singla30 commented on June 20, 2024 5

Hi Team, Any update on new version of orika core which is compatible with JDK17. I am facing same issue.

from orika.

oliverlockwood avatar oliverlockwood commented on June 20, 2024 4

@elaatifi should we consider this project dead?

from orika.

M-Sharjeel-Tariq avatar M-Sharjeel-Tariq commented on June 20, 2024 4

Unfortunately, no. I have been following Orika Mapper since the start of 2022. There are no updates rolling out.
For the time being, as a workaround we used the following flag as VM Option
--add-opens java.base/java.lang=ALL-UNNAMED
But we conducted a research and found Mapstruct to be the closest best alternative to Orika. I would suggest everyone to consider migrating to another Mapper.

from orika.

JoepWeijers avatar JoepWeijers commented on June 20, 2024 3

Seems that this will be fixed in the 1.6.0 version. I'm waiting for that to release.

from orika.

beatjost avatar beatjost commented on June 20, 2024 2

For those using the Gradle JIB-Plugin, solved it as follows:

container {
	jvmFlags = ['--add-opens=java.base/java.lang=ALL-UNNAMED', '-XX:+UseContainerSupport', '-XX:MaxRAMPercentage=75.0']

from orika.

 avatar commented on June 20, 2024 1

+1 saw this with eclipse adoptium 17.0.1.12-hotspot. Reverted to openjdk11 and all was fine.

from orika.

boopsd avatar boopsd commented on June 20, 2024 1

遇到同样的问题,作为一种解决方法,您可以设置以下 VM 选项

--add-opens java.base/java.lang=ALL-UNNAMED

after set this ,not good

from orika.

Ares9999 avatar Ares9999 commented on June 20, 2024 1

So I tried my code with Java 17 and I get this exception:

Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected native java.lang.Object java.lang.Object.clone() throws java.lang.CloneNotSupportedException accessible: module java.base does not "opens java.lang" to unnamed module @46d21ee0
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
	at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
	at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
	at ma.glasnost.orika.converter.builtin.CloneableConverter.<init>(CloneableConverter.java:64)
	at ma.glasnost.orika.converter.builtin.CloneableConverter$Builtin.<init>(CloneableConverter.java:221)
	at ma.glasnost.orika.converter.builtin.BuiltinConverters.register(BuiltinConverters.java:135)
	at ma.glasnost.orika.impl.DefaultMapperFactory.build(DefaultMapperFactory.java:1278)
	at io.nemesis.platform.core.mapper.MixinAwareMapperFactory.build(MixinAwareMapperFactory.java:160)
	at ma.glasnost.orika.impl.DefaultMapperFactory.getMapperFacade(DefaultMapperFactory.java:881)

use below in your VM arg
--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED

from orika.

wolfomat avatar wolfomat commented on June 20, 2024 1

okay, seems to be dead. one year later, the 1.6.0 is not yet released. I'll go for another mapper-option. schade.

from orika.

pierrick-boule avatar pierrick-boule commented on June 20, 2024 1

Hello

We are using a workaround since last year in order to migrate on jdk17 without --add-opens, this allow the depreciation of Orika without rushing because of jdk17, off course "use it with caution"

The workaround is :

  • switch from the default JavassistCompilerStrategy to EclipseJdtCompilerStrategy
  • disable the default builtin converters
  • add only jdk17 ready converters, and rewrite if not compatible

snippets :

        <dependency>
            <groupId>ma.glasnost.orika</groupId>
            <artifactId>orika-eclipse-tools</artifactId>
            <version>1.5.4</version>
        </dependency>
@Deprecated(forRemoval = true)
public class BidouilleOrikaMapperFactory {

    public static MapperFactory defaultMapperFactory() {
        return new DefaultMapperFactory.Builder()
                .useBuiltinConverters(false)
                .converterFactory(new BidouilleOrikaConverterFactory())
                .compilerStrategy(new BidouilleOrikaCompilerStrategy())
                .build();
    }
}
@Deprecated(forRemoval = true)
public class BidouilleOrikaCompilerStrategy extends EclipseJdtCompilerStrategy {

    @Override
    protected void writeSourceFile(String sourceText, String packageName, String className) throws IOException {

    }
}

see https://github.com/orika-mapper/orika/blob/master/core/src/main/java/ma/glasnost/orika/converter/builtin/BuiltinConverters.java#L77
do not use makeSimpleConverter and rewrite them without reflection if needed (Date is on of them) .

@Deprecated(forRemoval = true)
public class BidouilleOrikaConverterFactory extends DefaultConverterFactory {
    public BidouilleOrikaConverterFactory() {
        super();
        this.registerConverter(new CopyByReferenceConverter());

        this.registerConverter(new EnumConverter());

        /*
         * Register to/from string converters
         */
        this.registerConverter(new FromStringConverter());
        this.registerConverter(new ToStringConverter());

        /*
         * Register common date/time converters
         */
        this.registerConverter(new DateAndTimeConverters.DateToXmlGregorianCalendarConverter());
        this.registerConverter(new DateAndTimeConverters.DateToTimeConverter());
        this.registerConverter(new DateAndTimeConverters.CalendarToXmlGregorianCalendarConverter());
        this.registerConverter(new DateAndTimeConverters.XmlGregorianCalendarToTimestampConverter());
        this.registerConverter(new DateAndTimeConverters.XmlGregorianCalendarToSqlDateConverter());
        this.registerConverter(new DateAndTimeConverters.XmlGregorianCalendarToTimeConverter());
        this.registerConverter(new DateAndTimeConverters.LongToXmlGregorianCalendarConverter());

        this.registerConverter(new DateAndTimeConverters.DateToCalendarConverter());
        this.registerConverter(new DateAndTimeConverters.CalendarToTimeConverter());
        this.registerConverter(new DateAndTimeConverters.CalendarToSqlDateConverter());
        this.registerConverter(new DateAndTimeConverters.LongToCalendarConverter());
        this.registerConverter(new DateAndTimeConverters.TimestampToCalendarConverter());

        this.registerConverter(new DateAndTimeConverters.DateToSqlDateConverter());
        this.registerConverter(new DateAndTimeConverters.LongToSqlDateConverter());
        this.registerConverter(new DateAndTimeConverters.TimeToSqlDateConverter());
        this.registerConverter(new DateAndTimeConverters.TimestampToSqlDateConverter());

        this.registerConverter(new DateAndTimeConverters.LongToTimeConverter());
        this.registerConverter(new DateAndTimeConverters.TimestampToTimeConverter());

        this.registerConverter(new DateAndTimeConverters.LongToTimestampConverter());
        this.registerConverter(new DateAndTimeConverters.DateToTimestampConverter());

        this.registerConverter(new DateAndTimeConverters.LongToDateConverter());

        /*
         * Register numeric type converter
         */
        this.registerConverter(new NumericConverters.BigDecimalToDoubleConverter());
        this.registerConverter(new NumericConverters.BigDecimalToFloatConverter());
        this.registerConverter(new NumericConverters.BigIntegerToIntegerConverter(false));
        this.registerConverter(new NumericConverters.BigIntegerToLongConverter(false));

        this.registerConverter(new NumericConverters.IntegerToShortConverter(false));
        this.registerConverter(new NumericConverters.LongToIntegerConverter(false));
        this.registerConverter(new NumericConverters.LongToShortConverter(false));

        this.registerConverter(new NumericConverters.FloatToShortConverter(false));
        this.registerConverter(new NumericConverters.FloatToIntegerConverter(false));
        this.registerConverter(new NumericConverters.FloatToLongConverter(false));

        this.registerConverter(new NumericConverters.DoubleToShortConverter(false));
        this.registerConverter(new NumericConverters.DoubleToIntegerConverter(false));
        this.registerConverter(new NumericConverters.DoubleToLongConverter(false));
        /*
         * Register converter to instantiate by using a constructor on the
         * destination which takes the source as argument
         */
        this.registerConverter(new ConstructorConverter());
    }
}

from orika.

stapetro avatar stapetro commented on June 20, 2024

Hi @oliverlockwood , you can see my comment from #372 . Unfortunately it seems dead to me for quite time. 😞

from orika.

M-Sharjeel-Tariq avatar M-Sharjeel-Tariq commented on June 20, 2024

I was upgrading an API to Java 17 when I faced exact same issue. In a desperate final attempt I changed the maven version from 3.3.9 to 3.8.5 and the error message changed to the following
"The dependencies of some of the beans in the application context form a cycle:"
I added @lazy annotation at one of the beans and now my API is working absolutely fine.

from orika.

eebrukaya avatar eebrukaya commented on June 20, 2024

Did you fix the issue? I'm still struggling with this issue... @wolfomat

from orika.

rivancic avatar rivancic commented on June 20, 2024

Does anyone have experience using Orika mapper and GraalVM native image?
Do you need to provide extra metadata for the classes that will be mapped at runtime?

from orika.

vanditshah99 avatar vanditshah99 commented on June 20, 2024

Any updates on the existing issue? We need a mapper that uses reflections as we need run time mapping based on versioning logic of ours. Any new project or libraries that can be used which handles Java 17 and Spring Boot 3.0.6 and is managed actively. Thanks!

from orika.

rever67697 avatar rever67697 commented on June 20, 2024

Any updates ???

from orika.

catalyst26 avatar catalyst26 commented on June 20, 2024

Hi I'm facing a similar issue using TMC Beans for the Helsinki MOOC in JAVA. How can I get to the VM Option to use the flag?

Unable to make protected native java.lang.Object java.lang.Object.clone() throws java.lang.CloneNotSupportedException accessible: module java.base does not "opens java.lang" to unnamed module @3191379a

[java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)] [java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)] [java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)]
[java.lang.reflect.Method.setAccessible(Method.java:193)]
org.powermock.reflect.internal.WhiteboxImpl.doGetAllMethods(WhiteboxImpl.java:1499) org.powermock.reflect.internal.WhiteboxImpl.getAllMethods(WhiteboxImpl.java:1473) org.powermock.reflect.internal.WhiteboxImpl.findMethodOrThrowException(WhiteboxImpl.java:853) org.powermock.reflect.internal.WhiteboxImpl.doInvokeMethod(WhiteboxImpl.java:813) org.powermock.reflect.internal.WhiteboxImpl.invokeMethod(WhiteboxImpl.java:681) org.powermock.reflect.Whitebox.invokeMethod(Whitebox.java:401) org.powermock.classloading.AbstractClassloaderExecutor.getResult(AbstractClassloaderExecutor.java:76) org.powermock.classloading.AbstractClassloaderExecutor.invokeWithClassLoader(AbstractClassloaderExecutor.java:64) org.powermock.classloading.AbstractClassloaderExecutor.executeWithClassLoader(AbstractClassloaderExecutor.java:56) org.powermock.classloading.SingleClassloaderExecutor.execute(SingleClassloaderExecutor.java:33) org.powermock.classloading.AbstractClassloaderExecutor.execute(AbstractClassloaderExecutor.java:40) org.powermock.modules.junit4.rule.PowerMockStatement.evaluate(PowerMockRule.java:75) org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) org.junit.runners.ParentRunner.run(ParentRunner.java:309) fi.helsinki.cs.tmc.testrunner.TestRunner$TestingRunnable.runTestCase(TestRunner.java:134) fi.helsinki.cs.tmc.testrunner.TestRunner$TestingRunnable.doRun(TestRunner.java:89) fi.helsinki.cs.tmc.testrunner.TestRunner$TestingRunnable.run(TestRunner.java:70) java.lang.Thread.run(Thread.java:833)

from orika.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.