Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Added ejb-ref entries to web.xml file
Added ejb-ref entries to web.xml file [message #164533] Tue, 21 March 2006 18:39 Go to next message
Eclipse UserFriend
Originally posted by: jakencam50.yahoo.com

Hello,

I have an existing Dynamic Web Project, and I want to add entries to its
web.xml file via a Facet plug-in. I’m having a small problem trying to
add <ejb-ref> entries to the web.xml file using the WebArtifactEdit class.
Here is what I’m doing in my plug-in:


public static void addWebXMLEntries( final IProject pj )
{
final WebArtifactEdit artifact =
WebArtifactEdit.getWebArtifactEditForWrite( pj );

final WebApp root = artifact.getWebApp();
EjbRefType myEjbRef = getEjbRefType("myEjbRefName",
"myEjbRefType",
"myEjbHome",
"myEjbRemote");
root.getEjbRefs().add(myEjbRef);
artifact.saveIfNecessary( null );
artifact.dispose();
}

This is the method that returns EjbRefType objects

public static EjbRefType getEjbRefType(String ejbRef, String ejbType,
String home, String remote) {

EjbRefType ejbRefType = J2eeFactory.eINSTANCE.createEjbRefType();

EjbRefNameType ejbRefNameType =
J2eeFactory.eINSTANCE.createEjbRefNameType();
ejbRefNameType.setValue(ejbRef);

EjbRefTypeType ejbRefTypeType =
J2eeFactory.eINSTANCE.createEjbRefTypeType();
ejbRefTypeType.setValue(ejbType);

HomeType homeType = J2eeFactory.eINSTANCE.createHomeType();
homeType.setValue(home);

RemoteType remoteType = J2eeFactory.eINSTANCE.createRemoteType();
remoteType.setValue(remote);

ejbRefType.setEjbRefName(ejbRefNameType);
ejbRefType.setEjbRefType(ejbRefTypeType);

ejbRefType.setHome(homeType);
ejbRefType.setRemote(remoteType);

return ejbRefType;
}

However, I’m getting the following exception when installing the facet
with this code into my Dynamic Web Project:


java.lang.ArrayStoreException

at org.eclipse.emf.common.util.BasicEList.assign(BasicEList.jav a:187)
at org.eclipse.emf.common.util.BasicEList.addUnique(BasicEList. java:664)
at
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq ue(NotifyingListImpl.java:271)
at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:5 99)
at com.collabraspace.cs.templates.Utils.addWebXMLEntries(Utils. java:98)
at
com.collabraspace.cs.templates.MyFacetInstallDelegate.execut e(MyFacetInstallDelegate.java:48)
at
org.eclipse.wst.common.project.facet.core.internal.FacetedPr oject.callDelegate(FacetedProject.java:718)
at
org.eclipse.wst.common.project.facet.core.internal.FacetedPr oject.modifyInternal(FacetedProject.java:348)
at
org.eclipse.wst.common.project.facet.core.internal.FacetedPr oject.access$0(FacetedProject.java:247)
at
org.eclipse.wst.common.project.facet.core.internal.FacetedPr oject$1.run(FacetedProject.java:232)
at org.eclipse.core.internal.resources.Workspace.run(Workspace. java:1719)
at
org.eclipse.wst.common.project.facet.core.internal.FacetedPr oject.modify(FacetedProject.java:237)
at
org.eclipse.wst.common.project.facet.ui.AddRemoveFacetsWizar d.performFinish(AddRemoveFacetsWizard.java:344)
at
org.eclipse.wst.common.project.facet.ui.AddRemoveFacetsWizar d$2.run(AddRemoveFacetsWizard.java:288)
at
org.eclipse.jface.operation.ModalContext.runInCurrentThread( ModalContext.java:346)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.ja va:291)
at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java: 830)
at
org.eclipse.wst.common.project.facet.ui.AddRemoveFacetsWizar d.performFinish(AddRemoveFacetsWizard.java:304)
at
org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDi alog.java:676)
at
org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDi alog.java:349)
at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.jav a:556)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:90)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3080)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2713)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:809 )
at org.eclipse.jface.window.Window.open(Window.java:787)
at
org.eclipse.wst.common.project.facet.ui.internal.FacetsPrope rtyPage$2.widgetSelected(FacetsPropertyPage.java:122)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:90)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3080)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2713)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:809 )
at org.eclipse.jface.window.Window.open(Window.java:787)
at
org.eclipse.ui.dialogs.PropertyDialogAction.run(PropertyDial ogAction.java:157)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:996 )
at
org.eclipse.jface.action.ActionContributionItem.handleWidget Selection(ActionContributionItem.java:538)
at
org.eclipse.jface.action.ActionContributionItem.access$2(Act ionContributionItem.java:488)
at
org.eclipse.jface.action.ActionContributionItem$5.handleEven t(ActionContributionItem.java:400)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3080)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2713)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1699)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:367)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:143)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplicatio n.java:103)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:226)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:376)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:163)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334 )
at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
at org.eclipse.core.launcher.Main.run(Main.java:973)
at org.eclipse.core.launcher.Main.main(Main.java:948)


If this matters, the EjbRefType I am using is of the following type:
com.sun.java.xml.ns.j2ee.EjbRefType

Any thoughts anyone may have would be GREATLY appreciated!
Re: Added ejb-ref entries to web.xml file [message #164701 is a reply to message #164533] Thu, 23 March 2006 14:36 Go to previous message
Eclipse UserFriend
Originally posted by: jakencam50.yahoo.com

I was able to get it working on my end. When I used the CommonFactory,
instead of the J2eeFactory, everything seemed to work fine, like this:

EjbRef ejbRef = CommonFactory.eINSTANCE.createEjbRef();
ejbRef.setName("myEJBName");
ejbRef.setType(EjbRefType.get(EjbRefType.SESSION));
ejbRef.setHome("myHome");
ejbRef.setRemote("myRemote");


Jacob
Previous Topic:Eclipse Hangs when creating new Web Module with Linux when no internet connection present
Next Topic:How to get Resin Plugin to respect my context Root?
Goto Forum:
  


Current Time: Thu Aug 29 12:49:15 GMT 2024

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

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

Back to the top