JNDI lookup for request scope component,
Hi,
I have 2 web applications part of single ear file.
Where One application is ATG application having ATG pipeline defined in its web.xml
and 2nd one is a simple j2ee web application.
From 2nd application if I try to lookup a request scoped component by following code
String jndiName = "dynamo:/------compenent path------";
Context ctx = new javax.naming.InitialContext ();
Scheduler s = (Scheduler) ctx.lookup (jndiName);
it shows me following error.
** Error Fri Nov 16 11:04:20 CST 2012 1353085460117 / Invalid attempt to resolve component /atg/-------component path------/ in scope global. It is defined in scope request
Is there any way to resolve it ?
Edited by: Arvind Pal on Nov 16, 2012 2:00 PM
It seems the scheduler global component is resolving the request scope component internally.
For request scope components there should be DynamoHttpServletRequest object in context to resolve.
DynamoHttpServletRequest object is created as part of servlet pipeline.
As you request is not going thru servlet pipeline, there is no DynamoHttpServletRequest and hence the request scope components cannot be resolved.
So check in the scheduler why do you need to resolve the request scope component. Its not good practice to resolve them in schedulers.
Peace
Shaik
Similar Messages
-
JNDI lookup for UserTransaction
Hi all,
in Weblogic, in a typical scenario, do a client provide exactly
one JNDI lookup for the UserTransaction object (interface) or do
the client have to provide a JNDI lookup for each transaction?
In some EJB implementations, a JNDI lookup for UserTransaction
returns always the same reference. For example, in JOnAS, you can
have one static reference which is set when the client starts.
Then, more threads can simultaneously use the same static
UserTransaction reference without any conflict, since the
implementation of UserTransaction recognizes, which thread invoked
a particular method.
In other words, can I make an assumption that two different JNDI
lookups for UserTransaction returns different references or not?
Thanks a lot,
Marek Prochazka
Distributed Systems Research Group
Department of Software Engineering
Charles University, Faculty of Mathematics and Physics
Malostranske namesti 25, 118 00 Prague 1, Czech Republic
phone: +420-2-2191 4236
http://nenya.ms.mff.cuni.cz/thegroup/
Actually, UserTransaction is a singleton and it's not a transaction. It's just
very mis-named.
It should be called UserTransactionManager or UserInterfaceToJTA.
The actual transaction is javax.transaction.Transaction.
-- Rob
Cameron Purdy wrote:
> Within a transaction, it is different instances? For example, if you call
> it two times one right after another?
>
> A transaction is a unit of work. I understand why the transaction object
> changes from transaction to transaction, since a single transaction object
> (UserTransaction) represents exactly one transaction. Why would it be a
> singleton? It is not a transaction manager.
>
> Peace,
>
> --
> Cameron Purdy
> Tangosol, Inc.
> http://www.tangosol.com
> +1.617.623.5782
> WebLogic Consulting Available
>
> "Sarita" <[email protected]> wrote in message
> news:[email protected]...
> >
> > Hi Priscilla--
> >
> > This is not the behavior that I'm seeing, and I'm perplexed.
> > Every time I request a UserTransaction from JNDI, I receive a
> > a different instance. Should the value immediately returned by JNDI be
> the singleton
> > instance? If not, then how do I retrieve the singleton instance?
> >
> > I would like a session bean to start a transaction, and then call a method
> on another
> > session bean (which should operate under the same transaction). How does
> the second
> > session bean grab the correct transaction object? Is that possible?
> >
> > Thanks In Advance,
> > Sarita
> >
> > "Priscilla Fung" <[email protected]> wrote:
> > >
> > >Hi Marek,
> > >
> > >In Weblogic 6.0, JNDI lookup of UserTransaction returns a reference to
> the
> > >singleton
> > >Transaction Manager instance, which is thread-safe and can be used from
> > >multiple
> > >threads for transaction demarcations etc.
> > >
> > >-- Priscilla Fung, BEA Systems, Inc.
> > >
> > >"Marek Prochazka" <[email protected]> wrote:
> > >>
> > >>Hi all,
> > >>
> > >>in Weblogic, in a typical scenario, do a client provide exactly
> > >>one JNDI lookup for the UserTransaction object (interface) or do
> > >>the client have to provide a JNDI lookup for each transaction?
> > >>
> > >>In some EJB implementations, a JNDI lookup for UserTransaction
> > >>returns always the same reference. For example, in JOnAS, you can
> > >>have one static reference which is set when the client starts.
> > >>Then, more threads can simultaneously use the same static
> > >>UserTransaction reference without any conflict, since the
> > >>implementation of UserTransaction recognizes, which thread invoked
> > >>a particular method.
> > >>
> > >>In other words, can I make an assumption that two different JNDI
> > >>lookups for UserTransaction returns different references or not?
> > >>
> > >>Thanks a lot,
> > >>Marek Prochazka
> > >>--------------------------------------------------------------
> > >> Distributed Systems Research Group
> > >> Department of Software Engineering
> > >> Charles University, Faculty of Mathematics and Physics
> > >> Malostranske namesti 25, 118 00 Prague 1, Czech Republic
> > >> phone: +420-2-2191 4236
> > >> http://nenya.ms.mff.cuni.cz/thegroup/
> > >>--------------------------------------------------------------
> > >>
> > >
> >
-
Work around for request scope for Listitems-working
Hi finally I got some work around solution for Listitems working with request scope, if any suggesion welcome, below is the small code of jsp and bean.
<h:selectOneMenu id="ownerListMenu" value="#{pc_trackingSearchPage.trackingSearchPageBean.selectedOwner}">
<f:selectItems value="#{pc_trackingSearchPage.trackingSearchPageBean.ownerList}" />
</h:selectOneMenu>
I used onPageLoadBegin() and onPagePost(),
first on PageLoad - I am loading the List from DB, its displaying perfect.,
than on pagePost -> I am setting the value ->ownerList.add(new SelectItem(getOwnerListMenu().getSubmittedValue().toString(),getOwnerListMenu().getSubmittedValue().toString()));
------->here is the getOwnerListMenu method.
public HtmlSelectOneMenu getOwnerListMenu() {
if (ownerListMenu == null) {
ownerListMenu =
(HtmlSelectOneMenu) findComponentInRoot("ownerListMenu");
return ownerListMenu;
so this way the List will not be empty what ever the user selectes it will be their, as i am setting key and values as same, so in submit method,
i am getting the selected keys and going back to backend getting results displaying on other page,
--->this will work only if they don't need the list , if they want to display the list again, they have to load freshelly.
I hope it will give some solution for request scope, if the data is huge and not to save on the session for navigation purpose.
suggestions welcome.
Thanks
srikanth
Message was edited by:
srikanthgApperently iTunes 11 is not affected (Apple stil makes iTunes11 for the 14 yr old Microsoft XP OS, but not for anything PPCs can run. Go figure)
"Next door" to Steve was metaphoric, he lived in Los Altos, about 15 miles away, but he cast a big shadow!
On 9.2.1/10.4.11 differences, some time in the past someone selected 'save file' and checked the box 'don't ask again' on your computers dialog box. That's why you're not given a choice wih the file downloads. I would think that selection should be able to be reversed.
iTunes 9.2.1/OS10.4.11 puts those downloaded URLs into the Music Libary of iTunes, no matter if it's opened directly, or you click on the file on your desktop. You can create a new playlist, highlight the selection in the Music Libary, and drag it to your new playlist to keep alll the steaming URLs together. NOTE, this only creates an alias, the URL copied by iTunes must remain in the Music Libary. You can then delete the the files on the desktop, if you want. I did multiple stations this way in 9.2.1, they all show in either the new playlist created, or in the Music Libary, and remain after the desktop files are deleted and trash emptied.
You can switch sations by double clicking them. Another note, all the URLs were all from vtune.
I hope this helps.
PS, I forgot how clunky Tiger is compared to Leopard... -
Problem in Jndi lookup for ITaskService
HI,
I am trying to initiate oracle bpm Human task programatically by using Java remotely.
for this I am using following JNDI lookup for ITaskService.
Hashtable ht = new
Hashtable<IWorkflowServiceClientConstants.CONNECTION_PROPERTY,java.lang.String>();
ht.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_PROVIDER_URL, "t3://localhost:7001");
ht.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_SECURITY_PRINCIPAL, "username");
ht.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_SECURITY_CREDENTIALS, "password");
Context ctx = new InitialContext(ht);
ITaskService taskService = (ITaskQueryService)ctx.lookup("ejb/bpel/services/workflow/TaskServiceBean");
taskService.initiateTask(task);
It the right approach or not.
Please help.To access human workflow api remotely try using the following code :
Map properties = new HashMap();
properties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_PROVIDER_URL, "t3://localhost:8001");
properties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_SECURITY_CREDENTIALS, "welcome1");
properties.put(IWorkflowServiceClientConstants.CONNECTION_PROPERTY.EJB_SECURITY_PRINCIPAL, "weblogic");
IWorkflowServiceClient wfSvcClient =
WorkflowServiceClientFactory.getWorkflowServiceClient(WorkflowServiceClientFactory.REMOTE_CLIENT, properties, null);
//Get the task query service
ITaskQueryService querySvc = wfSvcClient.getTaskQueryService();
//Login as weblogic
IWorkflowContext ctx = querySvc.authenticate("weblogic","welcome1".toCharArray(),null);
after getting the workflow context, you can call any method like query task list. perform actions etc. just see the api doc.
Regards,
Anshul -
JNDI lookup for weblogic.management.MBeanHome
Tried to do JNDI lookup for MBeanHome. It could resolve
weblogic.management, but not MBeanHome.
Any idea? Thank you
T. Pei
PS
The statement and the error message:
MBeanHome mBeanHome = (MBeanHome) initialContext.lookup
("weblogic.management.MBeanHome.JNDI_NAME.MyServer");
javax.naming.NameNotFoundException:
Unable to resolve weblogic.management.MBeanHome.JNDI_NAME.MyServer
Resolved: 'weblogic.management'
Unresolved:'MBeanHome' ; remaining name 'JNDI_NAME.MyServer'I answered this in my last post, but to clarify your attempt below.
you can access MBeanHome through JNDI in any of three ways that I
currently know...
MBeanHome mBeanHome =
(MBeanHome)ctx.lookup("weblogic.management.adminhome");
MBeanHome mBeanHome =
(MBeanHome)ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);
MBeanHome mBeanHome =
(MBeanHome)ctx.lookup(MBeanHome.JNDI_NAME+"."+yourservername);
typically yourservername = "myserver"
when I print MBeanHome.ADMIN_JNDI_NAME I get
"weblogic.management.adminhome"
when I print MBeanHome.JNDI_NAME I get
"weblogic.management.home"
so using MBeanHome.JNDI_NAME+"."+yourservername is the same as
"weblogic.management.home.myserver", if the server you are trying to access
is called myserver.
may be more information than you want.
"T. Pei" <[email protected]> wrote in message
news:3a7a1562$[email protected]..
>
Tried to do JNDI lookup for MBeanHome. It could resolve
weblogic.management, but not MBeanHome.
Any idea? Thank you
T. Pei
PS
The statement and the error message:
MBeanHome mBeanHome = (MBeanHome) initialContext.lookup
("weblogic.management.MBeanHome.JNDI_NAME.MyServer");
javax.naming.NameNotFoundException:
Unable to resolve weblogic.management.MBeanHome.JNDI_NAME.MyServer
Resolved: 'weblogic.management'
Unresolved:'MBeanHome' ; remaining name 'JNDI_NAME.MyServer' -
JNDI lookup for Crystal Reports at runtime
How to run a rpt to fetch data from database connection defined in Tomcat's JNDI resources ? We are using JDBC(JNDI) Data source while designing the report in the Crystal Report designer and we want to use 'Connection Name' at runtime for jndi lookup to Tomcats JNDI resources.
Hi,
Thanks, this helped in resolving the JNDI lookup problem. But we are not having an issue in connecting to DS as it fails with error "Unsupported JNDI Object".
Tried suggestions on this link: "http://www.theserverside.com/discussions/thread.tss?thread_id=37430", but no luck.
Here are the configuration files:
context.xml:
<Context>
<Resource name="jdbc/remedy" auth="Container" type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver" url="jdbc:oracle:thin:@10.76.85.68:1521:dtv" maxActive="20" maxIdle="10" maxWait="-1" />
</Context>
web.xml:
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/remedy</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Log:
2009-10-30 06:38:05,804 DEBUG [com.crystaldecisions.reports.formatter.a.c] - Export Supervisor: number of destination exporters:1
2009-10-30 06:38:05,804 DEBUG [com.crystaldecisions.reports.formatter.a.c] - Export Supervisor: number of format exporters:4
2009-10-30 06:38:05,865 INFO [com.businessobjects.reports.sdk.JRCCommunicationAdapter] - JRCAgent1 received request: fetchReportPageRequest
2009-10-30 06:38:05,865 INFO [com.businessobjects.reports.sdk.JRCCommunicationAdapter] - JRCAgent1 attempting to acquire license
2009-10-30 06:38:05,865 INFO [com.businessobjects.reports.sdk.JRCCommunicationAdapter] - JRCAgent1 successfully acquired license
2009-10-30 06:38:05,867 DEBUG [com.businessobjects.reports.sdk.JRCCommunicationAdapter] - Requesting page 1
2009-10-30 06:38:05,879 INFO [com.crystaldecisions.reports.queryengine.driverImpl] - Logon: Connecting to database using local JNDI server ...
2009-10-30 06:38:05,888 DEBUG [com.crystaldecisions.reports.reportdefinition.datainterface] - Failed to open connection (Connection: databaseType=JDBC (JNDI) serverName=jdbc:oracle:thin:@10.76.85.68:1521:dtv state=closed databaseDriverName=crdb_jdbc.dll).
com.crystaldecisions.reports.queryengine.al: Unsupported JNDI Object (remedy)
at com.crystaldecisions.reports.queryengine.driverImpl.o.if(Unknown Source)
at com.crystaldecisions.reports.queryengine.av.new(Unknown Source)
at com.crystaldecisions.reports.queryengine.av.byte(Unknown Source)
at com.crystaldecisions.reports.reportdefinition.datainterface.b.a(Unknown Source)
at com.crystaldecisions.reports.reportdefinition.datainterface.b.a(Unknown Source)
at com.crystaldecisions.reports.reportdefinition.datainterface.b.a(Unknown Source)
at com.crystaldecisions.reports.reportdefinition.datainterface.b.if(Unknown Source)
at com.crystaldecisions.reports.reportdefinition.datainterface.j.a(Unknown Source)
at com.businessobjects.reports.sdk.b.i.if(Unknown Source)
at com.businessobjects.reports.sdk.b.i.a(Unknown Source)
at com.businessobjects.reports.sdk.b.i.byte(Unknown Source)
at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(Unknown Source)
at com.crystaldecisions.proxy.remoteagent.y.a(Unknown Source)
at com.crystaldecisions.proxy.remoteagent.r.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.cf.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.ReportSource.getPage(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.AdvancedReportSource.getPage(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.NonDCPAdvancedReportSource.getPage(Unknown Source)
at com.crystaldecisions.report.web.event.ac.a(Unknown Source)
at com.crystaldecisions.report.web.event.ac.a(Unknown Source)
at com.crystaldecisions.report.web.event.b2.a(Unknown Source)
at com.crystaldecisions.report.web.event.b7.broadcast(Unknown Source)
at com.crystaldecisions.report.web.event.av.a(Unknown Source)
at com.crystaldecisions.report.web.WorkflowController.do(Unknown Source)
Edited by: MuralidharS on Oct 30, 2009 8:46 AM -
JAVA client JNDI lookup for EJB session in cluster in WLS 5.1
The documentation says :
to obtain a Context for JNDI lookup do the following :
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL, "t3://mycluster:7001");
try {
Context ctx = new InitialContext(ht);
// Do the client's work
catch (NamingException ne) {
// A failure occurred
finally {
try {ctx.close();}
catch (Exception e) {
// a failure occurred
where "mycluster" is the DNS name of my cluster. My DNS server (Windows 200
DNS server) use round robin
to call alernatively all the wls server node in "mycluster" and it's OK. The
two servers of my cluster
are called alternatively for my EJB session stateless.
Now I unplug one of the two nodes of my cluster and the remaining server is
called only 2 times
and not after.
Questions :
-is the load balancing between the nodes of mycluster only rely on DNS or
is there an internal
mecanism in EJB sub to try one server then an other ?
- do I need to obtain a new reference on JNDI Context for each call ?
Thank's a lot.
Farid Bellameche.
I too have the same problem. My scenario is :
I have the web tier architecture away from cluster. All ejbs are in cluster
running in two seperate machines. We have a factory class running in
webtier(we use servlet in this tier) which obtains home interface only once
and stores it for future reference. When ever we need the remoteobject stub,
we ask the factory class and which in turn uses the stored home interface to
get the same.
In the webtier, I list all the servers in the cluster as a part of url as
mentioned by you.
I started the web tier as well as Object tier cluster. I could see the
request coming in both the machines in the cluster for the ejb. But When I
bring one the server in the cluster,
1. Web tier throws an exception saying that it could not connect
to server using t3.
2. The other machine which is running the server, also says
'failed to create socket to : -32323234324 sever name
using protocol t3.
It looks like I am able to get load balance. But I am not able to get the
fail over to be working.
In the weblogic-ejb-jar.xml, I added the following.
<clustering-descriptor>
<home-is-clusterable>true</home-is-clusterable>
<home-load-algorithm>round-robin</home-load-algorithm>
</clustering-descriptor>
I compiled and added the .jar file. So the jar file now has replica aware
stubs.
Could any one of you help me for why the fail over is not working?
Suersh
"Giri Alwar" <[email protected]> wrote in message
news:[email protected]...
> Farid,
> (1) Yes, the stub has the logic to perform load-balancing and
fail-over.
> (2) In almost all cases, no. You can get the context once, store it
and
> use it thereafter. Please refer to
> http://www.weblogic.com/docs51/cluster/concepts.html#1025061 for more
info.
>
> A couple of notes on your situation. From what you are describing, your
> Windows DNS server is setup to serve only one IP from the cluster (using
> round-robin) as opposed to a list of all IP's in the cluster. Hence, the
> initial context you obtain is tied to a single server in the cluster (the
> one returned by the DNS). The weblogic implementation on the client side
has
> no idea of the existence of the other servers in the cluster. This is not
a
> cluster aware context. To obtain a cluster aware context, either list all
> the IP's in the URL like t3://server1,server2,server3:7001 or have
> "mycluster" return a list of all servers in the cluster.
>
> Giri
>
>
> "Farid Bellameche" <[email protected]> wrote in message
> news:[email protected]...
> > The documentation says :
> >
> > to obtain a Context for JNDI lookup do the following :
> > Hashtable ht = new Hashtable();
> > ht.put(Context.INITIAL_CONTEXT_FACTORY,
> > "weblogic.jndi.WLInitialContextFactory");
> > ht.put(Context.PROVIDER_URL, "t3://mycluster:7001");
> > try {
> > Context ctx = new InitialContext(ht);
> > // Do the client's work
> > }
> > catch (NamingException ne) {
> > // A failure occurred
> > }
> > finally {
> > try {ctx.close();}
> > catch (Exception e) {
> > // a failure occurred
> > }
> > }
> >
> > where "mycluster" is the DNS name of my cluster. My DNS server (Windows
> 200
> > DNS server) use round robin
> > to call alernatively all the wls server node in "mycluster" and it's OK.
> The
> > two servers of my cluster
> > are called alternatively for my EJB session stateless.
> > Now I unplug one of the two nodes of my cluster and the remaining server
> is
> > called only 2 times
> > and not after.
> >
> > Questions :
> > -is the load balancing between the nodes of mycluster only rely on DNS
> or
> > is there an internal
> > mecanism in EJB sub to try one server then an other ?
> >
> > - do I need to obtain a new reference on JNDI Context for each call ?
> >
> >
> > Thank's a lot.
> >
> > Farid Bellameche.
> >
> >
> >
> >
>
>
-
Problems with JNDI lookup for java:comp/env/ejb
Hi all,
I'm using OC4J 9.0.3 and I have problems when looking up for the local
EJB context.
I have a SLSB which refers to another SLSB via a JNDI mapping like
shown below. Both services are deployed within one EAR file.
(snippets of ejb-jar.xml and orion-ejb-jar.xml)
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>ServiceABean</ejb-name>
<home>com.coi.ServiceAHome</home>
<remote>com.coi.ServiceA</remote>
<ejb-class>com.coi.ServiceABean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<ejb-ref>
<ejb-ref-name>ejb/some/sub/packages/ServiceB</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>com.coi.ServiceBHome</home>
<remote>com.coi.ServiceB</remote>
</ejb-ref>
</session>
</enterprise-beans>
</ejb-jar>
<orion-ejb-jar>
<enterprise-beans>
<session-deployment location="global/some/sub/packages/ServiceA" name="ServiceABean">
<ejb-ref-mapping name="ejb/some/sub/packages/ServiceB" location="global/some/sub/packages/ServiceB" />
</session-deployment>
</enterprise-beans>
</orion-ejb-jar>
The ApplicationInitialContextFactory will be used (prepared by the container),
so the lookup for ServiceB within a method of ServiceA should work as follows:
public class ServiceABean implements SessionBean
public void someMethod()
InitialContext con = new InitialContext(); // will be of class ApplicationContext
Context localEjbContext = (Context)con.lookup( "java:comp/env/ejb" );
ServiceBHome serviceBHome = (ServiceBHome) PortableRemoteObject.narrow(
localEjbContext.lookup( "some/sub/packages/ServiceB" ),
ServiceBHome.class );
The problem is now, that the lookup for "java:comp/env/ejb" doesn't work
and throws a NameNotFoundException.
To figure out what's actually happening during lookup I debugged a little bit and
tried a few things:
1. A lookup for "java:comp" works fine. It returns an instance of class FlatMapContext
which consists of a hash map which itself contains an entry for "env".
2. So a lookup for "env" on that FlatMapContext also works and returns an instance of SubContext.
3. A lookup for "ejb" using this SubContext causes a NameNotFoundException
with message "java:comp/env/ejb not found".
4. A lookup like con.lookup( "java:comp/env" ) throws also a NameNotFoundException
with message "java:comp/env not found (not inside a J2EE module, for instance a Web-App,
EJB, or Application-Client)".
Does anyone know something about this?
Regards
--thomasHi Debu,
Great! 9.0.4 will be released in june/july this year, right? Sorry for my ironical reaction, but does that mean, that I don't have any chance to get my whole stuff running in 9.0.3? I cannot believe that. Isn't there a wordaround I could apply? A setting or whatever to substitute the daft FlatCtx by something else that is implemented according to the spec?
Regards
--thomas -
JNDI Lookup for EJB3 (Bean to Bean)
Hi Forum,
i've search the whole internet and two books but I could not find an answer that pleased me.
I want to get a reference to an EJB3 by JNDI Lookup. With container managed dependency injection everything works fine but I have to do a little more generic way, thats why I want to work with JNDI Lookup.
I have the following situation:
At first I have a stateless bean
@Local
public interface Job {
* run the job
* @return true if the job executed without errors
public boolean run(SchedulerConfig schedulerConfig ,JobContext context);
@Local
public interface AConcreteJobLocal extends Job {
//no more declarations
@Stateless
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public class AConcreteJobBean implements AConcreteJobLocal {
//implemented methods goes here | removed for better overview in the post
} This is a typical declaration for a bunch of jobs I have. Every concrete job has it's own bean if it necessary in some way for you to know.
So now I wanted to write a bean which returns me an bean instance via a JNDI lookup
@Stateless
public class JobJNDILookupBean implements JobJNDILookupLocal {
Logger logger = Logger.getLogger(JobJNDILookupBean.class.getName());
public Job getJobBeanFromJNDIName(String jndiName) {
Job job = null;
try {
Context c = new InitialContext();
job = (Job) c.lookup("jndiName");
} catch (NamingException ex) {
Logger.getLogger(JobJNDILookupBean.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalArgumentException ex) {
logger.log(Level.SEVERE, "Bean not found", ex);
return job;
}When I call this method I always get a NameNotFoundException
javax.naming.NameNotFoundException: JNDI_NAME_GOES_HERE not found
at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:216)
at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:188)
at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:74)
at com.sun.enterprise.naming.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:111)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:398)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at com.vw.ais.dcl.timer.engine.JobJNDILookup.getJobBeanFromJNDIName(JobJNDILookup.java:46)
at com.vw.ais.dcl.timer.engine.EngineBean.init(EngineBean.java:221)
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.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)
at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3986)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:197)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:83)
at $Proxy713.init(Unknown Source)
at com.vw.ais.dcl.timer.SchedulerBean.runEngine(SchedulerBean.java:192)
at com.vw.ais.dcl.timer.SchedulerBean.handleIncomingByTimer(SchedulerBean.java:171)
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.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)
at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895)
at com.sun.ejb.containers.BaseContainer.callEJBTimeout(BaseContainer.java:2824)
at com.sun.ejb.containers.EJBTimerService.deliverTimeout(EJBTimerService.java:1401)
at com.sun.ejb.containers.EJBTimerService.access$100(EJBTimerService.java:99)
at com.sun.ejb.containers.EJBTimerService$TaskExpiredWork.run(EJBTimerService.java:1952)
at com.sun.ejb.containers.EJBTimerService$TaskExpiredWork.service(EJBTimerService.java:1948)
at com.sun.ejb.containers.util.WorkAdapter.doWork(WorkAdapter.java:75)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)I've tried I guess all combinations for the JNDI_NAME
java:/comp/env/ejb/AConcreteJob
java:/comp/env/ejb/AConcreteJobLocal
java:/comp/env/ejb/AConcreteJobBean
java:/comp/env/AConcreteJob
java:/comp/env/full.package.and.Class.name
this all without java:/comp/env
etc.
The only way it worked was when I added a annotation to the JobJNDILookupBean in this way
@Stateless
*@EJB(name="ejb/AConcreteJob",beanInterface=A.Interface.location)*
public class JobJNDILookupBean implements JobJNDILookupLocal {
}But this is not what I want to do. Thats why my question. How can I lookup a bean without annotate it in the bean which want to look it up???
In other words whats wrong here
@Stateless
public class JobJNDILookupBean implements JobJNDILookupLocal {
Logger logger = Logger.getLogger(JobJNDILookupBean.class.getName());
public Job getJobBeanFromJNDIName(String someJndiName) {
Job job = null;
try {
Context c = new InitialContext();
job = (Job) c.lookup("someJndiName");
} catch (NamingException ex) {
Logger.getLogger(JobJNDILookupBean.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalArgumentException ex) {
logger.log(Level.SEVERE, "Bean not found", ex);
return job;
}I hope you understand my question and more than this I hope some has the answer.Hi Zsom,
Zsom wrote:
One thing you need to keep in mind is that beans aren't instantiated every time you make a call to your EJB. You're right! But because the fact the beans are all stateless it doesn't matter. I don't want to get a new EJB at a lookup. If I get a reference to a bean which was used a million times before it is absolutely ok
Zsom wrote:
You might be gaining some time because the container can create new beans more quickly, but you are also looking up the beans before each call, which in the long run will be even more expensive.Mhm, I don't know if I understand you. Maybe I explain my process a little bit. I have a lot of different jobs in my application (JobDoThis, JobDoThat, JobFoo, JobBar). Every job has a own bean which keeps the business logic. Furthermore I have an job engine which is able to execute jobs which are configured to run and this engine can solve some dependencies (If JobFoo fails don't execute JobBar , and so on). When I build my engine I want to get a reference to a jobBean by jndi lookup which keeps the business logic and then call some method on it. This means that the lookup will only be called when I build a new engine. And because this doesn't happen so often performance is not so important. Furthermore if all jobs all configured to run the application needs sometimes more than 12 hours (depended from the amount of data) for one run (Start to End -> the application has a little script character), that's why performance as I said already is not so important.
Zsom wrote:
But it would be worth making some test, because to me it seems a bit like bad design.Yes it could be, but this was my first thought to instantiate a bean (or get a reference to an existing one) dynamically. I don't like this hard coded dependency injection. I mean it's great If you know at compiletime which beans you need. But because we don't know which beans we need it's a big overhead to inject them all by container and then use only 40 percent of the injected bean because for example only 40 of 100 jobs shall run.
If there is another approach to get a reference dynamically which is better than this then I will try, no problem, but unfortunally I don't see another. -
JNDI Lookup for JMS Topic issue.......!
Hi,
Our application is deployed on two nodes (MS1 and MS2 in a cluster) and I created JMSServer on MS1, JMS ConnectionFactory and Distributed Topic are targeted on both MS1 and MS2 i.e on entire cluster.
We have the JMS Code in postStart() method of starup class which extends ApplicationLifecycleListener which would create the JMS Subcriber and set the message listener on to it.
code snippet:
System.out.println("createSubscriber called");
subSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
// Lookup for the Topic
Topic cadTopic = (Topic) ctx.lookup("JMSTopicLog4j");
System.out.println("Topic is: " + cadTopic.getTopicName());
// Create JMS Subscriber.
cadSubscriber = subSession.createSubscriber(cadTopic);
// Set the listener to Subscriber.
cadSubscriber.setMessageListener(new CADMessageListener());
topicConnection.start();
When I start the cluster (managed Servers MS1 and MS2) for the first time and deploy the application on them (entire cluster) it works well i.e. message listener is active and able to receive messages published by publisher but when I try to stop and start MS2 it gives the following exception during server startup
javax.naming.NameNotFoundException: Unable to resolve 'JMSTopicLog4j'. Resolved ''
javax.naming.NameNotFoundException: Unable to resolve 'JMSTopicLog4j'. Resolved ''; remaining name 'JMSTopicLog4j'
at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1123)
at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:250)
at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:171)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:204)
at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:267)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:362)
Note: I thought my application context is getting started before JNDI tree is loaded but I could see that it is able to lookup the ConnectionFactory and throws the given exception when it comes to lookup code of JMS Topic.
is there any configuration issue or am I missing something? Please help me in this regard.
Thanks in advance.
Kris.Very interesting, I mean in the sense that we have the same setup, but instead of topic we are using the queues.
And our problem is exactly the same,deployment works but after restart same javax.naming.NameNotFoundException happens on server 2. -
Manual JNDI lookup for EJB3 between different Application Server Instances
Hi all,
i have spent quite some time looking into this problem and searching the net but i just can't figure out for the life of me what i am doing wrong so i hope someone here can give me a clue or a good resource where i can look it up myself.
I am currently doing some interoperability tests concerning EJB calls between Glassfish and Weblogic 10. In my test setup i have an EJB deployed in a jar file on one server and a servlet in a war file deployed on the other. The objective is to try to look up and call the EJB from the servlet. As there seem to be some issues with injection in Weblogic 10 i set that one aside for now (i have opened a case at BEA support for this) but i would like to do a plain old JNDI lookup to obtain the EJB.
The online tutorials and FAQs i have read so far all state that this can be done the same way as it works for EJB2.x, at least if i understood them correctly. The interessting thing is, when i deploy an EJB2.x bean i can look it up without problems, but when i try to do the same with the EJB3 bean the name cannot be found. On the other hand when listing all contents of the JNDI tree in Glassfish from a stand alone application i can see entries for both EJBs of the type java.naming.Reference (in Weblogic i can also see entries for both, but the ones for EJB3 are of some weird internal weblogic types, which i put down as a weblogic problem for now).
The lookup code for the servlet running in weblogic looks like this:
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL, "corbaname:iiop:1.2@localhost:3700");
Object myEjb = new InitialContext(env).lookup("JNDINameDisplayedByContextListing");
I know that the preferred way would be to have the corbaname put into weblogic.xml/sun-web.xml and just use an InitialContext without an environment to perform the lookup but i wanted to get rid of any additional indirections to pinpoint the source my problem and it should work this way, too. As i said, it works when i target an EJB2.x bean but not with the EJB3 one, so i guess i am doing something wrong there. The jar file contains the interface of the bean annotated with @Remote and the implementation of the interface annotated with @Stateless, i also tried setting the mappedName attribute for the bean and use that name as JNDI name, but that also fails. In addition i added an ejb-jar.xml to the jars META-INF containing the following:
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
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/ejb-jar_3_0.xsd"
version="3.0">
<enterprise-beans>
<session>
<ejb-name>SecurityTest3EJB</ejb-name>
<ejb-class>
testcase.ejb.SecurityTestBean
</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
But the ejb-name specified there does not show up in a context listing, so i would guess that means the file is ignored or only accessible from within the same application server (note, there is no indication of any problems in the Glassfish log when deploying the jar file).
This might be just a stupid mistake by me, but i just can't figure it out at the moment, so any advice will be greatly appriciated.
Thanks, ChrisI think i stumbled across something now. From some posts it seems to me that the EJB3 spec does not require EJBs to be accessible from a remote location, since this can be achieved by using the @RemoteHome annotation and performing a EJB2.x compliant look up. Is that correct?
-
Doing a jndi lookup() for an EJB deployed on Glassfish v3
Hello.
I have deployed a Stateful Sesion EJB on a Glassfish v3 AppServer.
It is running under 'localhost' on my laptop pc.
I am also running a stand-alone java application on the same pc... it attempts to get a remote connection from the client-app to the Glassfish Server and then do a jndi lookup() to get a reference to my EJB.
here is the client source code:
public class LookupTest {
static Properties props = null;
public static void main(String[] args) {
try {
props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
props.put(Context.PROVIDER_URL, "iiop://localhost:3700");
Context ctx = new InitialContext(props);
System.out.println( "the context is: " + ctx);
System.out.println( "the environment contains: " + ctx.getEnvironment() );
System.out.println( " ");
// do a lookup.
Object elementObj = ctx.lookup("SerialContextProvider");
System.out.println(elementObj);
} catch (NamingException e) {
e.printStackTrace();
When I run this app, there are no Errors or Exceptions. It appears that the connection succeeds. But there are no EJB references in the context that is created. The only item that seems to be present in the context is an item named "SerialContextProvider", as noted in the return value from a list("") method invocation. Why can i not see the EJB within the context? Is my code wrong ??
Thanks,
Andy Jerpe
Edited by: user1169567 on Nov 28, 2010 12:12 PMOk, but the communication seems to be OK over the wire because if I use netstat -a I can see the ESTABLISHED connection with the server in the right RMI port.
TCP PORTAL35:1581 caapiranga:12405 ESTABLISHED
and then when I stop the instance in the OAS, the client shows an exception telling that the connection was lost.
An curious thing is that the ons.log doesn't log this connection ;/ -
How to write the jndi lookup for ejb using oc4j server in jdeveloper
Hi All,
i am new to the JDeveloper. i want to develop the session bean in JDeveloper using the OC4J server. how to write the jndi lookup in cllient. what are the xml files need to deploy the application. where can i mention the JNDI name in xml file. so please provide the information as soon as possible.
regards
ramThere is quite in-depth information in the Enterprise JavaBeans Developer's Guide.
Section 2 (Understanding EJB Application Development) explains the xml files needed and Section 29 (Accessing an EJB from a Client) explains how to do a JNDI lookup.
Hope this helps. -
JNDI lookup() for a Resource Adapter fails
Hi guys,
I've deployed a Resource Adapter on Weblogic (v10.3.4). It's JNDI name is: jca/HelloAdapter
Moreover, in the Outbound Connection Pools tag, I've created a javax.resource.cci.ConnectionFactory entry with JNDI name: eis/HelloAdapter.
I want to write a simple Java test to lookup my Resource adapter. The code I am using is the following:
Hashtable<String, String> properties = new Hashtable<String, String>();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, "t3://localhost:8001");
properties.put(Context.SECURITY_PRINCIPAL, "weblogic");
properties.put(Context.SECURITY_CREDENTIALS, "weblogic1");
Context ctx = null;
try {
ctx = new InitialContext(properties);
javax.resource.cci.ConnectionFactory cf =
(javax.resource.cci.ConnectionFactory) ctx.lookup("jca/HelloAdapter");
} catch (NamingException e) {
e.printStackTrace();
}I get the following exception:
javax.naming.NameNotFoundException: No Object found: jca/HelloAdapter|null
at weblogic.connector.deploy.JNDIHandler.lookupObject(JNDIHandler.java:881)
at weblogic.connector.deploy.JNDIHandler.getObjectInstance(JNDIHandler.java:843)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:424)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:411)
at javax.naming.InitialContext.lookup(InitialContext.java:392)Any ideas please ? Thank you for your time
Regards,
GeorgeSorry guys,
I suppose my thread subject is out of the scope of the specific list.
Sorry for the inconvenience -
JNDI Lookup for multiple server instances with multiple cluster nodes
Hi Experts,
I need help with retreiving log files for multiple server instances with multiple cluster nodes. The system is Netweaver 7.01.
There are 3 server instances all instances with 3 cluster nodes.
There are EJB session beans deployed on them to retreive the log information for each server node.
In the session bean there is a method:
public List getServers() {
List servers = new ArrayList();
ClassLoader saveLoader = Thread.currentThread().getContextClassLoader();
try {
Properties prop = new Properties();
prop.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");
prop.put(Context.SECURITY_AUTHENTICATION, "none");
Thread.currentThread().setContextClassLoader((com.sap.engine.services.adminadapter.interfaces.RemoteAdminInterface.class).getClassLoader());
InitialContext mInitialContext = new InitialContext(prop);
RemoteAdminInterface rai = (RemoteAdminInterface) mInitialContext.lookup("adminadapter");
ClusterAdministrator cadm = rai.getClusterAdministrator();
ConvenienceEngineAdministrator cea = rai.getConvenienceEngineAdministrator();
int nodeId[] = cea.getClusterNodeIds();
int dispatcherId = 0;
String dispatcherIP = null;
String p4Port = null;
for (int i = 0; i < nodeId.length; i++) {
if (cea.getClusterNodeType(nodeId[i]) != 1)
continue;
Properties dispatcherProp = cadm.getNodeInfo(nodeId[i]);
dispatcherIP = dispatcherProp.getProperty("Host", "localhost");
p4Port = cea.getServiceProperty(nodeId[i], "p4", "port");
String[] loc = new String[3];
loc[0] = dispatcherIP;
loc[1] = p4Port;
loc[2] = null;
servers.add(loc);
mInitialContext.close();
} catch (NamingException e) {
} catch (RemoteException e) {
} finally {
Thread.currentThread().setContextClassLoader(saveLoader);
return servers;
and the retreived server information used here in another class:
public void run() {
ReadLogsSession readLogsSession;
int total = servers.size();
for (Iterator iter = servers.iterator(); iter.hasNext();) {
if (keepAlive) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
status = status + e.getMessage();
System.err.println("LogReader Thread Exception" + e.toString());
e.printStackTrace();
String[] serverLocs = (String[]) iter.next();
searchFilter.setDetails("[" + serverLocs[1] + "]");
Properties prop = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");
prop.put(Context.PROVIDER_URL, serverLocs[0] + ":" + serverLocs[1]);
System.err.println("LogReader run [" + serverLocs[0] + ":" + serverLocs[1] + "]");
status = " Reading :[" + serverLocs[0] + ":" + serverLocs[1] + "] servers :[" + currentIndex + "/" + total + " ] ";
prop.put("force_remote", "true");
prop.put(Context.SECURITY_AUTHENTICATION, "none");
try {
Context ctx = new InitialContext(prop);
Object ob = ctx.lookup("com.xom.sia.ReadLogsSession");
ReadLogsSessionHome readLogsSessionHome = (ReadLogsSessionHome) PortableRemoteObject.narrow(ob, ReadLogsSessionHome.class);
status = status + "Found ReadLogsSessionHome ["+readLogsSessionHome+"]";
readLogsSession = readLogsSessionHome.create();
if(readLogsSession!=null){
status = status + " Created ["+readLogsSession+"]";
List l = readLogsSession.getAuditLogs(searchFilter);
serverLocs[2] = String.valueOf(l.size());
status = status + serverLocs[2];
allRecords.addAll(l);
}else{
status = status + " unable to create readLogsSession ";
ctx.close();
} catch (NamingException e) {
status = status + e.getMessage();
System.err.println(e.getMessage());
e.printStackTrace();
} catch (CreateException e) {
status = status + e.getMessage();
System.err.println(e.getMessage());
e.printStackTrace();
} catch (IOException e) {
status = status + e.getMessage();
System.err.println(e.getMessage());
e.printStackTrace();
} catch (Exception e) {
status = status + e.getMessage();
System.err.println(e.getMessage());
e.printStackTrace();
currentIndex++;
jobComplete = true;
The application is working for multiple server instances with a single cluster node but not working for multiple cusltered environment.
Anybody knows what should be changed to handle more cluster nodes?
Thanks,
GergelyThanks for the response.
I was afraid that it would be something like that although
was hoping for
something closer to the application pools we use with IIS to
isolate sites
and limit the impact one badly behaving one can have on
another.
mmr
"Ian Skinner" <[email protected]> wrote in message
news:fe5u5v$pue$[email protected]..
> Run CF with one instance. Look at your processes and see
how much memory
> the "JRun" process is using, multiply this by number of
other CF
> instances.
>
> You are most likely going to end up on implementing a
"handful" of
> instances versus "dozens" of instance on all but the
beefiest of servers.
>
> This can be affected by how much memory each instance
uses. An
> application that puts major amounts of data into
persistent scopes such as
> application and|or session will have a larger foot print
then a leaner
> application that does not put much data into memory
and|or leave it there
> for a very long time.
>
> I know the first time we made use of CF in it's
multi-home flavor, we went
> a bit overboard and created way too many. After nearly
bringing a
> moderate server to its knees, we consolidated until we
had three or four
> or so IIRC. A couple dedicated to to each of our largest
and most
> critical applications and a couple general instances
that ran many smaller
> applications each.
>
>
>
>
>
Maybe you are looking for
-
Just doing simple things, like the video bellow. http://dandalo.net/forum/photoshop-error/photoshop-error-720.mov I opened an image and tried to crop it. In the end of the video, the error happens I also ran an action, with canvas, smart sharpen and
-
Saving to SharePoint works only half the time for Windows 7 Users--all the time for Windows XP users
We have a SharePoint 2010 Environment with hardware load balancing, 2 WFEs, 2 Apps Servers and 1 SQL Server. This was built in October 2013. Office Integration and Saving back to SharePoint works all of the time for users on XP. It works sporadically
-
When i use Ical, ( dayly, week, month ) i can have lot of distinct colors for each days, few colors in the same day, When i use Ical ( year ) just one color appear each day, Can i change that to have the same wiev of day in each calendar ( ex: in the
-
Why does the page not move smothe when i scroll?
Why does the page not move smothe when i scroll? Sometimes it even move slower then i Scroll? I use a Mac and i have tried to reinstall the program.
-
Get Vraiant button inactive during pf-status activation for report program.
Hello Gurus, I have created a pf-status for a selection screen program. Now I have done the adjustment to that pf-status thorugh, Extras -> Adjust Template -> Selection Screen in se41. So now it shows all the buttons associated with Selection Screen