History | Log In     View a printable version of the current page. Get help!  
Issue Details [XML]

Key: EJB-64
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Blocker Blocker
Assignee: Vance Karimi
Reporter: Leandro Hermida
Votes: (View)
Watchers: (View)
Operations

If you were logged in you would be able to see more operations.
EJB Cartridge

Seam project won't build: missing andromda-plugins-profiles

Created: 20/Jun/07 12:05 PM   Updated: 05/Jul/07 04:28 PM
Component/s: None
Affects Version/s: None
Fix Version/s: None

File Attachments: 1. File andromda-plugins-profiles-uml2-1.0-SNAPSHOT.pom (0.8 kb)



 Description   
When building my first Seam project (mvn install), I get the following error because it cannot find a dependency:

Downloading: http://team.andromda.org/maven2/org/andromda/profiles/uml2/andromda-plugins-profiles-uml2/1.0-SNAPSHOT/andromda-plugins-profiles-uml2-1.0-SNAPSHOT.pom
[WARNING] Unable to get resource 'org.andromda.profiles.uml2:andromda-plugins-profiles-uml2:pom:1.0-SNAPSHOT' from repository andromda (http://team.andromda.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

GroupId: org.andromda.profiles.uml2
ArtifactId: andromda-plugins-profiles-uml2
Version: 1.0-SNAPSHOT

Reason: Unable to download the artifact from any repository

  org.andromda.profiles.uml2:andromda-plugins-profiles-uml2:pom:1.0-SNAPSHOT

from the specified remote repositories:
  central (http://repo1.maven.org/maven2),
  andromda (http://team.andromda.org/maven2)


[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Wed Jun 20 11:41:14 CEST 2007
[INFO] Final Memory: 7M/254M
[INFO] ------------------------------------------------------------------------


Examining further it is the andromda-profile-seam-1.1-SNAPSHOT that requires this dependency. In $M2_REPO/org/andromda/profiles/uml2/andromda-profile-seam/1.1-SNAPSHOT/andromda-profile-seam-1.1-SNAPSHOT.pom:

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.andromda.profiles.uml2</groupId>
        <artifactId>andromda-plugins-profiles-uml2</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <packaging>xml.zip</packaging>
    <artifactId>andromda-profile-seam</artifactId>
    <name>AndroMDA Plugins UML 2.0 Seam Profile</name>
    <version>1.1-SNAPSHOT</version>
    <description>Seam UML 2.0 profile which can be used with the AndroMDA Seam-EJB3 cartridges</description>
</project>

Where do I get or build andromda-plugins-profiles-uml2-1.0-SNAPSHOT? It seems to me that it should be like the parent of the core andromda profiles, andromda-profiles-uml2-3.3-SNAPSHOT. The andromda-profiles-uml2-3.3-SNAPSHOT.pom file looks like this:

<project>
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.andromda.profiles</groupId>
        <artifactId>andromda-profiles</artifactId>
        <version>3.3-SNAPSHOT</version>
    </parent>
    <groupId>org.andromda.profiles.uml2</groupId>
    <artifactId>andromda-profiles-uml2</artifactId>
    <name>AndroMDA UML 2.0 Profile</name>
    <packaging>pom</packaging>
<description>
        Contains the AndroMDA UML 2.0 profiles.
    </description>
    <build>
        <plugins>
            <plugin>
                <groupId>org.andromda.maven.plugins</groupId>
                <artifactId>andromda-model-archiver-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
    <modules>
        <module>common</module>
        <module>datatype</module>
        <module>messaging</module>
        <module>meta</module>
        <module>persistence</module>
        <module>presentation</module>
        <module>process</module>
        <module>service</module>
        <module>webservice</module>
        <module>xml</module>
    </modules>
</project>

How should I create andromda-plugins-profiles-uml2-1.0-SNAPSHOT? Like this maybe?

<project>
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.andromda.profiles</groupId>
        <artifactId>andromda-profiles</artifactId>
        <version>3.3-SNAPSHOT</version>
    </parent>
    <groupId>org.andromda.profiles.uml2</groupId>
    <artifactId>andromda-plugins-profiles-uml2</artifactId>
    <name>AndroMDA Plugins UML 2.0 Profile</name>
    <packaging>pom</packaging>
<description>
        Contains the AndroMDA Plugins UML 2.0 profiles.
    </description>
    <build>
        <plugins>
            <plugin>
                <groupId>org.andromda.maven.plugins</groupId>
                <artifactId>andromda-model-archiver-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
    <modules>
        <module>seam</module>
    </modules>
</project>


Thanks,

Leandro


 All   Comments   Change History      Sort Order:
Comment by Leandro Hermida [20/Jun/07 01:29 PM]
I have attached my version of $M2_REPO/org/andromda/profiles/uml2/andromda-plugins-profiles-uml2/1.0-SNAPSHOT/andromda-plugins-profiles-uml2-1.0-SNAPSHOT.pom.

This got me past the error mentioned when building. Now I have another error but that's a different story :)

Comment by Vance Karimi [21/Jun/07 04:18 PM]
Can you make sure your AndroMDA 3.3-SNAPSHOT source is up to date and freshly built. Then use the andromdapp generator to generate an ejb3 + seam sample project. Build that and see if you still get this problem. I cannot replicate it.

It may possibly be due to the wrong dependency of the profile in the pom.xml (uml1.4 profiles in uml2 projects rather than uml2 profiles) - prior to the fix made a couple of days ago.

Lastly, if you still cannot get it working, maybe try cleaning your M2 repo/andromda folder and give it another try.

Pls confirm when you can.

Comment by Leandro Hermida [22/Jun/07 11:50 AM]
Hi,

Still doesn't work. I blew away my $M2_REPO, got the latest andromda-all and andromda-plugins and built them. Then ran:

[hermida@fc6-leandro01 andromda_projects]$ mvn org.andromda.maven.plugins:andromdapp-maven-plugin:generate
[INFO] Scanning for projects...
[INFO] ----------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [org.andromda.maven.plugins:andromdapp-maven-plugin:generate] (aggregator-style)
[INFO] ----------------------------------------------------------------------------
[INFO] [andromdapp:generate]
log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester).
log4j:WARN Please initialize the log4j system properly.
INFO [AndroMDA] discovered andromdapp type --> 'richclient'
INFO [AndroMDA] discovered andromdapp type --> 'j2ee'

Please choose the type of application to generate [richclient, j2ee]
j2ee

Please enter the location in which your new application will be created (i.e. f:/java/development):
/home/hermida/andromda_projects

Please enter your first and last name (i.e. Chad Brandon):
Leandro Hermida

Which kind of modeling tool will you use? [uml1.4, uml2, emf-uml2]:
uml2

Please enter the name of your J2EE project (i.e. Animal Quiz):
Test01

Please enter an id for your J2EE project (i.e. animalquiz):
test01

Please enter a version for your project (i.e. 1.0-SNAPSHOT):
0.1

Please enter the root package name for your J2EE project (i.e. org.andromda.samples.animalquiz):
org.fmi.test

Would you like an EAR or standalone WAR? [ear, war]:
ear

Please enter the type of transactional/persistence cartridge to use [hibernate, ejb, ejb3, spring, none]:
ejb3

Please enter the database backend for the persistence layer [hypersonic, mysql, oracle, db2, informix, mssql, pointbase, postgres, sybase, sabdb, progress, derby]:
mysql

Will your project need workflow engine capabilities? (it uses jBPM and Hibernate3)? [yes, no]:
yes

Will your project have a web user interface? [yes, no]:
yes

Would you like your web user interface to use JSF or Struts? [jsf, struts]:
jsf

Would you like to use Facelets or JSP as your view type for JSF? [facelets, jsp]:
facelets

Would you like to use the JBoss Seam application framework? [yes, no]:
yes

Would you like to be able to expose your services as web services? [yes, no]:
yes

Would you like to use the JSR181 (webservice defined by annotations) EJB3 cartridge specific implementation? [yes, no]:
yes
-------------------------------------------------------------------------------------
    G e n e r a t i n g A n d r o M D A P o w e r e d A p p l i c a t i o n
-------------------------------------------------------------------------------------
    Output: 'file:/home/hermida/andromda_projects/test01/app/src/main/application/META-INF/jboss-app.xml'
    Output: 'file:/home/hermida/andromda_projects/test01/app/src/main/config/test01-ds.xml'
    Output: 'file:/home/hermida/andromda_projects/test01/app/pom.xml'
    Output: 'file:/home/hermida/andromda_projects/test01/core/target/classes/META-INF/ejb-jar.xml'
    Output: 'file:/home/hermida/andromda_projects/test01/core/pom.xml'
    Output: 'file:/home/hermida/andromda_projects/test01/pom.xml'
    Output: 'file:/home/hermida/andromda_projects/test01/readme.txt'
    Output: 'file:/home/hermida/andromda_projects/test01/common/pom.xml'
    Output: 'file:/home/hermida/andromda_projects/test01/mda/src/main/config/mappings/WebMergeMappings.xml'
    Output: 'file:/home/hermida/andromda_projects/test01/mda/src/main/config/andromda.xml'
    Output: 'file:/home/hermida/andromda_projects/test01/mda/src/main/uml/test01.xml'
    Output: 'file:/home/hermida/andromda_projects/test01/mda/pom.xml'
    Output: 'file:/home/hermida/andromda_projects/test01/web/src/main/properties/messages.properties'
    Output: 'file:/home/hermida/andromda_projects/test01/web/pom.xml'
    Output: 'file:/home/hermida/andromda_projects/test01/web/target/test01-web-0.1/WEB-INF/web.xml'
    Output: 'file:/home/hermida/andromda_projects/test01/workflow/pom.xml'
-------------------------------------------------------------------------------------
    New application generated to --> 'file:/home/hermida/andromda_projects/test01/'
    Instructions for your new application --> 'file:/home/hermida/andromda_projects/test01/readme.txt'
-------------------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 10 seconds
[INFO] Finished at: Fri Jun 22 11:28:57 CEST 2007
[INFO] Final Memory: 21M/254M
[INFO] ------------------------------------------------------------------------


Then cd into test01 directory and did mvn install and I get:

[hermida@fc6-leandro01 test01]$ mvn install
[INFO] Scanning for projects...
[INFO] Reactor build order:
[INFO] Test01
[INFO] Test01 MDA
[INFO] Test01 Common
[INFO] Test01 Workflow Module
[INFO] Test01 Core Business Tier
[INFO] Test01 Web
[INFO] Test01 Application
[INFO] ----------------------------------------------------------------------------
[INFO] Building Test01
[INFO] task-segment: [install]
[INFO] ----------------------------------------------------------------------------
[INFO] artifact org.apache.maven.plugins:maven-site-plugin: checking for updates from andromda
[INFO] artifact org.apache.maven.plugins:maven-install-plugin: checking for updates from andromda
[INFO] [site:attach-descriptor]
[INFO] [install:install]
[INFO] Installing /home/hermida/andromda_projects/test01/pom.xml to /home/hermida/.m2/repository/org/fmi/test/test01/0.1/test01-0.1.pom
[INFO] ----------------------------------------------------------------------------
[INFO] Building Test01 MDA
[INFO] task-segment: [install]
[INFO] ----------------------------------------------------------------------------
[INFO] snapshot org.andromda.maven.plugins:andromda-maven-plugin:3.3-SNAPSHOT: checking for updates from andromda
4K downloaded
[INFO] snapshot org.andromda.maven.plugins:andromda-maven-plugins:3.3-SNAPSHOT: checking for updates from andromda
1K downloaded
[INFO] snapshot org.andromda:andromda:3.3-SNAPSHOT: checking for updates from andromda
10K downloaded
25K downloaded
[INFO] snapshot org.andromda.maven.plugins:andromdapp-maven-plugin:3.3-SNAPSHOT: checking for updates from andromda
5K downloaded
62K downloaded
Downloading: http://team.andromda.org/maven2/org/testng/testng/4.7/testng-4.7.pom
[WARNING] Unable to get resource 'org.testng:testng:pom:4.7' from repository andromda (http://team.andromda.org/maven2)
Downloading: http://repo1.maven.org/maven2/org/testng/testng/4.7/testng-4.7.pom
1K downloaded
Downloading: http://team.andromda.org/maven2/mysql/mysql-connector-java/3.1.13/mysql-connector-java-3.1.13.pom
[WARNING] Unable to get resource 'mysql:mysql-connector-java:pom:3.1.13' from repository andromda (http://team.andromda.org/maven2)
Downloading: http://repo1.maven.org/maven2/mysql/mysql-connector-java/3.1.13/mysql-connector-java-3.1.13.pom
759b downloaded
[INFO] snapshot org.andromda.profiles.uml2:andromda-profile:3.3-SNAPSHOT: checking for updates from andromda
2K downloaded
[INFO] snapshot org.andromda.profiles.uml2:andromda-profiles-uml2:3.3-SNAPSHOT: checking for updates from andromda
1K downloaded
[INFO] snapshot org.andromda.profiles:andromda-profiles:3.3-SNAPSHOT: checking for updates from andromda
1K downloaded
[INFO] snapshot org.andromda.profiles.uml2:andromda-profile-datatype:3.3-SNAPSHOT: checking for updates from andromda
493b downloaded
[INFO] snapshot org.andromda.profiles.uml2:andromda-profile-webservice:3.3-SNAPSHOT: checking for updates from andromda
497b downloaded
[INFO] snapshot org.andromda.profiles.uml2:andromda-profile-service:3.3-SNAPSHOT: checking for updates from andromda
491b downloaded
[INFO] snapshot org.andromda.profiles.uml2:andromda-profile-process:3.3-SNAPSHOT: checking for updates from andromda
491b downloaded
[INFO] snapshot org.andromda.profiles.uml2:andromda-profile-meta:3.3-SNAPSHOT: checking for updates from andromda
485b downloaded
[INFO] snapshot org.andromda.profiles.uml2:andromda-profile-messaging:3.3-SNAPSHOT: checking for updates from andromda
495b downloaded
[INFO] snapshot org.andromda.profiles.uml2:andromda-profile-xml:3.3-SNAPSHOT: checking for updates from andromda
483b downloaded
[INFO] snapshot org.andromda.profiles.uml2:andromda-profile-persistence:3.3-SNAPSHOT: checking for updates from andromda
499b downloaded
[INFO] snapshot org.andromda.profiles.uml2:andromda-profile-presentation:3.3-SNAPSHOT: checking for updates from andromda
501b downloaded
[INFO] snapshot org.andromda.profiles.uml2:andromda-profile-seam:1.1-SNAPSHOT: checking for updates from andromda
[INFO] snapshot org.andromda.profiles.uml2:andromda-plugins-profiles-uml2:1.0-SNAPSHOT: checking for updates from andromda
Downloading: http://team.andromda.org/maven2/org/andromda/profiles/uml2/andromda-plugins-profiles-uml2/1.0-SNAPSHOT/andromda-plugins-profiles-uml2-1.0-SNAPSHOT.pom
[WARNING] Unable to get resource 'org.andromda.profiles.uml2:andromda-plugins-profiles-uml2:pom:1.0-SNAPSHOT' from repository andromda (http://team.andromda.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

GroupId: org.andromda.profiles.uml2
ArtifactId: andromda-plugins-profiles-uml2
Version: 1.0-SNAPSHOT

Reason: Unable to download the artifact from any repository

  org.andromda.profiles.uml2:andromda-plugins-profiles-uml2:pom:1.0-SNAPSHOT

from the specified remote repositories:
  central (http://repo1.maven.org/maven2),
  andromda (http://team.andromda.org/maven2)


[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8 seconds
[INFO] Finished at: Fri Jun 22 11:29:33 CEST 2007
[INFO] Final Memory: 7M/254M
[INFO] ------------------------------------------------------------------------


Why can't it download the dependency? It doesn't seem to exist in the remote repository.

-Leandro

Comment by Leandro Hermida [22/Jun/07 12:00 PM]
Hi again,

I've browsed through the http://team.andromda.org/maven2 and this dependency doesn't exist. I'm surprised you don't get this error - please look at your $M2_REPO/org/andromda/profiles/uml2/andromda-profile-seam/1.1-SNAPSHOT/andromda-profile-seam-1.1-SNAPSHOT.pom and tell me if it has the parent dependency I wrote above:

    <parent>
        <groupId>org.andromda.profiles.uml2</groupId>
        <artifactId>andromda-plugins-profiles-uml2</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

If you do then where is it getting this pom from if it doesn't exist http://team.andromda.org/maven2?

-Leandro

Comment by Vance Karimi [01/Jul/07 06:57 AM]
Can't remember if you fixed this?

My andromda-profile-seam-1.1-SNAPSHOT.pom has got the right parent settings.

Did you build the seam profile only or build the profiles ie. run mvn from the 'profiles' directory?

Comment by Leandro Hermida [03/Jul/07 03:14 PM]
Hi,

I have never been able to build from the profiles project. That's why I have always gone down to andromda-plugins/profiles/uml-2.0/seam and built from there because it was the only thing that worked. When I cd into andromda-plugins/profiles and do mvn install I get this error:

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

GroupId: org.andromda.plugins
ArtifactId: andromda-plugins
Version: 1.0-SNAPSHOT

Reason: Unable to download the artifact from any repository

  org.andromda.plugins:andromda-plugins:pom:1.0-SNAPSHOT

from the specified remote repositories:
  central (http://repo1.maven.org/maven2)


[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.reactor.MavenExecutionException: Cannot find parent: org.andromda.plugins:andromda-plugins for project: org.andromda.profiles:andromda-plugins-profiles:pom:1.0-SNAPSHOT
        at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:373)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:286)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:123)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:272)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.project.ProjectBuildingException: Cannot find parent: org.andromda.plugins:andromda-plugins for project: org.andromda.profiles:andromda-plugins-profiles:pom:1.0-SNAPSHOT
        at org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(DefaultMavenProjectBuilder.java:1198)
        at org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(DefaultMavenProjectBuilder.java:1214)
        at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(DefaultMavenProjectBuilder.java:697)
        at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFileInternal(DefaultMavenProjectBuilder.java:431)
        at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:195)
        at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:523)
        at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:455)
        at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:499)
        at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:359)
        ... 11 more
Caused by: org.apache.maven.project.ProjectBuildingException: POM 'org.andromda.plugins:andromda-plugins' not found in repository: Unable to download the artifact from any repository

  org.andromda.plugins:andromda-plugins:pom:1.0-SNAPSHOT

from the specified remote repositories:
  central (http://repo1.maven.org/maven2)

        at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(DefaultMavenProjectBuilder.java:528)
        at org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(DefaultMavenProjectBuilder.java:1194)
        ... 19 more
Caused by: org.apache.maven.artifact.resolver.ArtifactNotFoundException: Unable to download the artifact from any repository

  org.andromda.plugins:andromda-plugins:pom:1.0-SNAPSHOT

from the specified remote repositories:
  central (http://repo1.maven.org/maven2)

        at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:197)
        at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:73)
        at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(DefaultMavenProjectBuilder.java:482)
        ... 20 more
Caused by: org.apache.maven.wagon.ResourceDoesNotExistException: Unable to download the artifact from any repository
        at org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(DefaultWagonManager.java:308)
        at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:185)
        ... 22 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Tue Jul 03 14:44:10 CEST 2007
[INFO] Final Memory: 1M/254M
[INFO] ------------------------------------------------------------------------


Is there something stupid I not doing? I already built the ejb3 and seam cartridges.

Thanks,
-Leandro

Comment by Leandro Hermida [03/Jul/07 04:06 PM]
Hi Vance,

Do I need to build (mvn install) the entire andromda-plugins project? This might solve the dependency problem.

-Leandro

Comment by Vance Karimi [03/Jul/07 04:40 PM]
Yes, building the andromda-plugins would solve the problem.

We should set the build process up so that the missing pom artifacts are downloaded from our AndroMDA repo.

This is something that should definitely go into the the cartridge installation if it's not there already. I think we just presume that the andromda-plugins project has been built once - which is wrong to presume.

Comment by Leandro Hermida [03/Jul/07 04:49 PM]
Hi,

This solved the problem. The latest andromda-plugins project doesn't build properly and craps out but that is not your problem since there is an issue with one of the other cartridges. But it does get the right dependencies so that I can build the entire profiles project.

Thanks for the help,

Leandro

Comment by Vance Karimi [05/Jul/07 04:28 PM]
Solution provided.