Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Headless workspace compilation
Headless workspace compilation [message #187338] Tue, 30 January 2007 16:57 Go to next message
Eclipse UserFriend
Originally posted by: alexandre-michael.neubert.edifixio.com

Hello,
I posted this questionS on the eclipse.platform newsgroup and they told me
it would rather belong here; Can someone help me out?

Thanks,

Alexandre

--------------------------
Hello everybody,
I want to use eclipse headless compilation command. My eclipse is 3.2 with
wtp plug-in version 1.5. I found it after a while in eclipse documentation
with the apt plug-in. My workspace is composed of an EJB project, his EJB
client and an EAR project which has a dependency on both, ejb and client.

I also configured the ejb project to include a custom ant launcher;
therefore I created a basic ant file which simply creates a directory toto
in the ejb project. Then I included this build in the Preference-->Builder
section of the project and configured it to be launched when building
manually and automatically. I use this behaviour to have the project
execute custom tasks when I build the workspace in headless mode.

The command I use is the following to compile this workspace:
set ECLIPSE_HOME=D:\eclipse set WORKSPACE=D:\workspace
java -cp %ECLIPSE_HOME%/startup.jar org.eclipse.core.launcher.Main
-noupdate -application org.eclipse.jdt.apt.core.aptBuild -data %WORKSPACE%

Few remarks about that:

* Sometimes, I get an error stack like this at build start:

*** ERROR ***: Tue Jan 30 16:47:23 CET 2007
org.eclipse.emf.common.util.BasicEList$BasicIndexOutOfBounds Exception:
index=0, size=0
at org.eclipse.emf.common.util.BasicEList.get(BasicEList.java:5 12)
at
org.eclipse.jst.j2ee.componentcore.EnterpriseArtifactEdit.ge tDeploymentDescriptorRoot(EnterpriseArtifactEdit.java:154)
at
org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit.getA pplication(EARArtifactEdit.java:291)
at
org.eclipse.jst.j2ee.internal.deployables.J2EEDeployableFact ory.createBinaryModules(J2EEDeployableFactory.java:109)
at
org.eclipse.jst.j2ee.internal.deployables.J2EEDeployableFact ory.createModuleDelegates(J2EEDeployableFactory.java:97)
at
org.eclipse.jst.j2ee.internal.deployables.J2EEDeployableFact ory.createModules(J2EEDeployableFactory.java:72)
at
org.eclipse.jst.j2ee.internal.deployables.J2EEDeployableFact ory.createModules(J2EEDeployableFactory.java:61)
at
org.eclipse.wst.server.core.util.ProjectModuleFactoryDelegat e.cacheModules(ProjectModuleFactoryDelegate.java:60)
at
org.eclipse.wst.server.core.util.ProjectModuleFactoryDelegat e.getModules(ProjectModuleFactoryDelegate.java:92)
at
org.eclipse.wst.server.core.internal.ModuleFactory.getModule s(ModuleFactory.java:133)
at
org.eclipse.wst.server.core.ServerUtil.getModules(ServerUtil .java:285)
at
org.eclipse.wst.server.core.ServerUtil.getModule(ServerUtil. java:52)
at
org.eclipse.wst.server.core.internal.ResourceManager.publish HandleProjectChange(ResourceManager.java:913)
at
org.eclipse.wst.server.core.internal.ResourceManager$1.visit (ResourceManager.java:114)
at
org.eclipse.core.internal.events.ResourceDelta.accept(Resour ceDelta.java:67)
at
org.eclipse.core.internal.events.ResourceDelta.accept(Resour ceDelta.java:76)
at
org.eclipse.core.internal.events.ResourceDelta.accept(Resour ceDelta.java:48)
at
org.eclipse.wst.server.core.internal.ResourceManager$ServerR esourceChangeListener.resourceChanged(ResourceManager.java:1 08)
at
org.eclipse.core.internal.events.NotificationManager$2.run(N otificationManager.java:280)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at
org.eclipse.core.internal.events.NotificationManager.notify( NotificationManager.java:274)
at
org.eclipse.core.internal.events.NotificationManager.broadca stChanges(NotificationManager.java:148)
at
org.eclipse.core.internal.resources.Workspace.broadcastBuild Event(Workspace.java:240)
at
org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBu ildJob.java:146)
at
org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJ ob.java:208)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

*** ERROR ***: Tue Jan 30 16:47:24 CET 2007
org.eclipse.jst.j2ee.commonarchivecore.internal.exception.De ploymentDescriptorLoadException:
META-INF/application.xml
Stack trace of nested exception:

org.eclipse.jst.j2ee.commonarchivecore.internal.exception.Em ptyResourceException:
platform:/resource/EARProject/EarContent/META-INF/applicatio n.xml
at
org.eclipse.jst.j2ee.commonarchivecore.internal.util.Archive Util.getRoot(ArchiveUtil.java:396)
at
org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.Xml BasedImportStrategyImpl.primLoadDeploymentDescriptor(XmlBase dImportStrategyImpl.java:42)
at
org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.Ear 12ImportStrategyImpl.loadDeploymentDescriptor(Ear12ImportStr ategyImpl.java:87)
at
org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.Ear 12ImportStrategyImpl.importMetaData(Ear12ImportStrategyImpl. java:81)
at
org.eclipse.jst.j2ee.commonarchivecore.internal.impl.EARFile Impl.getDeploymentDescriptor(EARFileImpl.java:294)
at
org.eclipse.jst.j2ee.model.internal.validation.EarValidator. validateInJob(EarValidator.java:142)
at
org.eclipse.jst.j2ee.internal.validation.UIEarValidator.vali dateInJob(UIEarValidator.java:218)
at
org.eclipse.wst.validation.internal.operations.ValidatorJob. run(ValidatorJob.java:70)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
Building workspace

But the workspace still seems to be build. How is that stack error related
to my workspace configuration? Is this a bug? If not, where does it come
from and how can I eliminate it?

* If my ejb is not generated using the xdoclets, no classes are generated
(neither in the client nor in the ejb) when building the workspace using
the command line option. How come? Is that feature doclet dependent?

* When building, the logs in the console say that my custom launcher is
executed but the directory toto is never created.
Here are the logs i get in the console when building the workspace:

Building workspace
Building: /EJBTest1Client
Invoking Java Builder on /EJBTest1Client.
Cleaning output folder for EJBTest1Client
Build done
Invoking Faceted Project Validation Builder on /EJBTest1Client.
Invoking Validation on /EJBTest1Client.
Building: /EJBTest1
Invoking Java Builder on /EJBTest1.
Cleaning output folder for EJBTest1
Build done
Invoking Faceted Project Validation Builder on /EJBTest1.
Invoking Validation on /EJBTest1.
Invoking Integrated External Tool Builder on /EJBTest1.
Running New_Builder...
Building: /EARProject
Invoking Faceted Project Validation Builder on /EARProject.
Invoking Validation on /EARProject.

The "Running New_Builder" indicates that the build is executed, but no
directory is generated. Is that right that the "Running New_Builder"
should execute the default task (or the one configured in the settings) of
my custom ant build or does it something else?
How come that nothing is generated? Is there a configuration to set to
make this feature work?

Thanks for all your answers

Regards

Alexandre
Re: Headless workspace compilation [message #188015 is a reply to message #187338] Wed, 14 February 2007 16:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wagnerb.us.ibm.com

Alexandre Neubert wrote:
> Hello,
> I posted this questionS on the eclipse.platform newsgroup and they told
> me it would rather belong here; Can someone help me out?
>
> Thanks,
>
> Alexandre
>
> --------------------------
> Hello everybody,
> I want to use eclipse headless compilation command. My eclipse is 3.2
> with wtp plug-in version 1.5. I found it after a while in eclipse
> documentation with the apt plug-in. My workspace is composed of an EJB
> project, his EJB client and an EAR project which has a dependency on
> both, ejb and client.
>
> I also configured the ejb project to include a custom ant launcher;
> therefore I created a basic ant file which simply creates a directory
> toto in the ejb project. Then I included this build in the
> Preference-->Builder section of the project and configured it to be
> launched when building manually and automatically. I use this behaviour
> to have the project execute custom tasks when I build the workspace in
> headless mode.
>
> The command I use is the following to compile this workspace:
> set ECLIPSE_HOME=D:\eclipse set WORKSPACE=D:\workspace
> java -cp %ECLIPSE_HOME%/startup.jar org.eclipse.core.launcher.Main
> -noupdate -application org.eclipse.jdt.apt.core.aptBuild -data %WORKSPACE%
>
> Few remarks about that:
>
> * Sometimes, I get an error stack like this at build start:
>
> *** ERROR ***: Tue Jan 30 16:47:23 CET 2007
> org.eclipse.emf.common.util.BasicEList$BasicIndexOutOfBounds Exception:
> index=0, size=0
> at org.eclipse.emf.common.util.BasicEList.get(BasicEList.java:5 12)
> at
> org.eclipse.jst.j2ee.componentcore.EnterpriseArtifactEdit.ge tDeploymentDescriptorRoot(EnterpriseArtifactEdit.java:154)
>
> at
> org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit.getA pplication(EARArtifactEdit.java:291)
>
> at
> org.eclipse.jst.j2ee.internal.deployables.J2EEDeployableFact ory.createBinaryModules(J2EEDeployableFactory.java:109)
>
> at
> org.eclipse.jst.j2ee.internal.deployables.J2EEDeployableFact ory.createModuleDelegates(J2EEDeployableFactory.java:97)
>
> at
> org.eclipse.jst.j2ee.internal.deployables.J2EEDeployableFact ory.createModules(J2EEDeployableFactory.java:72)
>
> at
> org.eclipse.jst.j2ee.internal.deployables.J2EEDeployableFact ory.createModules(J2EEDeployableFactory.java:61)
>
> at
> org.eclipse.wst.server.core.util.ProjectModuleFactoryDelegat e.cacheModules(ProjectModuleFactoryDelegate.java:60)
>
> at
> org.eclipse.wst.server.core.util.ProjectModuleFactoryDelegat e.getModules(ProjectModuleFactoryDelegate.java:92)
>
> at
> org.eclipse.wst.server.core.internal.ModuleFactory.getModule s(ModuleFactory.java:133)
>
> at
> org.eclipse.wst.server.core.ServerUtil.getModules(ServerUtil .java:285)
> at
> org.eclipse.wst.server.core.ServerUtil.getModule(ServerUtil. java:52)
> at
> org.eclipse.wst.server.core.internal.ResourceManager.publish HandleProjectChange(ResourceManager.java:913)
>
> at
> org.eclipse.wst.server.core.internal.ResourceManager$1.visit (ResourceManager.java:114)
>
> at
> org.eclipse.core.internal.events.ResourceDelta.accept(Resour ceDelta.java:67)
>
> at
> org.eclipse.core.internal.events.ResourceDelta.accept(Resour ceDelta.java:76)
>
> at
> org.eclipse.core.internal.events.ResourceDelta.accept(Resour ceDelta.java:48)
>
> at
> org.eclipse.wst.server.core.internal.ResourceManager$ServerR esourceChangeListener.resourceChanged(ResourceManager.java:1 08)
>
> at
> org.eclipse.core.internal.events.NotificationManager$2.run(N otificationManager.java:280)
>
> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
> at
> org.eclipse.core.internal.events.NotificationManager.notify( NotificationManager.java:274)
>
> at
> org.eclipse.core.internal.events.NotificationManager.broadca stChanges(NotificationManager.java:148)
>
> at
> org.eclipse.core.internal.resources.Workspace.broadcastBuild Event(Workspace.java:240)
>
> at
> org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBu ildJob.java:146)
>
> at
> org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJ ob.java:208)
> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
>
> *** ERROR ***: Tue Jan 30 16:47:24 CET 2007
> org.eclipse.jst.j2ee.commonarchivecore.internal.exception.De ploymentDescriptorLoadException:
> META-INF/application.xml
> Stack trace of nested exception:
>
> org.eclipse.jst.j2ee.commonarchivecore.internal.exception.Em ptyResourceException:
> platform:/resource/EARProject/EarContent/META-INF/applicatio n.xml
> at
> org.eclipse.jst.j2ee.commonarchivecore.internal.util.Archive Util.getRoot(ArchiveUtil.java:396)
>
> at
> org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.Xml BasedImportStrategyImpl.primLoadDeploymentDescriptor(XmlBase dImportStrategyImpl.java:42)
>
> at
> org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.Ear 12ImportStrategyImpl.loadDeploymentDescriptor(Ear12ImportStr ategyImpl.java:87)
>
> at
> org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.Ear 12ImportStrategyImpl.importMetaData(Ear12ImportStrategyImpl. java:81)
>
> at
> org.eclipse.jst.j2ee.commonarchivecore.internal.impl.EARFile Impl.getDeploymentDescriptor(EARFileImpl.java:294)
>
> at
> org.eclipse.jst.j2ee.model.internal.validation.EarValidator. validateInJob(EarValidator.java:142)
>
> at
> org.eclipse.jst.j2ee.internal.validation.UIEarValidator.vali dateInJob(UIEarValidator.java:218)
>
> at
> org.eclipse.wst.validation.internal.operations.ValidatorJob. run(ValidatorJob.java:70)
>
> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
> Building workspace
>
> But the workspace still seems to be build. How is that stack error
> related to my workspace configuration? Is this a bug? If not, where does
> it come from and how can I eliminate it?
>
> * If my ejb is not generated using the xdoclets, no classes are
> generated (neither in the client nor in the ejb) when building the
> workspace using the command line option. How come? Is that feature
> doclet dependent?
>
> * When building, the logs in the console say that my custom launcher is
> executed but the directory toto is never created.
> Here are the logs i get in the console when building the workspace:
>
> Building workspace
> Building: /EJBTest1Client
> Invoking Java Builder on /EJBTest1Client.
> Cleaning output folder for EJBTest1Client
> Build done
> Invoking Faceted Project Validation Builder on /EJBTest1Client.
> Invoking Validation on /EJBTest1Client.
> Building: /EJBTest1
> Invoking Java Builder on /EJBTest1.
> Cleaning output folder for EJBTest1
> Build done
> Invoking Faceted Project Validation Builder on /EJBTest1.
> Invoking Validation on /EJBTest1.
> Invoking Integrated External Tool Builder on /EJBTest1.
> Running New_Builder...
> Building: /EARProject
> Invoking Faceted Project Validation Builder on /EARProject.
> Invoking Validation on /EARProject.
>
> The "Running New_Builder" indicates that the build is executed, but no
> directory is generated. Is that right that the "Running New_Builder"
> should execute the default task (or the one configured in the settings)
> of my custom ant build or does it something else?
> How come that nothing is generated? Is there a configuration to set to
> make this feature work?
>
> Thanks for all your answers
>
> Regards
>
> Alexandre
>


Here is some code...
I'm running headless and want to create an EJB project with an associated EAR project
so that I can later generate some code from an external model an put it in these projects.


IProgressMonitor progressMonitor = new NullProgressMonitor();

final String projectName = "project";
final String earProjectName = projectName + "EAR";
final String ejbProjectName = projectName + "EJB";

final IProject earProject = ResourcesPlugin.getWorkspace().getRoot().getProject(earProje ctName);
final IProject ejbProject = ResourcesPlugin.getWorkspace().getRoot().getProject(ejbProje ctName);

if (earProject.exists()) {
earProject.delete(true, true, new SubProgressMonitor(progressMonitor, 10));
}
if (ejbProject.exists()) {
ejbProject.delete(true, true, new SubProgressMonitor(progressMonitor, 10));
}

/*
IProjectDescription earProjectDesription = ResourcesPlugin.getWorkspace().newProjectDescription(earProj ect.getName());
earProject.create(earProjectDesription, new SubProgressMonitor(progressMonitor, 10));
earProject.open(new SubProgressMonitor(progressMonitor, 10));

final IFacetedProject earFacetedProject = ProjectFacetsManager.create(earProject, true, new SubProgressMonitor(progressMonitor, 10));
IActionDefinition earInstallAction = EARFacetUtils.EAR_14.getActionDefinition(Collections.singlet on(EARFacetUtils.EAR_14), IFacetedProject.Action.Type.INSTALL);
Object earConfig = earInstallAction.createConfigObject(EARFacetUtils.EAR_14, earProject.getName());
earFacetedProject.installProjectFacet(EARFacetUtils.EAR_14, earConfig, new SubProgressMonitor(progressMonitor, 10));
earFacetedProject.setFixedProjectFacets(Collections.singleto n(EARFacetUtils.EAR_FACET));
*/

//final IProjectFacet EJB_FACET = ProjectFacetsManager.getProjectFacet("jst.ejb");
//final IProjectFacetVersion EJB_21 = EJB_FACET.getVersion("2.1");
final IProjectFacetVersion EJB_21 = EjbFacetInstallDataModelProvider.EJB_21;
final IProjectFacet EJB_FACET = EJB_21.getProjectFacet();

final IProjectDescription ejbProjectDescription = ResourcesPlugin.getWorkspace().newProjectDescription(ejbProj ect.getName());
ejbProject.create(ejbProjectDescription, new SubProgressMonitor(progressMonitor, 10));
ejbProject.open(new SubProgressMonitor(progressMonitor, 10));

final IFacetedProject ejbFacetedProject = ProjectFacetsManager.create(ejbProject, true, new SubProgressMonitor(progressMonitor, 10));

//Install Java facet (required by EJB facet).
final IActionDefinition javaInstallAction = JavaFacetUtils.JAVA_50.getActionDefinition(Collections.singl eton(JavaFacetUtils.JAVA_50), IFacetedProject.Action.Type.INSTALL);
final Object javaConfig = javaInstallAction.createConfigObject(JavaFacetUtils.JAVA_50, ejbProject.getName());
ejbFacetedProject.installProjectFacet(JavaFacetUtils.JAVA_50 , javaConfig, new SubProgressMonitor(progressMonitor, 10));

//Install EJB facet.
final IActionDefinition ejbInstallAction = EJB_21.getActionDefinition(Collections.singleton(EJB_21), IFacetedProject.Action.Type.INSTALL);
final IDataModel ejbConfig = (IDataModel) ejbInstallAction.createConfigObject(EJB_21, ejbProject.getName());
ejbConfig.setBooleanProperty(IJ2EEModuleFacetInstallDataMode lProperties.ADD_TO_EAR, Boolean.TRUE);
ejbConfig.setStringProperty(IJ2EEModuleFacetInstallDataModel Properties.EAR_PROJECT_NAME, earProject.getName());
ejbConfig.setBooleanProperty(IEjbFacetInstallDataModelProper ties.CREATE_CLIENT, Boolean.FALSE);
ejbFacetedProject.installProjectFacet(EJB_21, ejbConfig, new SubProgressMonitor(progressMonitor, 10));

//Fix the facets.
ejbFacetedProject.setFixedProjectFacets(new HashSet<IProjectFacet>(Arrays.asList(new IProjectFacet[]{EJB_FACET, JavaFacetUtils.JAVA_FACET})));






The issue in question begins with the line (second from last)
ejbFacetedProject.installProjectFacet(EJB_21, ejbConfig, new SubProgressMonitor(progressMonitor, 10));

Which eventually leads us into "EjbFacetPostInstallDelegate.execute" and the line
installAndAddModuletoEAR(
j2eeVersionText,
earProjectName,
(IRuntime) model.getProperty(IJ2EEFacetInstallDataModelProperties.FACET _RUNTIME),
project,
moduleURI,
monitor );

Which again leads us to "J2EEFacetInstallDelegate.installAndAddModuletoEAR" which has the line
installEARFacet(j2eeVersionText,
earProjectName,
runtime,
monitor);
Which creates an EAR project with the correct name. The next call of interest is in the same method
addToEar( earComp, c, moduleURI );

Which brings us to "J2EEFacetInstallDelegate.addToEar" which gets us to
dataModel.getDefaultOperation().execute(null, null);

After a lot of jumping through hoops (DataModelPausibleOperationImpl's six frames)
to actually run something we get to the important bit,
which is in "AddComponentToEnterpriseApplicationOp:execute" and the line
updateEARDD(submon(monitor, 1));

Which gets us into "AddComponentToEnterpriseApplicationOp:updateEARDD"
and the bit that is causing problems
Application application = earEdit.getApplication();

Through this call we end up in
EnterpriseArtifactEdit:
public EObject getDeploymentDescriptorRoot() {
Resource res = getDeploymentDescriptorResource();
return (EObject) res.getContents().get(0);
}

At this point the contents of the ear project's application.xml is

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Application_ID" version="1.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
<display-name>projectEAR</display-name>
</application>

Eventually, the fist line, "Resource res = getDeploymentDescriptorResource();",
ends up in org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce
which ends up throwing

org.eclipse.emf.common.util.WrappedException: org.xml.sax.SAXParseException: cvc-complex-type.2.4.b:
The content of element 'application' is not complete.
One of '{"http://java.sun.com/xml/ns/j2ee":display-name, "http://java.sun.com/xml/ns/j2ee":icon,
"http://java.sun.com/xml/ns/j2ee":module}' is expected.

The exception doesn't make it out, since updateEARDD catches Exception and logs it.

If I manually create the EARProject before hand (by uncommenting the commented out block of code;
so that J2EEFacetInstallDelegate.installEARFacet does not create the EAR project)
then I do not get the above exception (as it appears the application.xml for the EAR project is already loaded)
but the contents of the resource are empty causing the line
"return (EObject) res.getContents().get(0);" to throw the

org.eclipse.emf.common.util.BasicEList$BasicIndexOutOfBounds Exception: index=0, size=0

exception, which again does not make it out since it is caught and logged by updateEARDD which catches Exception.

In any event, due to either of these issues, the real work of updateEARDD,
adding the module descriptor to the EAR does not occur, leaving the EAR in an incomplete state.
Everything else (outside updateEARDD ) works fine, so on the surface it looked like everything worked,
however, the EJB was not added to the module list of the EAR.

If I go and change things up by creating the EJB project first (not adding it to an EAR)
and then create the EAR project and add the line

earConfig.setProperty(IEarFacetInstallDataModelProperties.J2 EE_PROJECTS_LIST, Arrays.asList(new IProject[]{ejbProject}));

I get the same SAXParserException as I got above.
(As well as another message about "Unable to set nested messages property.")

In addition,
IEarFacetInstallDataModelProperties.J2EE_PROJECTS_LIST
IEjbFacetInstallDataModelProperties.CREATE_CLIENT
EjbFacetInstallDataModelProvider.EJB_21
are all internal and I shouldn't be using them, but I don't see how to get
the functionality I need without using them.
Why isn't there an EJBFacetUtils like EARFacetUtils and JavaFacetUtils?
Why are these DataModelProperties internal unlike their super classes,
is it just due to the possibility of their changing?

I'm going to try to take a look at how the wizards go about doing this to make sure I'm not missing something,
but I suspect that they're using internal stuff to get their work done.

So, after all that... am I missing something
(I admit I could be, I figured out how to do this mostly by reading through the code base,
there's almost no documentation anywhere on how to do this)
or is this a bug?
Re: Headless workspace compilation [message #188120 is a reply to message #188015] Fri, 16 February 2007 16:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wagnerb.us.ibm.com

Ok, I've taken a look at how the wizard works. I modified my code to read as follows:

------------------------------------------------------------ -

IProgressMonitor progressMonitor = new NullProgressMonitor();

final String projectName = "project";
final String earProjectName = projectName + "EAR";
final String ejbProjectName = projectName + "EJB";

final IProject earProject = ResourcesPlugin.getWorkspace().getRoot().getProject(earProje ctName);
final IProject ejbProject = ResourcesPlugin.getWorkspace().getRoot().getProject(ejbProje ctName);

if (earProject.exists()) {
earProject.delete(true, true, new SubProgressMonitor(progressMonitor, 10));
}
if (ejbProject.exists()) {
ejbProject.delete(true, true, new SubProgressMonitor(progressMonitor, 10));
}

//final IProjectFacet EJB_FACET = ProjectFacetsManager.getProjectFacet("jst.ejb");
//final IProjectFacetVersion EJB_21 = EJB_FACET.getVersion("2.1");
final IProjectFacetVersion EJB_21 = EjbFacetInstallDataModelProvider.EJB_21;
final IProjectFacet EJB_FACET = EJB_21.getProjectFacet();

final IProjectDescription ejbProjectDescription = ResourcesPlugin.getWorkspace().newProjectDescription(ejbProj ect.getName());
ejbProject.create(ejbProjectDescription, new SubProgressMonitor(progressMonitor, 10));
ejbProject.open(new SubProgressMonitor(progressMonitor, 10));

final IFacetedProject ejbFacetedProject = ProjectFacetsManager.create(ejbProject, true, new SubProgressMonitor(progressMonitor, 10));

//Install Java facet (required by EJB facet).
final IActionDefinition javaInstallAction = JavaFacetUtils.JAVA_50.getActionDefinition(Collections.singl eton(JavaFacetUtils.JAVA_50), IFacetedProject.Action.Type.INSTALL);
final Object javaConfig = javaInstallAction.createConfigObject(JavaFacetUtils.JAVA_50, ejbProject.getName());
ejbFacetedProject.installProjectFacet(JavaFacetUtils.JAVA_50 , javaConfig, new SubProgressMonitor(progressMonitor, 10));

//Install EJB facet.
final IActionDefinition ejbInstallAction = EJB_21.getActionDefinition(Collections.singleton(EJB_21), IFacetedProject.Action.Type.INSTALL);
final IDataModel ejbConfig = (IDataModel) ejbInstallAction.createConfigObject(EJB_21, ejbProject.getName());
//ejbConfig.setBooleanProperty(IJ2EEModuleFacetInstallDataMo delProperties.ADD_TO_EAR, Boolean.TRUE);
//ejbConfig.setStringProperty(IJ2EEModuleFacetInstallDataMod elProperties.EAR_PROJECT_NAME, earProject.getName());
ejbConfig.setBooleanProperty(IEjbFacetInstallDataModelProper ties.CREATE_CLIENT, Boolean.FALSE);
ejbFacetedProject.installProjectFacet(EJB_21, ejbConfig, new SubProgressMonitor(progressMonitor, 10));

//Fix the facets.
ejbFacetedProject.setFixedProjectFacets(new HashSet<IProjectFacet>(Arrays.asList(new IProjectFacet[]{EJB_FACET, JavaFacetUtils.JAVA_FACET})));


IProjectDescription earProjectDesription = ResourcesPlugin.getWorkspace().newProjectDescription(earProj ect.getName());
earProject.create(earProjectDesription, new SubProgressMonitor(progressMonitor, 10));
earProject.open(new SubProgressMonitor(progressMonitor, 10));

final IFacetedProject earFacetedProject = ProjectFacetsManager.create(earProject, true, new SubProgressMonitor(progressMonitor, 10));
IActionDefinition earInstallAction = EARFacetUtils.EAR_14.getActionDefinition(Collections.singlet on(EARFacetUtils.EAR_14), IFacetedProject.Action.Type.INSTALL);
IDataModel earConfig = (IDataModel) earInstallAction.createConfigObject(EARFacetUtils.EAR_14, earProject.getName());

earConfig.setProperty(IEarFacetInstallDataModelProperties.J2 EE_PROJECTS_LIST, Arrays.asList(new IProject[]{ejbProject}));
earConfig.setProperty(IEarFacetInstallDataModelProperties.JA VA_PROJECT_LIST, Collections.EMPTY_LIST);
earConfig.setBooleanProperty(IFacetDataModelProperties.SHOUL D_EXECUTE, Boolean.TRUE);

IDataModel master = DataModelFactory.createDataModel(new EARFacetProjectCreationDataModelProvider());
master.setStringProperty(IFacetDataModelProperties.FACET_PRO JECT_NAME, earConfig.getStringProperty(IFacetDataModelProperties.FACET_ PROJECT_NAME));
master.setProperty(IFacetProjectCreationDataModelProperties. FACET_DM_MAP, Collections.singletonMap(EARFacetUtils.EAR_FACET.getId(), earConfig));
master.setProperty(IFacetProjectCreationDataModelProperties. FACET_ACTION_MAP, Collections.EMPTY_MAP);
master.setProperty(FacetProjectCreationDataModelProvider.REQ UIRED_FACETS_COLLECTION, Collections.singletonList(EARFacetUtils.EAR_FACET));

earConfig.setProperty(FacetInstallDataModelProvider.MASTER_P ROJECT_DM, master);

earFacetedProject.installProjectFacet(EARFacetUtils.EAR_14, earConfig, new SubProgressMonitor(progressMonitor, 10));
earFacetedProject.setFixedProjectFacets(Collections.singleto n(EARFacetUtils.EAR_FACET));

------------------------------------------------------------ -

I set a breakpoint in FacetedProject.modify(Set, IProgressMonitor) and ran the above code headless,
stopping in FacetedProject.modify when being called as a result of the second to last line above.
I then started a debug workbench and ran the EAR Wizard, selecting the EJB project created by the above code,
stopping in FacetedProject.modify at exactly the same point.

At this time I compared the "actions" in the two threads.
They both have exactly the same structure and the same information.
One would expect these two threads to then go on to do the same things.
But, the wizard thread succeeds while the headless thread does not.
The headless thread reports a parse error to stderr and does not link the EJB to the EAR (does not add the module).

Upon further examination (parallel stepping) the first (and so far only) difference between the threads
is found in AddComponentToEnterpriseApplicationOp.updateEARDD(IProgressM onitor).

earEdit.artifactEditModel.emfContext.resourceSet.resourceFac toryRegistery.factories{WTPResourceFactoryRegistry}.value.re ndererFactory

for the wizard thread this is: org.eclipse.wst.xml.core.internal.emf2xml.EMF2DOMSSERenderer Factory
for the headless thread this is: org.eclipse.wst.common.internal.emf.resource.EMF2DOMRenderer Factory

This artifactEditModel comes directly from the ModuleCoreNature of this project.
I am as yet unsure as to why these two ModuleCoreNatures differ in this manner.
However, I believe that this difference is what is causing my problem.



So my questions are...

Why do these ModuleCoreNatures differ, and is this a bug?
If it isn't a bug, and something else needs done first, it is completely non-obvious.
Also, I'm suspecting this is a bug as the same issue causes the same problem
when the wtp code itself internally creates an EAR project automatically
(as in EJBFacetPostInstallDelegate::J2EEFacetInstallDelegate.instal lEARFacet)
when creating an EJB project which requires it.

Do I need to use several property names which are internal?
IEjbFacetInstallDataModelProperties.CREATE_CLIENT
IEarFacetInstallDataModelProperties.J2EE_PROJECTS_LIST
IEarFacetInstallDataModelProperties.JAVA_PROJECT_LIST

Is there a non-internal (and non-magic) way to access the EJB facets and facet versions?
EjbFacetInstallDataModelProvider.EJB_21
Re: Headless workspace compilation [message #188138 is a reply to message #188120] Fri, 16 February 2007 22:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wagnerb.us.ibm.com

wagnerb wrote:
> Ok, I've taken a look at how the wizard works. I modified my code to
> read as follows:
>
> ------------------------------------------------------------ -
>
> IProgressMonitor progressMonitor = new NullProgressMonitor();
>
> final String projectName = "project";
> final String earProjectName = projectName + "EAR";
> final String ejbProjectName = projectName + "EJB";
>
> final IProject earProject =
> ResourcesPlugin.getWorkspace().getRoot().getProject(earProje ctName);
> final IProject ejbProject =
> ResourcesPlugin.getWorkspace().getRoot().getProject(ejbProje ctName);
>
> if (earProject.exists()) {
> earProject.delete(true, true, new
> SubProgressMonitor(progressMonitor, 10));
> }
> if (ejbProject.exists()) {
> ejbProject.delete(true, true, new
> SubProgressMonitor(progressMonitor, 10));
> }
>
> //final IProjectFacet EJB_FACET =
> ProjectFacetsManager.getProjectFacet("jst.ejb");
> //final IProjectFacetVersion EJB_21 = EJB_FACET.getVersion("2.1");
> final IProjectFacetVersion EJB_21 =
> EjbFacetInstallDataModelProvider.EJB_21;
> final IProjectFacet EJB_FACET = EJB_21.getProjectFacet();
>
> final IProjectDescription ejbProjectDescription =
> ResourcesPlugin.getWorkspace().newProjectDescription(ejbProj ect.getName());
> ejbProject.create(ejbProjectDescription, new
> SubProgressMonitor(progressMonitor, 10));
> ejbProject.open(new SubProgressMonitor(progressMonitor, 10));
>
> final IFacetedProject ejbFacetedProject =
> ProjectFacetsManager.create(ejbProject, true, new
> SubProgressMonitor(progressMonitor, 10));
>
> //Install Java facet (required by EJB facet).
> final IActionDefinition javaInstallAction =
> JavaFacetUtils.JAVA_50.getActionDefinition(Collections.singl eton(JavaFacetUtils.JAVA_50),
> IFacetedProject.Action.Type.INSTALL);
> final Object javaConfig =
> javaInstallAction.createConfigObject(JavaFacetUtils.JAVA_50,
> ejbProject.getName());
> ejbFacetedProject.installProjectFacet(JavaFacetUtils.JAVA_50 ,
> javaConfig, new SubProgressMonitor(progressMonitor, 10));
>
> //Install EJB facet.
> final IActionDefinition ejbInstallAction =
> EJB_21.getActionDefinition(Collections.singleton(EJB_21),
> IFacetedProject.Action.Type.INSTALL);
> final IDataModel ejbConfig = (IDataModel)
> ejbInstallAction.createConfigObject(EJB_21, ejbProject.getName());
> //ejbConfig.setBooleanProperty(IJ2EEModuleFacetInstallDataMo delProperties.ADD_TO_EAR,
> Boolean.TRUE);
> //ejbConfig.setStringProperty(IJ2EEModuleFacetInstallDataMod elProperties.EAR_PROJECT_NAME,
> earProject.getName());
> ejbConfig.setBooleanProperty(IEjbFacetInstallDataModelProper ties.CREATE_CLIENT,
> Boolean.FALSE);
> ejbFacetedProject.installProjectFacet(EJB_21, ejbConfig, new
> SubProgressMonitor(progressMonitor, 10));
>
> //Fix the facets.
> ejbFacetedProject.setFixedProjectFacets(new
> HashSet<IProjectFacet>(Arrays.asList(new IProjectFacet[]{EJB_FACET,
> JavaFacetUtils.JAVA_FACET})));
>
>
> IProjectDescription earProjectDesription =
> ResourcesPlugin.getWorkspace().newProjectDescription(earProj ect.getName());
> earProject.create(earProjectDesription, new
> SubProgressMonitor(progressMonitor, 10));
> earProject.open(new SubProgressMonitor(progressMonitor, 10));
>
> final IFacetedProject earFacetedProject =
> ProjectFacetsManager.create(earProject, true, new
> SubProgressMonitor(progressMonitor, 10));
> IActionDefinition earInstallAction =
> EARFacetUtils.EAR_14.getActionDefinition(Collections.singlet on(EARFacetUtils.EAR_14),
> IFacetedProject.Action.Type.INSTALL);
> IDataModel earConfig = (IDataModel)
> earInstallAction.createConfigObject(EARFacetUtils.EAR_14,
> earProject.getName());
>
> earConfig.setProperty(IEarFacetInstallDataModelProperties.J2 EE_PROJECTS_LIST,
> Arrays.asList(new IProject[]{ejbProject}));
> earConfig.setProperty(IEarFacetInstallDataModelProperties.JA VA_PROJECT_LIST,
> Collections.EMPTY_LIST);
> earConfig.setBooleanProperty(IFacetDataModelProperties.SHOUL D_EXECUTE,
> Boolean.TRUE);
>
> IDataModel master = DataModelFactory.createDataModel(new
> EARFacetProjectCreationDataModelProvider());
> master.setStringProperty(IFacetDataModelProperties.FACET_PRO JECT_NAME,
> earConfig.getStringProperty(IFacetDataModelProperties.FACET_ PROJECT_NAME));
> master.setProperty(IFacetProjectCreationDataModelProperties. FACET_DM_MAP,
> Collections.singletonMap(EARFacetUtils.EAR_FACET.getId(), earConfig));
> master.setProperty(IFacetProjectCreationDataModelProperties. FACET_ACTION_MAP,
> Collections.EMPTY_MAP);
> master.setProperty(FacetProjectCreationDataModelProvider.REQ UIRED_FACETS_COLLECTION,
> Collections.singletonList(EARFacetUtils.EAR_FACET));
>
> earConfig.setProperty(FacetInstallDataModelProvider.MASTER_P ROJECT_DM,
> master);
>
> earFacetedProject.installProjectFacet(EARFacetUtils.EAR_14, earConfig,
> new SubProgressMonitor(progressMonitor, 10));
> earFacetedProject.setFixedProjectFacets(Collections.singleto n(EARFacetUtils.EAR_FACET));
>
>
> ------------------------------------------------------------ -
>
> I set a breakpoint in FacetedProject.modify(Set, IProgressMonitor) and
> ran the above code headless,
> stopping in FacetedProject.modify when being called as a result of the
> second to last line above.
> I then started a debug workbench and ran the EAR Wizard, selecting the
> EJB project created by the above code,
> stopping in FacetedProject.modify at exactly the same point.
>
> At this time I compared the "actions" in the two threads.
> They both have exactly the same structure and the same information.
> One would expect these two threads to then go on to do the same things.
> But, the wizard thread succeeds while the headless thread does not.
> The headless thread reports a parse error to stderr and does not link
> the EJB to the EAR (does not add the module).
>
> Upon further examination (parallel stepping) the first (and so far only)
> difference between the threads
> is found in
> AddComponentToEnterpriseApplicationOp.updateEARDD(IProgressM onitor).
>
> earEdit.artifactEditModel.emfContext.resourceSet.resourceFac toryRegistery.factories{WTPResourceFactoryRegistry}.value.re ndererFactory
>
>
> for the wizard thread this is:
> org.eclipse.wst.xml.core.internal.emf2xml.EMF2DOMSSERenderer Factory
> for the headless thread this is:
> org.eclipse.wst.common.internal.emf.resource.EMF2DOMRenderer Factory
>
> This artifactEditModel comes directly from the ModuleCoreNature of this
> project.
> I am as yet unsure as to why these two ModuleCoreNatures differ in this
> manner.
> However, I believe that this difference is what is causing my problem.
>
>
>
> So my questions are...
>
> Why do these ModuleCoreNatures differ, and is this a bug?
> If it isn't a bug, and something else needs done first, it is completely
> non-obvious.
> Also, I'm suspecting this is a bug as the same issue causes the same
> problem
> when the wtp code itself internally creates an EAR project automatically
> (as in
> EJBFacetPostInstallDelegate::J2EEFacetInstallDelegate.instal lEARFacet)
> when creating an EJB project which requires it.
>
> Do I need to use several property names which are internal?
> IEjbFacetInstallDataModelProperties.CREATE_CLIENT
> IEarFacetInstallDataModelProperties.J2EE_PROJECTS_LIST
> IEarFacetInstallDataModelProperties.JAVA_PROJECT_LIST
>
> Is there a non-internal (and non-magic) way to access the EJB facets and
> facet versions?
> EjbFacetInstallDataModelProvider.EJB_21

The error I'm getting is

org.eclipse.emf.common.util.WrappedException: org.xml.sax.SAXParseException: cvc-complex-type.2.4.b:
The content of element 'application' is not complete.
One of '{"http://java.sun.com/xml/ns/j2ee":display-name,
"http://java.sun.com/xml/ns/j2ee":icon, "http://java.sun.com/xml/ns/j2ee":module}' is expected.

The EAR the EARFacetIntallDelegate writes out
is an unfinished (non-module containing) application.xml
(the http://java.sun.com/xml/ns/j2ee/application_1_4.xsd requires
at least one module as the default for min-occurs is one).
When the PostInstallDelegate tries to open this file the error occurs
(because we're opening a non-validating application.xml).

I'm not sure why headless is using a different renderer,
it makes little sense to change something this fundamental (and non-ui)
just because we're running headless. I think this is more of an oversight,

org.eclipse.wst.xml.core/plugin.xml
<extension
point="org.eclipse.jem.util.uiContextSensitiveClass">
<uiContextSensitiveClass
context="UI"
key="rendererFactory"
className=" org.eclipse.wst.xml.core.internal.emf2xml.EMF2DOMSSERenderer Factory ">
</uiContextSensitiveClass>
<uiContextSensitiveClass
key="ValidateEditContext"
className=" org.eclipse.wst.common.internal.emfworkbench.validateedit.Va lidateEditHeadlessContext "
context="Headless">
</uiContextSensitiveClass>
</extension>

org.eclipse.wst.common.emf/plugin.xml
<extension
point="org.eclipse.jem.util.uiContextSensitiveClass">
<uiContextSensitiveClass
context="Headless"
key="rendererFactory"
className=" org.eclipse.wst.common.internal.emf.resource.EMF2DOMRenderer Factory ">
</uiContextSensitiveClass>
</extension>

is there a reason for this, or is it something that was just overlooked?
Note that my code does result in the creation of an EAR project and an EJB project,
its just the the EARFacetPostInstallDelegate can't load the incomplete (non-validating)
application.xml produced by EARFacetInstallDelegate when it is using the
org.eclipse.wst.common.internal.emf.resource.EMF2DOMRenderer Factory instad of the
org.eclipse.wst.xml.core.internal.emf2xml.EMF2DOMSSERenderer Factory ,
so the module section of the application.xml (linking the EAR to the EJB) never gets written.

If no one gets back to me on this I'm going to report it as a bug.
Re: Headless workspace compilation [message #188155 is a reply to message #188138] Sat, 17 February 2007 19:59 Go to previous message
Eclipse UserFriend
Originally posted by: wagnerb.us.ibm.com

wagnerb wrote:
> wagnerb wrote:
>> Ok, I've taken a look at how the wizard works. I modified my code to
>> read as follows:
>>
>> ------------------------------------------------------------ -
>>
>> IProgressMonitor progressMonitor = new NullProgressMonitor();
>>
>> final String projectName = "project";
>> final String earProjectName = projectName + "EAR";
>> final String ejbProjectName = projectName + "EJB";
>>
>> final IProject earProject =
>> ResourcesPlugin.getWorkspace().getRoot().getProject(earProje ctName);
>> final IProject ejbProject =
>> ResourcesPlugin.getWorkspace().getRoot().getProject(ejbProje ctName);
>>
>> if (earProject.exists()) {
>> earProject.delete(true, true, new
>> SubProgressMonitor(progressMonitor, 10));
>> }
>> if (ejbProject.exists()) {
>> ejbProject.delete(true, true, new
>> SubProgressMonitor(progressMonitor, 10));
>> }
>>
>> //final IProjectFacet EJB_FACET =
>> ProjectFacetsManager.getProjectFacet("jst.ejb");
>> //final IProjectFacetVersion EJB_21 = EJB_FACET.getVersion("2.1");
>> final IProjectFacetVersion EJB_21 =
>> EjbFacetInstallDataModelProvider.EJB_21;
>> final IProjectFacet EJB_FACET = EJB_21.getProjectFacet();
>>
>> final IProjectDescription ejbProjectDescription =
>> ResourcesPlugin.getWorkspace().newProjectDescription(ejbProj ect.getName());
>>
>> ejbProject.create(ejbProjectDescription, new
>> SubProgressMonitor(progressMonitor, 10));
>> ejbProject.open(new SubProgressMonitor(progressMonitor, 10));
>>
>> final IFacetedProject ejbFacetedProject =
>> ProjectFacetsManager.create(ejbProject, true, new
>> SubProgressMonitor(progressMonitor, 10));
>>
>> //Install Java facet (required by EJB facet).
>> final IActionDefinition javaInstallAction =
>> JavaFacetUtils.JAVA_50.getActionDefinition(Collections.singl eton(JavaFacetUtils.JAVA_50),
>> IFacetedProject.Action.Type.INSTALL);
>> final Object javaConfig =
>> javaInstallAction.createConfigObject(JavaFacetUtils.JAVA_50,
>> ejbProject.getName());
>> ejbFacetedProject.installProjectFacet(JavaFacetUtils.JAVA_50 ,
>> javaConfig, new SubProgressMonitor(progressMonitor, 10));
>>
>> //Install EJB facet.
>> final IActionDefinition ejbInstallAction =
>> EJB_21.getActionDefinition(Collections.singleton(EJB_21),
>> IFacetedProject.Action.Type.INSTALL);
>> final IDataModel ejbConfig = (IDataModel)
>> ejbInstallAction.createConfigObject(EJB_21, ejbProject.getName());
>> //ejbConfig.setBooleanProperty(IJ2EEModuleFacetInstallDataMo delProperties.ADD_TO_EAR,
>> Boolean.TRUE);
>> //ejbConfig.setStringProperty(IJ2EEModuleFacetInstallDataMod elProperties.EAR_PROJECT_NAME,
>> earProject.getName());
>> ejbConfig.setBooleanProperty(IEjbFacetInstallDataModelProper ties.CREATE_CLIENT,
>> Boolean.FALSE);
>> ejbFacetedProject.installProjectFacet(EJB_21, ejbConfig, new
>> SubProgressMonitor(progressMonitor, 10));
>>
>> //Fix the facets.
>> ejbFacetedProject.setFixedProjectFacets(new
>> HashSet<IProjectFacet>(Arrays.asList(new IProjectFacet[]{EJB_FACET,
>> JavaFacetUtils.JAVA_FACET})));
>>
>>
>> IProjectDescription earProjectDesription =
>> ResourcesPlugin.getWorkspace().newProjectDescription(earProj ect.getName());
>>
>> earProject.create(earProjectDesription, new
>> SubProgressMonitor(progressMonitor, 10));
>> earProject.open(new SubProgressMonitor(progressMonitor, 10));
>>
>> final IFacetedProject earFacetedProject =
>> ProjectFacetsManager.create(earProject, true, new
>> SubProgressMonitor(progressMonitor, 10));
>> IActionDefinition earInstallAction =
>> EARFacetUtils.EAR_14.getActionDefinition(Collections.singlet on(EARFacetUtils.EAR_14),
>> IFacetedProject.Action.Type.INSTALL);
>> IDataModel earConfig = (IDataModel)
>> earInstallAction.createConfigObject(EARFacetUtils.EAR_14,
>> earProject.getName());
>>
>> earConfig.setProperty(IEarFacetInstallDataModelProperties.J2 EE_PROJECTS_LIST,
>> Arrays.asList(new IProject[]{ejbProject}));
>> earConfig.setProperty(IEarFacetInstallDataModelProperties.JA VA_PROJECT_LIST,
>> Collections.EMPTY_LIST);
>> earConfig.setBooleanProperty(IFacetDataModelProperties.SHOUL D_EXECUTE,
>> Boolean.TRUE);
>>
>> IDataModel master = DataModelFactory.createDataModel(new
>> EARFacetProjectCreationDataModelProvider());
>> master.setStringProperty(IFacetDataModelProperties.FACET_PRO JECT_NAME,
>> earConfig.getStringProperty(IFacetDataModelProperties.FACET_ PROJECT_NAME));
>>
>> master.setProperty(IFacetProjectCreationDataModelProperties. FACET_DM_MAP,
>> Collections.singletonMap(EARFacetUtils.EAR_FACET.getId(), earConfig));
>> master.setProperty(IFacetProjectCreationDataModelProperties. FACET_ACTION_MAP,
>> Collections.EMPTY_MAP);
>> master.setProperty(FacetProjectCreationDataModelProvider.REQ UIRED_FACETS_COLLECTION,
>> Collections.singletonList(EARFacetUtils.EAR_FACET));
>>
>> earConfig.setProperty(FacetInstallDataModelProvider.MASTER_P ROJECT_DM,
>> master);
>>
>> earFacetedProject.installProjectFacet(EARFacetUtils.EAR_14, earConfig,
>> new SubProgressMonitor(progressMonitor, 10));
>> earFacetedProject.setFixedProjectFacets(Collections.singleto n(EARFacetUtils.EAR_FACET));
>>
>>
>> ------------------------------------------------------------ -
>>
>> I set a breakpoint in FacetedProject.modify(Set, IProgressMonitor) and
>> ran the above code headless,
>> stopping in FacetedProject.modify when being called as a result of the
>> second to last line above.
>> I then started a debug workbench and ran the EAR Wizard, selecting the
>> EJB project created by the above code,
>> stopping in FacetedProject.modify at exactly the same point.
>>
>> At this time I compared the "actions" in the two threads.
>> They both have exactly the same structure and the same information.
>> One would expect these two threads to then go on to do the same things.
>> But, the wizard thread succeeds while the headless thread does not.
>> The headless thread reports a parse error to stderr and does not link
>> the EJB to the EAR (does not add the module).
>>
>> Upon further examination (parallel stepping) the first (and so far
>> only) difference between the threads
>> is found in
>> AddComponentToEnterpriseApplicationOp.updateEARDD(IProgressM onitor).
>>
>> earEdit.artifactEditModel.emfContext.resourceSet.resourceFac toryRegistery.factories{WTPResourceFactoryRegistry}.value.re ndererFactory
>>
>>
>> for the wizard thread this is:
>> org.eclipse.wst.xml.core.internal.emf2xml.EMF2DOMSSERenderer Factory
>> for the headless thread this is:
>> org.eclipse.wst.common.internal.emf.resource.EMF2DOMRenderer Factory
>>
>> This artifactEditModel comes directly from the ModuleCoreNature of
>> this project.
>> I am as yet unsure as to why these two ModuleCoreNatures differ in
>> this manner.
>> However, I believe that this difference is what is causing my problem.
>>
>>
>>
>> So my questions are...
>>
>> Why do these ModuleCoreNatures differ, and is this a bug?
>> If it isn't a bug, and something else needs done first, it is
>> completely non-obvious.
>> Also, I'm suspecting this is a bug as the same issue causes the same
>> problem
>> when the wtp code itself internally creates an EAR project automatically
>> (as in
>> EJBFacetPostInstallDelegate::J2EEFacetInstallDelegate.instal lEARFacet)
>> when creating an EJB project which requires it.
>>
>> Do I need to use several property names which are internal?
>> IEjbFacetInstallDataModelProperties.CREATE_CLIENT
>> IEarFacetInstallDataModelProperties.J2EE_PROJECTS_LIST
>> IEarFacetInstallDataModelProperties.JAVA_PROJECT_LIST
>>
>> Is there a non-internal (and non-magic) way to access the EJB facets
>> and facet versions?
>> EjbFacetInstallDataModelProvider.EJB_21
>
> The error I'm getting is
>
> org.eclipse.emf.common.util.WrappedException:
> org.xml.sax.SAXParseException: cvc-complex-type.2.4.b:
> The content of element 'application' is not complete.
> One of '{"http://java.sun.com/xml/ns/j2ee":display-name,
> "http://java.sun.com/xml/ns/j2ee":icon,
> "http://java.sun.com/xml/ns/j2ee":module}' is expected.
>
> The EAR the EARFacetIntallDelegate writes out
> is an unfinished (non-module containing) application.xml
> (the http://java.sun.com/xml/ns/j2ee/application_1_4.xsd requires
> at least one module as the default for min-occurs is one).
> When the PostInstallDelegate tries to open this file the error occurs
> (because we're opening a non-validating application.xml).
>
> I'm not sure why headless is using a different renderer,
> it makes little sense to change something this fundamental (and non-ui)
> just because we're running headless. I think this is more of an oversight,
>
> org.eclipse.wst.xml.core/plugin.xml
> <extension
> point="org.eclipse.jem.util.uiContextSensitiveClass">
> <uiContextSensitiveClass
> context="UI"
> key="rendererFactory"
>
> className=" org.eclipse.wst.xml.core.internal.emf2xml.EMF2DOMSSERenderer Factory ">
>
> </uiContextSensitiveClass>
> <uiContextSensitiveClass
> key="ValidateEditContext"
>
> className=" org.eclipse.wst.common.internal.emfworkbench.validateedit.Va lidateEditHeadlessContext "
>
> context="Headless">
> </uiContextSensitiveClass>
> </extension>
>
> org.eclipse.wst.common.emf/plugin.xml
> <extension
> point="org.eclipse.jem.util.uiContextSensitiveClass">
> <uiContextSensitiveClass
> context="Headless"
> key="rendererFactory"
>
> className=" org.eclipse.wst.common.internal.emf.resource.EMF2DOMRenderer Factory ">
>
> </uiContextSensitiveClass>
> </extension>
>
> is there a reason for this, or is it something that was just overlooked?
> Note that my code does result in the creation of an EAR project and an
> EJB project,
> its just the the EARFacetPostInstallDelegate can't load the incomplete
> (non-validating)
> application.xml produced by EARFacetInstallDelegate when it is using the
> org.eclipse.wst.common.internal.emf.resource.EMF2DOMRenderer Factory
> instad of the
> org.eclipse.wst.xml.core.internal.emf2xml.EMF2DOMSSERenderer Factory ,
> so the module section of the application.xml (linking the EAR to the
> EJB) never gets written.
>
> If no one gets back to me on this I'm going to report it as a bug.

I found someone who has worked on this project
and may be responsible for this state of affairs.
His suggestion (which is an ugly, ugly, hack, but does work) is to do something like

final boolean validating = org.eclipse.wst.common.internal.emf.resource.EMF2DOMRenderer Factory.getDefaultRendererFactory().isValidating();
if (validating) org.eclipse.wst.common.internal.emf.resource.EMF2DOMRenderer Factory.getDefaultRendererFactory().setValidating(false);
earFacetedProject.installProjectFacet(EARFacetUtils.EAR_14, earConfig, new SubProgressMonitor(progressMonitor, 10));
if (validating) org.eclipse.wst.common.internal.emf.resource.EMF2DOMRenderer Factory.getDefaultRendererFactory().setValidating(true);

I opened a bug on this behavior ( https://bugs.eclipse.org/bugs/show_bug.cgi?id=174554 ).
Previous Topic:Configuring characters to match in XML editor
Next Topic:When do I use IDOMNode.getModel and when do I used StructuredModelManager.getModelForRead?
Goto Forum:
  


Current Time: Fri Apr 19 21:57:43 GMT 2024

Powered by FUDForum. Page generated in 0.03100 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top