About env-entry scope
according to ejb spec
env-entry is scoped to the EJB whose declaration contains the evn-entry
but ,in petstore, class stateMachine get the env-entry .
i can not understand how does "env-entry is scoped to the EJB whose declaration contains the evn-entry " this mean.
Each ejb component (defined by an ejb-name in its corresponding ejb-jar.xml) has its own private component namespace -- java:comp/env. If your ejb is processing an invocation in a business method, say foo(), any lookups to java:comp/env will resolve to that ejb's private namespace. This is also true if you call some utility class from the ejb class. What matters is which ejb is currently active on a particular thread. The lookup doesn't have to be performed from the ejb implementation class itself.
Kenneth Saks
J2EE SDK Team
SUN Microsystems
Similar Messages
-
Hi,
I am trying to develop a session bean. I have three environment
properties. I declared them in my ejb-jar.xml
file like this:
<enterprise-beans>
<session>
<env-entry> (this is line 11)
<env-entry-name>..... </env-entry-name>
<env-entry-type> ... ...</env-entry-type>
<env-entry-value> ... ...</env-entry-value>
</env-entry>
</session>
</enterprise-beans>
I jared this deployment descriptor and my ejb class files together. When I
tried to deploy them in the deployer tool, I got this parser error message:
"session" element does not allow "env-entry" here on line11.
Can somebody help me?
Thanks in advance.
Best Regards
JeffEach ejb component (defined by an ejb-name in its corresponding ejb-jar.xml) has its own private component namespace -- java:comp/env. If your ejb is processing an invocation in a business method, say foo(), any lookups to java:comp/env will resolve to that ejb's private namespace. This is also true if you call some utility class from the ejb class. What matters is which ejb is currently active on a particular thread. The lookup doesn't have to be performed from the ejb implementation class itself.
Kenneth Saks
J2EE SDK Team
SUN Microsystems -
Global env-entry JNDI variables space for same ejb-jar.xml file
[Software]
jboss4.0.5
jdk 1.5
[Problem]
Is there any global <env-entry> tag for a Single EJB Module. Is there any way by which the JNDI variable can be accessed by all the modules except by binding the variables in the JNDI explixity in the code
Thanks in advance
CSJakhariaUnfortunately not. The EJB specification has always scoped the component environment
(java:comp/env) as a private environment for each EJB. The advantage is you can
assign entries within each bean easily without worrying about clashing with names selected
for other beans in the ejb-jar. That eases the process of assembling beans developed
separately into one ejb-jar since there is no possibility that their component environments
will clash.
However, the downside is just what you're pointing out, which is that in many cases
developers prefer to define a single dependency that is shared among all the
beans in the ejb module. That is the behavior of the component environment in a
web application.
We'll be looking into ways to simplify this for ejbs in a future revision of the specification.
--ken -
Edit env-entry values from web.xml in the WLS console.
Hi guys!
Is it possible to define JNDI variables of type java.lang.String using WLS Console?
ThanksI think this would require the use of a deployment plan, which you can learn about here: [http://e-docs.bea.com/wls/docs103/deployment/config.html] . This won't be as convenient as just editing the value directly in the admin console. In fact, it won't even prevent the requirement of redeploying the webapp. It will only allow you to make the change without rebuilding and repackaging the webapp.
It's questionable whether it's practical or meaningful to change env-entry values in a web.xml without redeployment, because even if you could change the values without redeploying, you'd have to reinitialize the servlet/filter with the changed environment parameter.
If you really need this dynamic reconfiguration ability, you might have to design the facility into your application, using some sort of polling or event handling capability. -
Hi,
I'm creating a J2ee application using various EJB's and at least one WAR, all inside one single EAR file.
This app. is to be intalled at different clients. I'd like to be able to specify different properties ( server used, remote host addresses, etc.) in some part of the EAR that will be available using
(String)context.lookup("java:comp/env/" + name );
I have been able to customize individual EJB's using the <env-entry> tag in its DD but what about the being able to customize the whole application??
I'm been scouring docs and the net and I can't see any specific application.wide examples.
Many thanks for your help.
Terry DoyleI faced the same problem some time ago. I went through the EJB 2.0 spec and the DTD of ejb-jar.xml. It appears that env-entry is for an EJB only. There is no 'global' env-entry.
-
Trailing spaces in env-entry-type elements
Hi,
We have been porting our EJB application from another app server over to Oracle iAS (9.0.3 Lite) and have encountered a rather frustrating problem.
We have an CMP (2.x) entity bean that has ejbSelect methods. There are corresponding <query> blocks in the ejb-jar.xml file for these methods. In the same ejb-jar.xml file there are <env-entry> blocks that setup a few things that are needed by the bean.
If the <env-entry-type> element is written as "<env-entry-type>java.lang.String </env-entry-type>" (note the trailing space after the type name) the following exception occurs during deployment of the ear file;
java.lang.InstantiationException: Failure to initialize EJBQL descriptors: com.sun.enterprise.deployment.xml.ContentTransformationException: java.lang.String is not an allowed property value type
at com.evermind.server.ejb.deployment.EJBPackage.initializeEjbqlDescriptors(EJBPackage.java:2075)
at com.evermind.server.ejb.deployment.EJBPackage.init(EJBPackage.java:2054)
at com.evermind.server.ServerComponent.init(ServerComponent.java:208)
at com.evermind.server.ejb.EJBPackageDeployment.getPackage(EJBPackageDeployment.java:672)
at com.evermind.server.administration.ServerApplicationInstallation.finish(ServerApplicationInstallation.java:547)
at com.evermind.server.administration.ServerApplicationInstallation.deploy(ServerApplicationInstallation.java:913)
at com.evermind.server.administration.DefaultApplicationServerAdministrator.deploy(DefaultApplicationServerAdministrator.java:337)
at java.lang.reflect.Method.invoke(Native Method)
at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:119)
at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48)
at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
at java.lang.Thread.run(Thread.java:479)
Error during deployment: Failure to initialize EJBQL descriptors: com.sun.enterprise.deployment.xml.ContentTransformationException: java.lang.String is not an allowed property value type
Removing the trailing space and the deployment proceeds to completion without exceptions.
I should also add that if the ejbSelect methods are remove d from the application and the trailing space left in place the resulting ear file will deploy sucessfully.
It is trivial to reproduce this problem with the ORMAP demo that ships with 9.0.3.
This was a really subtle problem that is not present on the *3* other appserver implementations that our application runs on. It was very frustrating to locate and perhaps some consideration could be given to how PCDATA is handled when parsing <env-entry-type> blocks.
Cheers,
Mick.Hi ,
Create two Characteristic InfoObjects in BW With length 60 Char and then in the Transfer Rules of this two InfoObjects write the Formula using Left() and right() function present in the Formula Builder .
That is First infoObject Contains the Left 60 Char and next one Contains the right 60 Char.
Regards,
Vijay. -
Query Reg env-entry in ejb jar xml
Hi,
I have the following tag in the ejb-jar of my application:
<env-entry>
<env-entry-name>postingDate</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>Request</env-entry-value>
</env-entry>
When a JNDI LookUp is done for this variable in the application, it doesn't pick up the value of the variable which is "Request" but it picks up the Value of the Posting Date.
I need to know how this works!
Just an Fyi, Posting Date is a date entered from the UI.I feel it is like declaring global and local variables with the same name and trying to access that variable.
-
Validation error when using env-entry in web.xml
I've added an env-entry element to my web.xml and it falls over at deploy time with a validation error. However, from what I can see, this is valid based on the schema.
And infact, it matches the example in the weblogic doco - http://edocs.bea.com/wls/docs103/webapp/web_xml.html#wp1025195
The error I'm getting is:
<17/12/2008 11:45:56 AM EST> <Error> <J2EE> <BEA-160197> <Unable to load descriptor D:\workspace\source_checkout\investment_control\ic-web\src\main\webapp/WEB-INF/web.xml of module ic-web.war. The error is weblogic.descriptor.DescriptorException: VALIDATION PROBLEMS WERE FOUND
problem: cvc-complex-type.2.4a: Expected elements 'mapped-name@http://java.sun.com/xml/ns/javaee injection-target@http://java.sun.com/xml/ns/javaee' instead of 'env-entry-type@http://java.sun.com/xml/ns/javaee' here in element env-entry@http://java.sun.com/xml/ns/javaee:<null>
at weblogic.descriptor.internal.MarshallerFactory$1.evaluateResults(MarshallerFactory.java:234)
at weblogic.descriptor.internal.MarshallerFactory$1.evaluateResults(MarshallerFactory.java:221)
My web.xml looks like:
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<description>IC Web</description>
<env-entry>
<env-entry-name>aEntry</env-entry-name>
<env-entry-value>aValue</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
</web-app>
Any suggestions???Found a resolution to this in the end.
Unless you have the sub-elements in the order below, it will get validation errors.
<env-entry>
<env-entry-name>maxAmount</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>aString</env-entry-value>
</env-entry>
A bit weird and very frustrating.... -
Issue with [env-entry] element in web.xml
I know it's possible to define [env-entry] elements in web.xml for environment
properties of a web application. But how do you access [env-entry] elements from
classes that do not exist within a web application? In other words, this is my
problem:
I have an EAR file, enterprise.ear, which contains the following...
employee.jar
employeeSearchEJB.jar
webApp1.war
META-INF/
application.xml
The employee.jar file is a utility archive that contains common classes, one of
which is a class called LogManager. LogManager needs to read environment properties
in order to initialize itself. Currently, LogManager reads these properties from
a property file, and therefore it needs to know the name of the property file
in order to access it. I dont like this approach because I'm forced to hard-code
the name of the property file in LogManager. I would rather leverage the power
of J2EE deployment descriptors and use the [env-entry] element to define the environment
properties for the LogManager class. Then, I would simply use JNDI to get the
values of the [env-entry] elements without ever having to specify their location
aside from the default JNDI context; java:comp/env, which is standard anyway.
The problem I'm having is that you can define the [env-entry] element in only
2 types of deployment descriptors; namely, web.xml and ejb-jar.xml, neither of
which are available to LogManager because LogManager exists at the EAR root level.
I was hoping application.xml supported the [env-entry] element, but it doesn't.
Any suggestions?
SAFSAF,
I am not sure if this applies to you situation but if you create an initial context
instance and then grab the value using the jndi name within that context then
you should be able to grab that environment variable.
I have a helper class that is used as part of a deployed application. The helper
class doesn't have access to the Servlet context but it is created as part of
the application workflow. When it gets initiated it grabs an env-entry created
in the web.xml deployment descriptor to find the default url for a content path.
After I create an initialContext, I perform a initContext.lookup("jndi.env.entry.here")
where "jndi.env.entry.here" is the name specified in the env-entry tag.
This returns the value of the entry.
This works under both Jrun and Weblogic so my guess is it should work for you.
Again, I am assuming that your class will at least be able to grab a context
object to communicate back to the server.
Hope this helps,
Troy
"SAF" <[email protected]> wrote:
>
I know it's possible to define [env-entry] elements in web.xml for environment
properties of a web application. But how do you access [env-entry] elements
from
classes that do not exist within a web application? In other words, this
is my
problem:
I have an EAR file, enterprise.ear, which contains the following...
employee.jar
employeeSearchEJB.jar
webApp1.war
META-INF/
application.xml
The employee.jar file is a utility archive that contains common classes,
one of
which is a class called LogManager. LogManager needs to read environment
properties
in order to initialize itself. Currently, LogManager reads these properties
from
a property file, and therefore it needs to know the name of the property
file
in order to access it. I dont like this approach because I'm forced to
hard-code
the name of the property file in LogManager. I would rather leverage
the power
of J2EE deployment descriptors and use the [env-entry] element to define
the environment
properties for the LogManager class. Then, I would simply use JNDI to
get the
values of the [env-entry] elements without ever having to specify their
location
aside from the default JNDI context; java:comp/env, which is standard
anyway.
The problem I'm having is that you can define the [env-entry] element
in only
2 types of deployment descriptors; namely, web.xml and ejb-jar.xml, neither
of
which are available to LogManager because LogManager exists at the EAR
root level.
I was hoping application.xml supported the [env-entry] element, but it
doesn't.
Any suggestions?
SAF -
Bug in lookup of web.xml env-entry in WL 7.0?
If I create an "env-entry" block for a name (e.g. "MySchemaName") in my web.xml
file and deploy the web app, I should be able to look up the name from my webapp
with the line:
<br>
myInitialContext.lookup("java:comp/env/MySchemaName");
<br>
However when I do that I get the error message:
<br>
javax.naming.NameNotFoundException: Unable to resolve 'java:comp.env/MySchemaName'
<br>
Note that the "comp/env" prefix has been changed to "comp.env". This worked under
WL 6.1. Is this a bug in WL 7's JNDI or a bug in the error message or both or
something else altogether?
The immediately previous line successfully performs an EJBHome lookup using the
same Initial Context object. The main difference is that the EJBHome name is defined
thru the EJB deployment descriptors, not the web.xml.
Thanks,
SteveAh, I was trying to do a lookup from session bean for the env-entry defined in
the web.xml. After reading the J2EE spec, I see this just won't work. env-entries
are only accessible from within the component where they are defined.
Still the error message with "comp.env" instead of the expected "comp/env" is
a bit confusing.
Not much traffic in this newsgroup, is there?
Steve
"Steve Ditlinger" <[email protected]> wrote:
>
>
>
If I create an "env-entry" block for a name (e.g. "MySchemaName") in
my web.xml
file and deploy the web app, I should be able to look up the name from
my webapp
with the line:
<br>
myInitialContext.lookup("java:comp/env/MySchemaName");
<br>
However when I do that I get the error message:
<br>
javax.naming.NameNotFoundException: Unable to resolve 'java:comp.env/MySchemaName'
<br>
Note that the "comp/env" prefix has been changed to "comp.env". This
worked under
WL 6.1. Is this a bug in WL 7's JNDI or a bug in the error message or
both or
something else altogether?
The immediately previous line successfully performs an EJBHome lookup
using the
same Initial Context object. The main difference is that the EJBHome
name is defined
thru the EJB deployment descriptors, not the web.xml.
Thanks,
Steve -
Env-entry problem in Pluto portal
I have portlet project. I wrote in web.xml:
<env-entry>
<env-entry-name>time_interval</env-entry-name>
<env-entry-value>5</env-entry-value>
<env-entry-type>java.lang.Long</env-entry-type>
</env-entry>
<env-entry>
<env-entry-name>file_path</env-entry-name>
<env-entry-value>d:\tmp</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
I get following error during deploying portlet:
12:21:30,588 INFO [Engine]
StandardContext[pluto]PortletDefinitionRegistryService initializing...
12:21:32,561 ERROR [Engine] StandardContext[pluto]ServiceManager: An
unidentified error occurred
ValidationException: element "env-entry" occurs more than once.
(XMLFieldDesciptor: envEntry AS env-entry)
at
org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:
730)
But when I put only one env-entry in web.xml, it works perfectly.
Does any solution exist for adding more than one env-entry?I have portlet project. I wrote in web.xml:
<env-entry>
<env-entry-name>time_interval</env-entry-name>
<env-entry-value>5</env-entry-value>
<env-entry-type>java.lang.Long</env-entry-type>
</env-entry>
<env-entry>
<env-entry-name>file_path</env-entry-name>
<env-entry-value>d:\tmp</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
I get following error during deploying portlet:
12:21:30,588 INFO [Engine]
StandardContext[pluto]PortletDefinitionRegistryService initializing...
12:21:32,561 ERROR [Engine] StandardContext[pluto]ServiceManager: An
unidentified error occurred
ValidationException: element "env-entry" occurs more than once.
(XMLFieldDesciptor: envEntry AS env-entry)
at
org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:
730)
But when I put only one env-entry in web.xml, it works perfectly.
Does any solution exist for adding more than one env-entry? -
In my ejb-jar.xml I have a Session bean with a env-entry:
<env-entry>
<env-entry-name>xslNameFile</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>pdftemplate.xsl</env-entry-value>
</env-entry>
In a class where I use the bean I make a lookup of this env-entry (using the same
context):
Context environment = (Context)ctx.lookup("java:comp/env/");
val = (String)environment.lookup("xslNameFile");
And I have the following Exception:
javax.naming.NameNotFoundException: Unable to resolve 'comp/env/xslNameFile' Reso
lved: 'comp/env' Unresolved:'xslNameFile' ; remaining name 'xslNameFile'
What I m doing wrong??
Could anyone help me?
Thanks
F.CanonicaHI ,
The Primary Purpose of <env-entry> tag
is used to Customize your bean at Runtime
and to Make your bean as an DataDriven one.
( instead of Storing it in DataBase )
Regards
Karthikeyan Gangadharan
"Deepak Vohra" <[email protected]> wrote:
>
>
>
InitialContext ic = new InitialContext();
String val = (String) ic.lookup("java:/comp/env/xslNameFile");
"canonica" <[email protected]> wrote:
In my ejb-jar.xml I have a Session bean with a env-entry:
<env-entry>
<env-entry-name>xslNameFile</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>pdftemplate.xsl</env-entry-value>
</env-entry>
In a class where I use the bean I make a lookup of this env-entry (using
the same
context):
Context environment = (Context)ctx.lookup("java:comp/env/");
val = (String)environment.lookup("xslNameFile");
And I have the following Exception:
javax.naming.NameNotFoundException: Unable to resolve 'comp/env/xslNameFile'
Reso
lved: 'comp/env' Unresolved:'xslNameFile' ; remaining name 'xslNameFile'
What I m doing wrong??
Could anyone help me?
Thanks
F.Canonica -
env-entry element in ejb-jar.xml
I just started to create my ejb-jar.xml (deployment descriptor file) manually so
that I won't depend on those generated by proprietary IDEs.
The ejb-jar_2_0.dtd specifies that env-entry is used in
entity, message-driven, and session elements.
My question is - When do we use the element <env-entry>? Under what
circumstances that ejb-jar_2_0.dtd necessitates its provision in the ejb-jar.xml
in relation to entity, message-driven, and session elements?Hi,
I've same prob here
<env-entry>
<env-entry-name>config.file.location</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>C:/bea/ITReportingConf.xml</env-entry-value>
</env-entry>
Right now config file is out side of my EAR, How can i put it within the EAR I tried with changing the
<env-entry-value>/ITReportingConf.xml</env-entry-value> Value
But i dont know which dir it is refering to and where should i put "ITReportingConf.xml" File
Thanks -
Env-entry reachable from more than one bean
Is it possible to reach env-entries of one session-bean from another session-bean within same ejb-jar.xml?
Or is the only way to write them twice, once per each bean.Greetings,
Is it possible to reach env-entries of one
session-bean from another session-bean within same
ejb-jar.xml?In theory, a JNDI namespace is hierarchical (a tree structure - like a filesystem) - and a server typically maintains a global namespace - so as long as your bean knows the lookup name of the entry it can be accessed regardless of the locality of the bean (ie. it may even exist in a separate application running on the same server!). However...
Or is the only way to write them twice, once per each
bean.The purpose of environment entries is to provide "post-compile time" customization to your beans and so ideally each bean should have it's own env-entries specific to it's needs. Additionally, depending on your vendor implementation private namespaces for env-entries might be provided and/or you may also get assembly/deployment errors for beans performing lookups against the namespace for which assembly mappings were not provided. In these cases you will have to devise a mechanism for the passing the env information between your beans (since the specification prohibits beans from modifying their runtime environments. ':-o ).
I hope this helpful.
Regards,
Tony "Vee Schade" Cook -
Hi,
Did anyone try <env-entry-mapping> in orion-ejb-jar.xml? It seems that it is suppressed during deployment. The orion-ejb-jar.xml being generated into -deploymentDirectory place (specified or default) simply drops these mappings. The effect is that whatever had been specified in ejb-jar.xml prevails, with obvious, bad consequences.
Besides, I think I read somewhere that Deployer-supplied orion-ejb-jar.xml would only be augmented with missing specifications. This to me implies that nothing should be removed from it. Perhaps, then, THIS IS A BUG.
ORION TEAM: I'm running 9.0.3.0.0/NT. I'd appreciate your help and 'know-how', especially if you could offer something better than manually editing orion-ejb-jar.xml in -deploymentDirectory AFTER EACH SUCH TIME THE APPLICATION IS DEPLOYED!Avi!
Of course, I had tried it before I wrote the question. I put the modified xml file into the application area. After that AS restarts OC4J instance. And then I find my xml without any changes I made! I tried to do the same thing from the AS console. The same!
Leonid
Maybe you are looking for
-
Hi, thanks for looking over my sudden Mac Pro problem. Recently, my Mac Pro Intel Xeon started to have continuous Kernel Panics, all during simultaneous programs running, but also with a common Mac torrent program running, Transmission. Keep in mind
-
Cant find my iTunes library after migration from old PC to new Mac
Can't find my iTunes library after migration from old PC to new Mac?
-
Converting HH24:MI:SS to seconds Issue
Hallo Everyone, I’m fairly new (read: about 2 days) to the whole PL/SQL world and I’ve run into a little problem with one of my projects. I’ve googled and looked around the forums and tried to apply what I have picked up but so far without much succe
-
File Transfer File Failure Question
Hi - I need to transfer my website to another host. As I'm downloading my files, I usually get some errors on some files that did not transfer. Sure I get a log that says which ones, but do I have to actually go and choose them individually to atte
-
Some albums only match 90% of songs while some are uploaded. Is this fixable?
I have a few well known albums like "Universal Religion Chapter 4" where only a few tracks are correctly matched. Others are uploaded. Is it possible to fix this situation like asking iTunes Match for re-analysis or having some kind of assistent to m