• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Migrating from 5.3.X t0 6.X.X spring framework and running into servlet issues

 
Ranch Hand
Posts: 416
  • Number of slices to send:
    Optional 'thank-you' note:
And running into some issues. Since spring 6 uses Jakarta EE, when I had the following import statement:



The following code worked fine:



However, when I changed it to :



Eclipse is complaining:

Type mismatch: cannot convert from javax.servlet.ServletContext to jakarta.servlet.ServletContext




FYI - WebContext is this if I mouse over it:



How should I fix this? Let me know if more info is needed.




 
Sheriff
Posts: 67748
173
  • Number of slices to send:
    Optional 'thank-you' note:
Why would you change it?
 
Jack Tauson
Ranch Hand
Posts: 416
  • Number of slices to send:
    Optional 'thank-you' note:

Bear Bibeault wrote:Why would you change it?



Is it not supposed to be changed while migrating? Should I keep it as it is "import javax.servlet.ServletContext;" ?
 
Marshal
Posts: 4525
572
  • Number of slices to send:
    Optional 'thank-you' note:
I'm not familiar with DWR, but it looks like the last (official?) version was org.directwebremoting:dwr:3.0.2-RELEASE dated 11-Dec-2016, and it has references to javax.servlet.http.

org.beangle.jakarta:beangle-jakarta-dwr:3.0.4-RELEASE dated 13-Nov-2020 seems to be a replacement which references jakarta.servlet.http.

The GitHub project for it can be found here.
 
Jack Tauson
Ranch Hand
Posts: 416
  • Number of slices to send:
    Optional 'thank-you' note:

Ron McLeod wrote:I'm not familiar with DWR, but it looks like the last (official?) version was org.directwebremoting:dwr:3.0.2-RELEASE dated 11-Dec-2016, and it has references to javax.servlet.http.

org.beangle.jakarta:beangle-jakarta-dwr:3.0.4-RELEASE dated 13-Nov-2020 seems to be a replacement which references jakarta.servlet.http.

The GitHub project for it can be found here.



Hmm, so I would probably keep it as it is if it’s possible or upgrade it with what you mentioned and see how it goes.

DWR works like Ajax calls in JavaScript.

 
Ron McLeod
Marshal
Posts: 4525
572
  • Number of slices to send:
    Optional 'thank-you' note:

Jack Tauson wrote:Hmm, so I would probably keep it as it is if it’s possible or upgrade it with what you mentioned and see how it goes.


I don't know enough to have a good opinion - try both approaches and see what works and what doesn't.
 
Jack Tauson
Ranch Hand
Posts: 416
  • Number of slices to send:
    Optional 'thank-you' note:

Ron McLeod wrote:

Jack Tauson wrote:Hmm, so I would probably keep it as it is if it’s possible or upgrade it with what you mentioned and see how it goes.


I don't know enough to have a good opinion - try both approaches and see what works and what doesn't.



Yeah, going to try both. It's just that if I decide to stay with the existing DWR org.directwebremoting:dwr:3.0.2-RELEASE dated 11-Dec-2016, then I can't get rid of Spring 5.3.X related dependency completely I believe from my pom.xml. I will test it out.  Thanks for your time and looking into it.
 
Saloon Keeper
Posts: 27851
196
  • Number of slices to send:
    Optional 'thank-you' note:
The first thing I do when I encounter an issue like this is to see if the project in question has been re-homed. Meaning that a more up-to-date version lives under a different website/package tree.

Unfortunately, there's nothing for DWR. In fact, the DWR homepage itself is no longer online. That counts as unsupported technology to me. Often a technology becomes unsupported because a better alternative has come along.

A quick check seems to indicate that jQuery plus a JSON library would be one alternative (which, incidentally, I've used without ever knowing of DWR). Note that if you're using JavaServer Faces, jQuery is already inside, although you may wish to override the default version, which tends to be fairly old.

Wholesale shuttling of Java objects between client and server for its own sake is something I don't encourage. It lends itself to easy hacking, so I'd be limiting the properties being transmitted to only what is essential.

One source recommended YAML. I'm a big YAML fan because of all the popular web service data formats (XML, JSON and YAML), it's the easiest to type, and like XML and JSON, you can source it from a JSP template. But I'm not sure I'd prefer it to JSON when used with AJAX or in JavaScript in general.
 
Jack Tauson
Ranch Hand
Posts: 416
  • Number of slices to send:
    Optional 'thank-you' note:

Tim Holloway wrote:The first thing I do when I encounter an issue like this is to see if the project in question has been re-homed. Meaning that a more up-to-date version lives under a different website/package tree.

Unfortunately, there's nothing for DWR. In fact, the DWR homepage itself is no longer online. That counts as unsupported technology to me. Often a technology becomes unsupported because a better alternative has come along.

A quick check seems to indicate that jQuery plus a JSON library would be one alternative (which, incidentally, I've used without ever knowing of DWR). Note that if you're using JavaServer Faces, jQuery is already inside, although you may wish to override the default version, which tends to be fairly old.

Wholesale shuttling of Java objects between client and server for its own sake is something I don't encourage. It lends itself to easy hacking, so I'd be limiting the properties being transmitted to only what is essential.

One source recommended YAML. I'm a big YAML fan because of all the popular web service data formats (XML, JSON and YAML), it's the easiest to type, and like XML and JSON, you can source it from a JSP template. But I'm not sure I'd prefer it to JSON when used with AJAX or in JavaScript in general.



Thank you. That worked for me in case of DWR. However, running into more issues:


I am using javax.print.PrintService interface (https://docs.oracle.com/javase/8/docs/api/javax/print/PrintService.html)


Do you know, what will be the equivalent one with Java EE? Seems like changing it to jakarta.print.PrintService , jakarta.print.PrintServiceLookup etc doesn't work? Similarly I couldn't find anything related to jakarta.crypto. Could be that these things never made it to jakarta EE but couldn't find clear answer to this online yet.
 
Sheriff
Posts: 22784
131
  • Number of slices to send:
    Optional 'thank-you' note:
Not everything that starts with javax is part of Java EE. Quite a lot are part of Java SE, for instance javax.net.ssl, javax.sql and javax.swing. javax.print and javax.crypto are also some of those. In other words - no need to change them.

There's one that you need to take a good look at - javax.xml. Part of it is Java SE, but javax.xml.bind is for JAXB which is part of Java EE, so that needs to be replaced. Likewise for javax.xml.ws.
 
Jack Tauson
Ranch Hand
Posts: 416
  • Number of slices to send:
    Optional 'thank-you' note:

Rob Spoor wrote:Not everything that starts with javax is part of Java EE. Quite a lot are part of Java SE, for instance javax.net.ssl, javax.sql and javax.swing. javax.print and javax.crypto are also some of those. In other words - no need to change them.

There's one that you need to take a good look at - javax.xml. Part of it is Java SE, but javax.xml.bind is for JAXB which is part of Java EE, so that needs to be replaced. Likewise for javax.xml.ws.



Thanks for clarifying. I thought of replacing every javax with jakarta.

I found this.

https://blogs.oracle.com/javamagazine/post/transition-from-java-ee-to-jakarta-ee

Do you think this is still an up to date reference to figure out what things were involved as far as javax to Java EE conversion is concerned?
 
Ron McLeod
Marshal
Posts: 4525
572
  • Number of slices to send:
    Optional 'thank-you' note:
As Rob just mentioned, the javax.print package was never part of Java EE, so it was not subject to any Java EE to Jakarta EE migration/renaming.
 
Rob Spoor
Sheriff
Posts: 22784
131
  • Number of slices to send:
    Optional 'thank-you' note:

Jack Tauson wrote:I found this.

https://blogs.oracle.com/javamagazine/post/transition-from-java-ee-to-jakarta-ee

Do you think this is still an up to date reference to figure out what things were involved as far as javax to Java EE conversion is concerned?


It still looks valid, although you should go to Java EE 9 instead of 8.

When in doubt you can use the search bar at https://docs.oracle.com/en/java/javase/22/docs/api/. Type in the package name - if it shows up you can keep it, otherwise it very likely needs to be changed to jakarta.
 
Jack Tauson
Ranch Hand
Posts: 416
  • Number of slices to send:
    Optional 'thank-you' note:

Rob Spoor wrote:

Jack Tauson wrote:I found this.

https://blogs.oracle.com/javamagazine/post/transition-from-java-ee-to-jakarta-ee

Do you think this is still an up to date reference to figure out what things were involved as far as javax to Java EE conversion is concerned?


It still looks valid, although you should go to Java EE 9 instead of 8.

When in doubt you can use the search bar at https://docs.oracle.com/en/java/javase/22/docs/api/. Type in the package name - if it shows up you can keep it, otherwise it very likely needs to be changed to jakarta.



Thank you. Yes, Spring 6 requires Java 17 and Java EE 9 so I am pretty sure I should be on Java EE 9. Not sure how to validate it though.
 
Tim Holloway
Saloon Keeper
Posts: 27851
196
  • Number of slices to send:
    Optional 'thank-you' note:
There is a utility that can take a Java source tree and  intelligently convert javax to jakarta. It's not 100% tuned to which is which - I had to change some JSF stuff manually - but it takes care of about 90% of the job automatically.

I used it to upgrade my Spring Boot Recipe Manager project.
 
Jack Tauson
Ranch Hand
Posts: 416
  • Number of slices to send:
    Optional 'thank-you' note:

Tim Holloway wrote:There is a utility that can take a Java source tree and  intelligently convert javax to jakarta. It's not 100% tuned to which is which - I had to change some JSF stuff manually - but it takes care of about 90% of the job automatically.

I used it to upgrade my Spring Boot Recipe Manager project.



Do you remember what utility is that?
 
Tim Holloway
Saloon Keeper
Posts: 27851
196
  • Number of slices to send:
    Optional 'thank-you' note:
I can't remember breakfast. And it's not even 7 a.m.

But I think it was this: https://github.com/apache/tomcat-jakartaee-migration
 
Jack Tauson
Ranch Hand
Posts: 416
  • Number of slices to send:
    Optional 'thank-you' note:

Tim Holloway wrote:I can't remember breakfast. And it's not even 7 a.m.

But I think it was this: https://github.com/apache/tomcat-jakartaee-migration



Thanks.  Does anyone know how can I handle this issue:

There's a org.apache.commons.mail.util.MimeMessageParser used in my code and since I am migrating  to jakarta ee, MimeMessageParser class still makes uses of javax related stuff instead of jakarta, I am wondering how should I handle this as commons mail doesn't have jakarta ee equivalent I believe?
 
Tim Holloway
Saloon Keeper
Posts: 27851
196
  • Number of slices to send:
    Optional 'thank-you' note:
The utility can handle the more common cases, but to do a completely clean conversion I did have to manually fix some things. It was less work than having to do it ALL by hand, though!
 
Jack Tauson
Ranch Hand
Posts: 416
  • Number of slices to send:
    Optional 'thank-you' note:

Tim Holloway wrote: do a completely clean conversion I did have to manually fix some things. It was less work than having to do it ALL by hand, though!



Sorry, I didn't understand it. Did you mean there's any other alternative available for org.apache.commons.mail.util.MimeMessageParser class where I could use jakarta instead of javax? I was wondering if I should be decompiling the class in some way and the manually change the javax to jakarta
 
Saloon Keeper
Posts: 15608
366
  • Number of slices to send:
    Optional 'thank-you' note:
Tim just meant that there are no automated fixes for ALL migration issues. You have to figure out some of the fixes by yourself.

There are two different approaches I would take for this particular issue, depending on how strongly your application depends on MimeMessageParser.

  • My preferred solution is to just dump Commons Email, and take what you need from MimeMessage directly.
  • The second solution it to add Apache's snapshot repository to your POM, and add a dependency on the latest snapshot of Commons Email, which works with Jakarta Mail.
  •  
    Jack Tauson
    Ranch Hand
    Posts: 416
    • Number of slices to send:
      Optional 'thank-you' note:

    Stephan van Hulst wrote:

  • The second solution it to add Apache's snapshot repository to your POM, and add a dependency on the latest snapshot of Commons Email, which works with Jakarta Mail.


  • Thanks. Did you mean to add this?

    https://mvnrepository.com/artifact/org.apache.commons/commons-email/1.6.0

    Not sure if I'm looking at the right one as it doesn't mention about jakarta.
     
    Stephan van Hulst
    Saloon Keeper
    Posts: 15608
    366
    • Number of slices to send:
      Optional 'thank-you' note:
    No. What I meant was this:
     
    Jack Tauson
    Ranch Hand
    Posts: 416
    • Number of slices to send:
      Optional 'thank-you' note:

    Stephan van Hulst wrote:No. What I meant was this:



    Thanks. That did solve some other issues but it looks like there's some different package name for org.apache.commons.mail.util as I am getting a compilation failure saying package org.apache.commons.mail.util does not exist on the following import:


    Do I need to change the import to something different? How can I figure this out?
     
    Marshal
    Posts: 28258
    95
    • Number of slices to send:
      Optional 'thank-you' note:

    Jack Tauson wrote:Thanks. That did solve some other issues but it looks like there's some different package name for org.apache.commons.mail.util as I am getting a compilation failure saying package org.apache.commons.mail.util does not exist on the following import:
    Do I need to change the import to something different? How can I figure this out?


    That's really what it's called in the commons.apache.org website, where I just looked. Perhaps you're downloading some other version of JavaMail from somewhere else?
     
    Jack Tauson
    Ranch Hand
    Posts: 416
    • Number of slices to send:
      Optional 'thank-you' note:

    Jack Tauson wrote:

    Thanks. That did solve some other issues but it looks like there's some different package name for org.apache.commons.mail.util as I am getting a compilation failure saying package org.apache.commons.mail.util does not exist on the following import:


    Do I need to change the import to something different? How can I figure this out?



    I found it here : https://github.com/apache/commons-email/tree/master/commons-email2-jakarta/src/main/java/org/apache/commons/mail2/jakarta/util



    May I know why this was not preferred option for you and is there any disadvantage of using snapshot? Sounds like it's not yet completed version?
     
    Paul Clapham
    Marshal
    Posts: 28258
    95
    • Number of slices to send:
      Optional 'thank-you' note:

    Jack Tauson wrote:May I know why this was not preferred option for you and is there any disadvantage of using snapshot? Sounds like it's not yet completed version?



    If that's addressed to me: I don't have a "preferred" option. I just looked in the obvious place and found the class with the expected package name. Note that the message you posted doesn't tell you whether the class is just plain not there or whether it's there but in a different package.
     
    Jack Tauson
    Ranch Hand
    Posts: 416
    • Number of slices to send:
      Optional 'thank-you' note:

    Paul Clapham wrote:
    If that's addressed to me: I don't have a "preferred" option. I just looked in the obvious place and found the class with the expected package name. Note that the message you posted doesn't tell you whether the class is just plain not there or whether it's there but in a different package.



    Thanks. Yeah, I only figured after looking at this URL ( https://github.com/apache/commons-email/tree/master/commons-email2-jakarta/src/main/java/org/apache/commons/mail2/jakarta/util) and found out that the class is there.
     
    Stephan van Hulst
    Saloon Keeper
    Posts: 15608
    366
    • Number of slices to send:
      Optional 'thank-you' note:

    Jack Tauson wrote:May I know why this was not preferred option for you and is there any disadvantage of using snapshot? Sounds like it's not yet completed version?


    Correct. Snapshot releases are not stable, and may change at any given moment (Maven may even overwrite the version you have cached in your local repository). Therefore, your application may break without any warning.

    Normally I'd avoid this situation, but Apache is good about avoiding the introduction of breaking changes, and it also appears that they are about to release a stable version of this dependency.

    I recommend that you use this snapshot release until Apache releases a stable version, which could be any day now. Check the central Maven repo periodically.
     
    Jack Tauson
    Ranch Hand
    Posts: 416
    • Number of slices to send:
      Optional 'thank-you' note:

    Stephan van Hulst wrote:

    Jack Tauson wrote:May I know why this was not preferred option for you and is there any disadvantage of using snapshot? Sounds like it's not yet completed version?


    Correct. Snapshot releases are not stable, and may change at any given moment (Maven may even overwrite the version you have cached in your local repository). Therefore, your application may break without any warning.

    Normally I'd avoid this situation, but Apache is good about avoiding the introduction of breaking changes, and it also appears that they are about to release a stable version of this dependency.

    I recommend that you use this snapshot release until Apache releases a stable version, which could be any day now. Check the central Maven repo periodically.



    Thanks. And this will be the place to keep an eye on the release - right?

    https://mvnrepository.com/artifact/org.apache.commons/commons-email

    I believe they are gonna come with 2.0 . It's at 1.6 right now
     
    Stephan van Hulst
    Saloon Keeper
    Posts: 15608
    366
    • Number of slices to send:
      Optional 'thank-you' note:
    Yes, I believe so.
     
    Tim Holloway
    Saloon Keeper
    Posts: 27851
    196
    • Number of slices to send:
      Optional 'thank-you' note:
    I'm going to make some possibly-stupid remarks here, so feel free to correct me.

    The first thing that came to mind when I saw all the grief with Commons Mail was "has this facility become obsolete"? That is, replaced by something else? The answer appears no, but not having an update since 2018 isn't a warm fuzzy feeling.

    I understand a Jakarta-compatible production release is due Real Soon Now, but there doesn't seem to be much urgency to it, which itself sets off more questions.

    Thus the second question: Has Jakarta Mail gained enough functionality that Commons Mail isn't necessary anymore? Probably not, but I can't tell offhand.

    And the last question: does this app use raw Apache Commons Main in application code or does it use Spring Mail? Spring's development is generally more active, so it's possible that they'd already worked around the issue.
     
    Greenhorn
    Posts: 1
    • Number of slices to send:
      Optional 'thank-you' note:
    I am getting "Could not find org.apache.commons:commons-email2-jakarta:2.0.0-M1-SNAPSHOT" after including uri("https://repository.apache.org/content/repositories/snapshots/")
    I wonder if commons-email2-jakarta:2.0.0-M1-SNAPSHOT was removed?
     
    Stephan van Hulst
    Saloon Keeper
    Posts: 15608
    366
    • Number of slices to send:
      Optional 'thank-you' note:
    Welcome to CodeRanch!

    It wasn't removed.

    Please show us your build definition file.
    reply
      Bookmark Topic Watch Topic
    • New Topic
    vceplus-200-125    | boson-200-125    | training-cissp    | actualtests-cissp    | techexams-cissp    | gratisexams-300-075    | pearsonitcertification-210-260    | examsboost-210-260    | examsforall-210-260    | dumps4free-210-260    | reddit-210-260    | cisexams-352-001    | itexamfox-352-001    | passguaranteed-352-001    | passeasily-352-001    | freeccnastudyguide-200-120    | gocertify-200-120    | passcerty-200-120    | certifyguide-70-980    | dumpscollection-70-980    | examcollection-70-534    | cbtnuggets-210-065    | examfiles-400-051    | passitdump-400-051    | pearsonitcertification-70-462    | anderseide-70-347    | thomas-70-533    | research-1V0-605    | topix-102-400    | certdepot-EX200    | pearsonit-640-916    | itproguru-70-533    | reddit-100-105    | channel9-70-346    | anderseide-70-346    | theiia-IIA-CIA-PART3    | certificationHP-hp0-s41    | pearsonitcertification-640-916    | anderMicrosoft-70-534    | cathMicrosoft-70-462    | examcollection-cca-500    | techexams-gcih    | mslearn-70-346    | measureup-70-486    | pass4sure-hp0-s41    | iiba-640-916    | itsecurity-sscp    | cbtnuggets-300-320    | blogged-70-486    | pass4sure-IIA-CIA-PART1    | cbtnuggets-100-101    | developerhandbook-70-486    | lpicisco-101    | mylearn-1V0-605    | tomsitpro-cism    | gnosis-101    | channel9Mic-70-534    | ipass-IIA-CIA-PART1    | forcerts-70-417    | tests-sy0-401    | ipasstheciaexam-IIA-CIA-PART3    | mostcisco-300-135    | buildazure-70-533    | cloudera-cca-500    | pdf4cert-2v0-621    | f5cisco-101    | gocertify-1z0-062    | quora-640-916    | micrcosoft-70-480    | brain2pass-70-417    | examcompass-sy0-401    | global-EX200    | iassc-ICGB    | vceplus-300-115    | quizlet-810-403    | cbtnuggets-70-697    | educationOracle-1Z0-434    | channel9-70-534    | officialcerts-400-051    | examsboost-IIA-CIA-PART1    | networktut-300-135    | teststarter-300-206    | pluralsight-70-486    | coding-70-486    | freeccna-100-101    | digitaltut-300-101    | iiba-CBAP    | virtuallymikebrown-640-916    | isaca-cism    | whizlabs-pmp    | techexams-70-980    | ciscopress-300-115    | techtarget-cism    | pearsonitcertification-300-070    | testking-2v0-621    | isacaNew-cism    | simplilearn-pmi-rmp    | simplilearn-pmp    | educationOracle-1z0-809    | education-1z0-809    | teachertube-1Z0-434    | villanovau-CBAP    | quora-300-206    | certifyguide-300-208    | cbtnuggets-100-105    | flydumps-70-417    | gratisexams-1V0-605    | ituonline-1z0-062    | techexams-cas-002    | simplilearn-70-534    | pluralsight-70-697    | theiia-IIA-CIA-PART1    | itexamtips-400-051    | pearsonitcertification-EX200    | pluralsight-70-480    | learn-hp0-s42    | giac-gpen    | mindhub-102-400    | coursesmsu-CBAP    | examsforall-2v0-621    | developerhandbook-70-487    | root-EX200    | coderanch-1z0-809    | getfreedumps-1z0-062    | comptia-cas-002    | quora-1z0-809    | boson-300-135    | killtest-2v0-621    | learncia-IIA-CIA-PART3    | computer-gcih    | universitycloudera-cca-500    | itexamrun-70-410    | certificationHPv2-hp0-s41    | certskills-100-105    | skipitnow-70-417    | gocertify-sy0-401    | prep4sure-70-417    | simplilearn-cisa    |
    http://www.pmsas.pr.gov.br/wp-content/    | http://www.pmsas.pr.gov.br/wp-content/    |