You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Yoda Koda II <ja...@tiscali.co.uk> on 2009/06/10 18:30:35 UTC

Re: maven-ejb-plugin & was6-maven-plugin generated jar files

Hi Ken,
I came across this error, I got around it by downloading the plugin sources
and changing the EjbDeployMojo.java to log warnings instead of throwing an
exception.
Like you say the deployed jar has the generated code in anyway so I am
unsure of the need to copy the sources, and why a failure to do so should be
terminal. Maybe a plugin developer could shed some light on this?






Pacileo, Ken wrote:
> 
> Hi,
>  
> I'm using Maven 2.0.10 & RAD6 base_v6 JDK and trying to build a WAS 6.0
> EJB.
>  
> So far the maven-ejb-plugin generates the EJB jar file in the
> project/target directory. When the was6 plugin executes, the wsejbdeploy
> task compiles the bindings and creates the WAS EJB in the
> project/target/was6-maven-plugin directory. The wsejbdeploy task
> completes but then there is an error copying generated sources:
> [INFO] [wsejbdeploy]
> 
> [INFO] [wsejbdeploy] EJBDeploy complete.
> [INFO] [wsejbdeploy] 0 Errors, 12 Warnings, 0 Informational Messages
> [INFO] 
> [INFO] BUILD SUCCESSFUL
> [INFO] Total time: 1 minute 27 seconds
> [INFO] Return code: 0
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] BUILD ERROR
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Error copying generated sources
>  
> Embedded error: Source
> 'c:\Work\TestEJB\target\was6-maven-plugin\d7ccc835\TestEJB-0.1-SNAPSHOT\
> ejbModule' does not exist
> 
> The location of the generated sources is actually in:
> C:\Work\TestEJB\target\was6-maven-plugin\d7ccc835\c2a6fbcd\ejbModule
>  
> The final EJB jar file (./target/was6-maven-plugin/TestEJB-deployed.jar)
> has all the generated class files and descriptor files so I'm unsure why
> the copy step is even needed.
>  
> Does anyone know how to fix the copy generated sources error?
>  
> There is also an issue with the location of the jar file generated by
> the was6 plugin. The ejb is placed in the wrong directory if I were to
> run the install goal which I can't yet because the build fails from the
> error above.
>  
> I tried setting the inputJar and outputJar parameter's in the
> configuration for the was6-maven-plugin but they did nothing. After
> checking the source, I found that those paramters are not defined in the
> mojo at this time. 
>  
> I realize this plugin was designed for RAD7 but it appears to be mostly
> working for RAD6 if I can get past these couple issues. Is there a
> workaround to get the plugin to put the final EJB jar file in the target
> directory under the <artifactId>-<version>.jar name?
>  
> Thanks in advance for any help,
> Regards,
> Ken
>  
> 
> This e-mail, including attachments, may include confidential and/or
> proprietary information, and may be used only by the person or entity
> to which it is addressed. If the reader of this e-mail is not the intended
> recipient or his or her authorized agent, the reader is hereby notified
> that any dissemination, distribution or copying of this e-mail is
> prohibited. If you have received this e-mail in error, please notify the
> sender by replying to this message and delete this e-mail immediately.
> 
> 

-- 
View this message in context: http://www.nabble.com/maven-ejb-plugin---was6-maven-plugin-generated-jar-files-tp23061582p23966080.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven-ejb-plugin & was6-maven-plugin generated jar files

Posted by Wayne Fay <wa...@gmail.com>.
> For me the above fix didn't help, it deployed ok, but the classes are not
> included into the final jars. I fixed the above problem as shown below. I
> guess the fix is only needed for WAS60, and probably only in certain cases.

You should submit a Jira for this so it will be included in a future
release of the maven-ejb-plugin! It looks like a reasonable
contribution/patch especially if it solves the problem.

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: maven-ejb-plugin & was6-maven-plugin generated jar files

Posted by knaap <ar...@op.fi>.
For me the above fix didn't help, it deployed ok, but the classes are not
included into the final jars. I fixed the above problem as shown below. I
guess the fix is only needed for WAS60, and probably only in certain cases.
At least it works for me now.
Arthur


	public void execute() throws MojoExecutionException, MojoFailureException {
		if (!getMavenProject().getPackaging().equalsIgnoreCase("ejb")) {
			throw new MojoExecutionException(
					"Invalid packaging type, this plugin can only be applied to ejb
packaging type projects");
		}

		super.execute();

		if (!getOutputJarFile().exists()) // TODO: Solve generically - MWAS-14 -
											// why doesn't failOnError fail the
											// build and ws_ant return a
											// returncode != 0?
		{
			throw new MojoExecutionException("Deployment failed - see previous
errors");
		}

		File[] workingDirectorySubdirs = getWorkingDirectory().listFiles(
				(java.io.FileFilter) DirectoryFileFilter.DIRECTORY);
		if (workingDirectorySubdirs.length != 1) {
			throw new MojoExecutionException("Cannot find workbench root under "
					+ getWorkingDirectory().getAbsolutePath());
		}
		File[] potentialRoots = workingDirectorySubdirs[0]
				.listFiles((java.io.FileFilter) DirectoryFileFilter.DIRECTORY);
		if (potentialRoots.length > 2) {
			throw new MojoExecutionException("Cannot find workbench root under "
					+ getWorkingDirectory().getAbsolutePath());
		}
		File workBenchRoot = null;
		for (int i = 0; i < potentialRoots.length; i++) {
			workBenchRoot = potentialRoots[i];
			if (!workBenchRoot.getName().equals(".metadata")) {
				break;
			}
		}

		// copy sources
		File generatedSources = new File(workBenchRoot, "ejbModule");
		try {
			  // Create a filter for ".java" files
			  IOFileFilter javaSuffixFilter =
FileFilterUtils.suffixFileFilter(".java");
			  IOFileFilter javaFiles =
FileFilterUtils.andFileFilter(FileFileFilter.FILE, javaSuffixFilter);
			  FileFilter filter =
FileFilterUtils.orFileFilter(DirectoryFileFilter.DIRECTORY, javaFiles);

			FileUtils.copyDirectory(generatedSources, getGeneratedSourcesDirectory(),
filter);
			FileUtils.deleteDirectory(new File(getGeneratedSourcesDirectory(),
"META-INF"));
		} catch (IOException e) {
			throw new MojoExecutionException("Error copying generated sources", e);
		}

		List compileSourceRoots = getMavenProject().getCompileSourceRoots();
		compileSourceRoots.add(getGeneratedSourcesDirectory().getPath());

		// copy generated classes
		File generatedClasses = new File(workBenchRoot, "ejbModule");

		try {
			  // Create a filter for ".class" files
			  IOFileFilter classSuffixFilter =
FileFilterUtils.suffixFileFilter(".class");
			  IOFileFilter classFiles =
FileFilterUtils.andFileFilter(FileFileFilter.FILE, classSuffixFilter);
			  FileFilter filter =
FileFilterUtils.orFileFilter(DirectoryFileFilter.DIRECTORY, classFiles);
			FileUtils.copyDirectory(generatedClasses, getGeneratedClassesDirectory(),
filter);
			Resource resource = new Resource();
			resource.setDirectory(getGeneratedClassesDirectory().getPath());
			getMavenProject().getResources().add(resource);
		} catch (IOException e) {
			throw new MojoExecutionException("Error copying generated classes", e);
		}

		getLog().info("ejbDeploy finished");
	}


-- 
View this message in context: http://old.nabble.com/maven-ejb-plugin---was6-maven-plugin-generated-jar-files-tp23061582p27917297.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: maven-ejb-plugin & was6-maven-plugin generated jar files

Posted by Yoda Koda II <ja...@tiscali.co.uk>.
if ( workingDirectorySubdirs.length == 1 )
        {
            // copy sources
            File generatedSources = new File( workingDirectorySubdirs[0],
getMavenProject().getBuild().getFinalName() + File.separator + "ejbModule"
);
            try
            {
                FileUtils.copyDirectory( generatedSources,
getGeneratedSourcesDirectory() );
                FileUtils.deleteDirectory( new File(
getGeneratedSourcesDirectory(), "META-INF" ) );
            }
            catch ( IOException e )
            {
            	getLog().warn( "No sources were copied: " + e.getMessage() );
            }

            List compileSourceRoots =
getMavenProject().getCompileSourceRoots();
            compileSourceRoots.add( getGeneratedSourcesDirectory().getPath()
);

            // copy generated classes
            File generatedClasses =
                new File( workingDirectorySubdirs[0],
getMavenProject().getBuild().getFinalName() + File.separator +
                    "build" + File.separator + "classes" );

            try
            {
                FileUtils.copyDirectory( generatedClasses,
getGeneratedClassesDirectory() );
                Resource resource = new Resource();
                resource.setDirectory(
getGeneratedClassesDirectory().getPath() );
                getMavenProject().getResources().add( resource );
            }
            catch ( IOException e )
            {
            	getLog().warn( "No classes were copied: " + e.getMessage() );
            }
        }
        else
        {
            getLog().warn( "No sources were generated" );
        }

        getLog().info( "ejbDeploy finished" );



Pacileo, Ken wrote:
> 
> 
> Can you post the code you used to change the exception to just log
> warnings?
> 
> Regards,
> Ken
> 
> 

-- 
View this message in context: http://www.nabble.com/maven-ejb-plugin---was6-maven-plugin-generated-jar-files-tp23061582p24110743.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: maven-ejb-plugin & was6-maven-plugin generated jar files

Posted by "Pacileo, Ken" <ke...@uhc.com>.
Thanks for the update. 

We ended up using the maven-antrun-plugin to call an Ant script that
runs the WebSphere WsEjbDeploy task and then renames the resultant ejb
jar file to the correct name so that the default install configuration
finds the correct file to install.

Can you post the code you used to change the exception to just log
warnings?

Regards,
Ken

-----Original Message-----
From: Yoda Koda II [mailto:james.gustard@tiscali.co.uk] 
Sent: Wednesday, June 17, 2009 10:17 AM
To: users@maven.apache.org
Subject: Re: maven-ejb-plugin & was6-maven-plugin generated jar files


Then to install the deployed jar, replacing the normal target jar, use
something like this..

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>install-library</id>
<phase>install</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<packaging>jar</packaging>
<file>${basedir}/working/FileNameEJB-deployed.jar</file>
</configuration>
</execution>
</executions>
</plugin>









Hi Ken,
I came across this error, I got around it by downloading the plugin
sources and changing the EjbDeployMojo.java to log warnings instead of
throwing an exception.
Like you say the deployed jar has the generated code in anyway so I am
unsure of the need to copy the sources, and why a failure to do so
should be terminal. Maybe a plugin developer could shed some light on
this?






--
View this message in context:
http://n2.nabble.com/maven-ejb-plugin---was6-maven-plugin-generated-jar-
files-tp2639579p3093071.html
Sent from the maven users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


This e-mail, including attachments, may include confidential and/or
proprietary information, and may be used only by the person or entity
to which it is addressed. If the reader of this e-mail is not the intended
recipient or his or her authorized agent, the reader is hereby notified
that any dissemination, distribution or copying of this e-mail is
prohibited. If you have received this e-mail in error, please notify the
sender by replying to this message and delete this e-mail immediately.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven-ejb-plugin & was6-maven-plugin generated jar files

Posted by Yoda Koda II <ja...@tiscali.co.uk>.
Then to install the deployed jar, replacing the normal target jar, use
something like this..

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>install-library</id>
<phase>install</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<packaging>jar</packaging>
<file>${basedir}/working/FileNameEJB-deployed.jar</file>
</configuration>
</execution>
</executions>
</plugin>









Hi Ken,
I came across this error, I got around it by downloading the plugin sources
and changing the EjbDeployMojo.java to log warnings instead of throwing an
exception.
Like you say the deployed jar has the generated code in anyway so I am
unsure of the need to copy the sources, and why a failure to do so should be
terminal. Maybe a plugin developer could shed some light on this?






-- 
View this message in context: http://n2.nabble.com/maven-ejb-plugin---was6-maven-plugin-generated-jar-files-tp2639579p3093071.html
Sent from the maven users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org