Michael Drona

Greenhorn
+ Follow
since Aug 08, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Michael Drona

Is there a way to make wlst's ls() return a list and then not print the results also?

I found ls(returnMap='true') but the problem is that it does like


I want to supress that first dr-- junk so that I can format the output like I want to see it from my script. I can do my own "for b in a: print" or whatever I want to do.
14 years ago
Here's an example I have that works

Hello.java


HelloBean.java



HelloClient.java


compress the whole org thing into a jar
jar cvf hello.jar org

deploy the jar on the wl server and then run the client.
So I am pretty new to the whole JMX thing but I am trying to do a simple little java app that can connect to my weblogic server and grab an attribute from the server instance. In this case I want the MessagesCurrentCount from the JMSServerRuntimeMBean. I can't find any code examples on how to get a particular mbean for a particular jms server and then query it for attributes. I have kind of pulled some code from a few examples for other things and tried to make it work... If anyone can explain how this works and maybe give me some working code to look at

The answer to this is in the first case you need to use the global JNDI name as exported in your container xml config (or mappedName in EJB3) and then Narrow the reference and cast it to the home interface. You can then call create() to get a reference to the bean itself. The java:comp syntax only works within the container itself.

The reason for the EJB1.1 error is that I was following an older tutorial that has the setSessionContext call the Context.getProperties() where this is not needed in EJB >= 2.0.
I am learning about session beans so I wrote a simple one. I built it and deployed it to weblogic (10.3). I can see the bean under the jndi tree of the server as testsess/TestSessHome but I don't seem to be able to call the bean.

A few questions:
Why is the TestSessHome in the jndi tree? Shouldn't the remote interface that actually exposes methods I would want to use be there? Or do I have to use the home.create() to get a handle to the remote and then use it?

My client is doing something simple in the main method
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
props.put(Context.PROVIDER_URL,"t3://127.0.0.1:7001");
Context ctx = new InitialContext(props);
TestSessHome tsHome = (TestSessHome) ctx.lookup("java:comp/env/testsess/TestSessHome");

but this fails with
Exception in thread "main" javax.naming.NameNotFoundException: While trying to lookup 'java:comp.env/testsess/TestSessHome' didn't find subcontext 'java:comp'. Resolved '' [Root exception is javax.naming.NameNotFoundException: While trying to lookup 'java:comp.env/testsess/TestSessHome' didn't find subcontext 'java:comp'. Resolved '']; remaining name 'java:comp/env/testsess/TestSessHome'

Why does it have java:comp.env instead of java:comp/env? And why can't it find the java:comp subcontext?

If I try the same thing but remove the java:comp/env part I get
Exception in thread "main" java.rmi.RemoteException: Error during setSessionContext; nested exception is:
java.lang.RuntimeException: [EJB:010183]javax.ejb.EJBContext.getEnvironment is deprecated in EJB 1.1. EJB 1.1 compliant containers are not required to implement this method. Use java:comp/env instead.

I guess this is some older deprecated way of calling the EJB?

My weblogic-ejb.xml just has some basic stuff
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>TestSessEJB</ejb-name>
<jndi-name>testsess.TestSessHome</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>