cancel
Showing results for 
Search instead for 
Did you mean: 

com.sap.engine.lib.injection.InjectionException

Former Member
0 Kudos

Hello,

I have a generic crud component (an EJB called CrudServiceBean) which has an EntityManager such as attribute and in other project some entities (with JPA).

Project1:

- CrudServiceBean.java

- CrudServiceLocal.java

Project2:

- CeraEmployee.java

- Persistence.xml

Project3:

- App.java

When I try to use some method of CrudServiceBean in App.java I get an exception, u201Ccom.sap.engine.lib.injection.InjectionException: Injection on field entityManager of instance co.com.crystal.util.CrudServiceBean@4e40f180 failed. Could not get a value to be injected from the factoryu201D

But the persistence.xml file (with the persistence unit ) is in the entity project because the generic crud will be used in many entities projects, so how can I use my generic crud component out of the entity project?

Regards

Janeth

Accepted Solutions (1)

Accepted Solutions (1)

Vlado
Advisor
Advisor
0 Kudos

Hi Janeth,

As long as Project1 and Project2 are part of the same EAR, that should be fine.

Please look into the defaultTrace.trc file for the cause exception that would explain the "Could not get a value to be injected from the factory" thing.

HTH!

\-- Vladimir

Former Member
0 Kudos

Hi Vladimir,

Thank you for your help, but when I put project1 and 2 in the same ear, I get a compilation error when I build another project (project4) which has a used component of project3 and a dependency of the ear (it need classes of project2). I think it will be because a bad reference.

this is a little explanation about each project:

Project1: it has the EJB to access a DB

Project2: it has the entities (jpa)

Project3: it encapsulated the methods to access a DB (it needs Project1 and Project2 for the injection)

Project4: it used a component of project3 and has a model of project2

The idea is reuse project1 and project3 in other applications.

I donu2019t know if itu2019s a good design or if Iu2019m doing unnecessary references.

thanks a lot!!!

regards

Janeth

The error:

[echo]   output dir:  C:\dir_workspace\ws_model.jdi\LocalDevelopment\t\506FD3EE47C4EC6DF3A6C6C7D65423BB\classes
     [javac] Compiling 14 source files to C:\dir_workspace\ws_model.jdi\LocalDevelopment\t\506FD3EE47C4EC6DF3A6C6C7D65423BB\classes
     [javac] An exception has occurred in the compiler (1.5.0_15). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report.  Thank you.
     [javac] com.sun.tools.javac.code.Symbol$CompletionFailure: file javax\persistence\Table.class not found
Error: C:\dir_workspace\ws_model.jdi\LocalDevelopment\t2\506FD3EE47C4EC6DF3A6C6C7D65423BB\default\logs\build.xml:232: Compile failed; see the compiler error output for details.
	at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:933)
	at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:757)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
	at org.apache.tools.ant.Task.perform(Task.java:364)
	at org.apache.tools.ant.Target.execute(Target.java:341)
	at org.apache.tools.ant.Target.performTasks(Target.java:369)
	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
	at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
	at com.sap.tc.buildplugin.techdev.ant.util.AntRunner.run(AntRunner.java:114)
	at com.sap.tc.buildplugin.DefaultAntBuildAction.execute(DefaultAntBuildAction.java:57)
	at com.sap.tc.buildplugin.DefaultPlugin.handleBuildStepSequence(DefaultPlugin.java:196)
	at com.sap.tc.buildplugin.DefaultPlugin.performBuild(DefaultPlugin.java:168)
	at com.sap.tc.buildplugin.DefaultPluginV3Delegate$BuildRequestHandler.handle(DefaultPluginV3Delegate.java:66)
	at com.sap.tc.buildplugin.DefaultPluginV3Delegate.requestV3(DefaultPluginV3Delegate.java:48)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at com.sap.tc.buildtool.v2.impl.PluginHandler2.maybeInvoke(PluginHandler2.java:400)
	at com.sap.tc.buildtool.v2.impl.PluginHandler2.request(PluginHandler2.java:149)
	at com.sap.tc.buildtool.v2.impl.PluginHandler2.build(PluginHandler2.java:87)
	at com.sap.tc.buildtool.PluginHandler2Wrapper.execute(PluginHandler2Wrapper.java:59)
	at com.sap.tc.devconf.impl.DCProxyMake.make(DCProxyMake.java:260)
	at com.sap.tc.devconf.impl.DCProxy.make(DCProxy.java:1574)
	at com.sap.tc.devconf.impl.DCProxy.make(DCProxy.java:4537)
	at com.sap.ide.dii05.lib.internal.commands.dc.BuildJob.build(BuildJob.java:370)
	at com.sap.ide.dii05.lib.internal.commands.dc.BuildJob.doInWorkerThread(BuildJob.java:187)
	at com.sap.ide.dii05.util.api.job.JdiJob$1.doInWorkerThread(JdiJob.java:75)
	at com.sap.ide.dii05.util.internal.job.InternalJdiJob$3$1.run(InternalJdiJob.java:224)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1797)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1779)
	at com.sap.ide.dii05.util.internal.job.InternalJdiJob$3.run(InternalJdiJob.java:233)
	at com.sap.ide.dii05.util.internal.job.BusyBackgroundIndicator.showWhile(BusyBackgroundIndicator.java:74)
	at com.sap.ide.dii05.util.internal.job.InternalJdiJob.internalRun(InternalJdiJob.java:214)
	at com.sap.ide.dii05.util.internal.job.InternalDiiJob.run(InternalDiiJob.java:275)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Vlado
Advisor
Advisor
0 Kudos

Hi Janeth,

Sounds like you don't actually need Project1-2-3 and could go with a single EJB 3.0 project which contains all your JPA entities and session beans as well as the classes currently in Project3 used to encapsulate the session bean methods (which btw I didn't get but suppose you have some considerations to do that). Then Project4 would just need to depend on this "consolidated" EJB project (note: not on the EAR project that would wrap it!).

HTH!

\-- Vladimir

Former Member
0 Kudos

Hi Vladimir,

Youu2019re right, I separated the consolidated EJB Project in tree because Project 1 and 2 could be used in many applications (not necessary in WD Projects), Project 3 is because of have a WD project with a model, reusable in other WD project not only in Project4.

Now, if Iu2019ve understood, your idea is have one project (1,2 together, project 3 could disappear) and used them in Project4, right? So, that project would to be an EJB Project and Project 4 has to import the model to use it. In that case the project 3 which import a model, and expose it such a methods, isnu2019t necessary?

Thank you!!!

Janeth

Vlado
Advisor
Advisor
0 Kudos

Exactly!

Former Member
0 Kudos

Thank you so much!

Janeth

Answers (0)