<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Maven EAR Plugin &#8211; My Shitty Code</title>
	<atom:link href="https://myshittycode.com/tag/maven-ear-plugin/feed/" rel="self" type="application/rss+xml" />
	<link>https://myshittycode.com</link>
	<description>Embracing the Messiness in Search of Epic Solutions</description>
	<lastBuildDate>Fri, 06 Jan 2023 17:19:52 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>https://myshittycode.com/wp-content/uploads/2022/04/cropped-icon-32x32.png</url>
	<title>Maven EAR Plugin &#8211; My Shitty Code</title>
	<link>https://myshittycode.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">205304208</site>	<item>
		<title>Maven Archetype Plugin: Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.3:create-from-project</title>
		<link>https://myshittycode.com/2015/08/05/maven-archetype-plugin-failed-to-execute-goal-org-apache-maven-pluginsmaven-archetype-plugin2-3create-from-project/</link>
					<comments>https://myshittycode.com/2015/08/05/maven-archetype-plugin-failed-to-execute-goal-org-apache-maven-pluginsmaven-archetype-plugin2-3create-from-project/#respond</comments>
		
		<dc:creator><![CDATA[Shitty Author]]></dc:creator>
		<pubDate>Wed, 05 Aug 2015 12:50:40 +0000</pubDate>
				<category><![CDATA[Programming Language]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Maven Archetype Plugin]]></category>
		<category><![CDATA[Maven EAR Plugin]]></category>
		<guid isPermaLink="false">http://myshittycode.com/?p=790</guid>

					<description><![CDATA[<p>PROBLEM When running mvn archetype:create-from-project with Maven Ear Plugin defined under &#60;pluginManagement&#62;&#8230;. &#8230; the following exception occurs&#8230; SOLUTION It appears this problem happens when using Maven Archetype Plugin 2.3, but works fine when using 2.2. To fix this, define an empty &#60;modules&#62; under &#60;configuration&#62; to prevent NullPointerException.</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2015/08/05/maven-archetype-plugin-failed-to-execute-goal-org-apache-maven-pluginsmaven-archetype-plugin2-3create-from-project/">Maven Archetype Plugin: Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.3:create-from-project</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">PROBLEM</h2>



<p>When running <code>mvn archetype:create-from-project</code> with Maven Ear Plugin defined under <code>&lt;pluginManagement&gt;</code>&#8230;.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; title: ; notranslate">
&lt;project ...&gt;
    ...
    &lt;build&gt;
        &lt;pluginManagement&gt;
                &lt;plugin&gt;
                    &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                    &lt;artifactId&gt;maven-archetype-plugin&lt;/artifactId&gt;
                    &lt;version&gt;2.3&lt;/version&gt;
                &lt;/plugin&gt;
                &lt;plugin&gt;
                    &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                    &lt;artifactId&gt;maven-ear-plugin&lt;/artifactId&gt;
                    &lt;version&gt;2.10.1&lt;/version&gt;
                &lt;/plugin&gt;
            &lt;/plugins&gt;
        &lt;/pluginManagement&gt;
    &lt;/build&gt;
&lt;/project&gt;
</pre></div>


<p>&#8230; the following exception occurs&#8230;</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
&#x5B;ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.3:create-from-project (default-cli) on project myproject-webapp: null: MojoFailureException -&amp;amp;gt; &#x5B;Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.3:create-from-project (default-cli) on project myproject-webapp: null
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
        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.MojoFailureException
        at org.apache.maven.archetype.mojos.CreateArchetypeFromProjectMojo.execute(CreateArchetypeFromProjectMojo.java:258)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        ... 19 more
</pre></div>


<h2 class="wp-block-heading">SOLUTION</h2>



<p>It appears this problem happens when using Maven Archetype Plugin 2.3, but works fine when using 2.2.</p>



<p>To fix this, define an empty <code>&lt;modules&gt;</code> under <code>&lt;configuration&gt;</code> to prevent <code>NullPointerException</code>.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; highlight: [15,16,17]; title: ; notranslate">
&lt;project ...&gt;
    ...
    &lt;build&gt;
        &lt;pluginManagement&gt;
                &lt;plugin&gt;
                    &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                    &lt;artifactId&gt;maven-archetype-plugin&lt;/artifactId&gt;
                    &lt;version&gt;2.3&lt;/version&gt;
                &lt;/plugin&gt;
                &lt;plugin&gt;
                    &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                    &lt;artifactId&gt;maven-ear-plugin&lt;/artifactId&gt;
                    &lt;version&gt;2.10.1&lt;/version&gt;
                    &lt;configuration&gt;
                        &lt;modules/&gt;
                    &lt;/configuration&gt;
                &lt;/plugin&gt;
            &lt;/plugins&gt;
        &lt;/pluginManagement&gt;
    &lt;/build&gt;
&lt;/project&gt;
</pre></div><p>The post <a rel="nofollow" href="https://myshittycode.com/2015/08/05/maven-archetype-plugin-failed-to-execute-goal-org-apache-maven-pluginsmaven-archetype-plugin2-3create-from-project/">Maven Archetype Plugin: Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.3:create-from-project</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://myshittycode.com/2015/08/05/maven-archetype-plugin-failed-to-execute-goal-org-apache-maven-pluginsmaven-archetype-plugin2-3create-from-project/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">790</post-id>	</item>
		<item>
		<title>java.lang.NoSuchMethodError: javax/persistence/OneToMany.orphanRemoval()Z</title>
		<link>https://myshittycode.com/2013/10/04/java-lang-nosuchmethoderror-javaxpersistenceonetomany-orphanremovalz/</link>
					<comments>https://myshittycode.com/2013/10/04/java-lang-nosuchmethoderror-javaxpersistenceonetomany-orphanremovalz/#comments</comments>
		
		<dc:creator><![CDATA[Shitty Author]]></dc:creator>
		<pubDate>Fri, 04 Oct 2013 11:45:50 +0000</pubDate>
				<category><![CDATA[Programming Language]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Maven EAR Plugin]]></category>
		<category><![CDATA[Websphere Application Server]]></category>
		<guid isPermaLink="false">http://myshittycode.com/?p=131</guid>

					<description><![CDATA[<p>PROBLEM You configure Hibernate using annotations and set orphanRemoval property in @OneToMany. When you run the application, the application server throws the following exception:- In my case, I&#8217;m getting this exception when I run on Websphere Application Server (WAS) 7.5. SOLUTION The orphanRemoval property in @OneToMany requires JPA 2.x to work. If you already have [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2013/10/04/java-lang-nosuchmethoderror-javaxpersistenceonetomany-orphanremovalz/">java.lang.NoSuchMethodError: javax/persistence/OneToMany.orphanRemoval()Z</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">PROBLEM</h2>



<p>You configure Hibernate using annotations and set <b>orphanRemoval</b> property in <b>@OneToMany</b>.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: java; highlight: [12]; title: ; notranslate">
@Entity
@Table(name = &quot;person&quot;)
public class Person implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = &quot;personId&quot;)
    private Long id;

    @OneToMany(mappedBy = &quot;person&quot;, cascade = CascadeType.ALL, orphanRemoval = true)
    private Set&lt;car&gt; cars = new HashSet&lt;car&gt;();

	...
}
</pre></div>


<p>When you run the application, the application server throws the following exception:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
Caused by: java.lang.NoSuchMethodError: javax/persistence/OneToMany.orphanRemoval()Z
        at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1868)
        at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:767)
</pre></div>


<p>In my case, I&#8217;m getting this exception when I run on Websphere Application Server (WAS) 7.5.</p>



<h2 class="wp-block-heading">SOLUTION</h2>



<p>The <b>orphanRemoval</b> property in <b>@OneToMany</b> requires JPA 2.x to work. If you already have JPA 2.x in your classpath and you are still getting the error, then JPA 1.x must already been loaded either by your application or by the application server, causing your JPA 2.x to be ignored.</p>



<p>To fix this:-</p>



<ol class="wp-block-list">
<li>Add JPA 2.x in your classpath. For example, <b>hibernate-jpa-2.0-api-1.0.1.Final.jar</b>.</li>



<li>Remove any trace of JPA 1.x from your classpath by scanning your dependency tree.</li>



<li>If your application server uses JPA 1.x, you will need to remove or replace that jar with JPA 2.x.</li>



<li>If you are not allowed to replace JPA 1.x jar on the application server (for example, you are not the admin of the server), you will need to invert the application class loader to <b>PARENT_LAST</b> to ensure the JPA 2.x from your application gets loaded first and JPA 1.x from the application server will get ignored.</li>
</ol>



<h3 class="wp-block-heading">Inverting class loader for application without replacing JPA 1.x from application server</h3>



<p>Assuming you have JPA 2.x in your application classpath and your project structure looks like this:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
myproject
|- myproject-ear
|  |- pom.xml
|- myproject-war
|  |- src
|  |  |- main
|  |     |- java
|  |     |- resources
|  |     |- webapp
|  |- pom.xml
|- pom.xml
</pre></div>


<p>&#8230; if you are deploying your application to Websphere Application Server (WAS), create <b>deployment.xml</b> under <b>src/main/application</b> in the EAR module and instruct WAS to load parent last:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; title: ; notranslate">
&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?--&gt;
&lt;appdeployment:deployment xmi:version=&quot;2.0&quot; xmlns:xmi=&quot;http://www.omg.org/XMI&quot; xmlns:appdeployment=&quot;http://www.ibm.com/websphere/appserver/schemas/5.0/appdeployment.xmi&quot; xmi:id=&quot;Deployment_1&quot;&gt;


    &lt;deployedobject xmi:type=&quot;appdeployment:ApplicationDeployment&quot; xmi:id=&quot;ApplicationDeployment_1&quot; startingweight=&quot;1&quot; warclassloaderpolicy=&quot;SINGLE&quot;&gt;
        &lt;classloader xmi:id=&quot;Classloader_1&quot; mode=&quot;PARENT_LAST&quot;&gt;
    &lt;/classloader&gt;&lt;/deployedobject&gt;
&lt;/appdeployment:deployment&gt;
</pre></div>


<p>In the EAR pom.xml, extend the parent POM and configure the Maven EAR Plugin:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; title: ; notranslate">
&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?--&gt;
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemalocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
    &lt;modelversion&gt;4.0.0&lt;/modelversion&gt;

	&lt;!-- Extend the parent POM --&gt;
	&lt;parent&gt;
        &lt;groupid&gt;myproject&lt;/groupid&gt;
        &lt;artifactid&gt;myproject&lt;/artifactid&gt;
        &lt;version&gt;1.0&lt;/version&gt;
    &lt;/parent&gt;

    &lt;artifactid&gt;myproject-ear&lt;/artifactid&gt;
    &lt;packaging&gt;ear&lt;/packaging&gt;
    &lt;name&gt;${project.artifactId}&lt;/name&gt;

    &lt;build&gt;
        &lt;plugins&gt;
		   &lt;!-- Configure Maven EAR Plugin --&gt;
            &lt;plugin&gt;
                &lt;artifactid&gt;maven-ear-plugin&lt;/artifactid&gt;
                &lt;version&gt;2.4&lt;/version&gt;
                &lt;configuration&gt;
                    &lt;displayname&gt;${project.parent.artifactId}&lt;/displayname&gt;
                    &lt;modules&gt;
                        &lt;webmodule&gt;
                            &lt;groupid&gt;myproject&lt;/groupid&gt;
                            &lt;artifactid&gt;myproject-war&lt;/artifactid&gt;
                            &lt;bundlefilename&gt;${project.parent.artifactId}.war&lt;/bundlefilename&gt;
                            &lt;contextroot&gt;${context-root}&lt;/contextroot&gt;
                        &lt;/webmodule&gt;
                    &lt;/modules&gt;
                &lt;/configuration&gt;
            &lt;/plugin&gt;
        &lt;/plugins&gt;
    &lt;/build&gt;

    &lt;dependencies&gt;
		&lt;!--
		Expose the WAR module to allow the WAR file to be packaged
		in the EAR file by Maven EAR Plugin
		--&gt;
        &lt;dependency&gt;
            &lt;groupid&gt;myproject&lt;/groupid&gt;
            &lt;artifactid&gt;myproject-war&lt;/artifactid&gt;
            &lt;version&gt;1.0&lt;/version&gt;
            &lt;type&gt;war&lt;/type&gt;
        &lt;/dependency&gt;
    &lt;/dependencies&gt;
&lt;/project&gt;
</pre></div>


<p>Your current project structure should look like this now:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
myproject
|- myproject-ear
|  |- src
|  |  |- main
|  |     |- application
|  |        |- deployment.xml
|  |- pom.xml
|- myproject-war
|  |- src
|  |  |- main
|  |     |- java
|  |     |- resources
|  |     |- webapp
|  |- pom.xml
|- pom.xml
</pre></div>


<p>Configure the parent POM to be an aggregator too:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; highlight: [11,12,13,14]; title: ; notranslate">
&amp;lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?--&gt;
&amp;lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemalocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
    &amp;lt;modelversion&gt;4.0.0&amp;lt;/modelversion&gt;

    &amp;lt;groupid&gt;myproject&amp;lt;/groupid&gt;
    &amp;lt;artifactid&gt;myproject&amp;lt;/artifactid&gt;
    &amp;lt;packaging&gt;pom&amp;lt;/packaging&gt;
    &amp;lt;version&gt;1.0&amp;lt;/version&gt;

	&amp;lt;!-- Make this parent POM to be an aggregator for both EAR and WAR modules --&gt;
    &amp;lt;modules&gt;
        &amp;lt;module&gt;myproject-ear&amp;lt;/module&gt;
        &amp;lt;module&gt;myproject-war&amp;lt;/module&gt;
    &amp;lt;/modules&gt;
&amp;lt;/project&gt;
</pre></div>


<p>When you run <b>mvn clean package</b> on the <b>parent POM</b>, the EAR file will contain the WAR file and the deployment file that inverts the class loader for this application.</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2013/10/04/java-lang-nosuchmethoderror-javaxpersistenceonetomany-orphanremovalz/">java.lang.NoSuchMethodError: javax/persistence/OneToMany.orphanRemoval()Z</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://myshittycode.com/2013/10/04/java-lang-nosuchmethoderror-javaxpersistenceonetomany-orphanremovalz/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">131</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Lazy Loading (feed)
Database Caching 54/65 queries in 0.010 seconds using Disk

Served from: myshittycode.com @ 2026-02-18 01:24:33 by W3 Total Cache
-->