Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.

Riaan Nel

Ranch Hand
+ Follow
since Apr 23, 2009
Riaan likes ...
IntelliJ IDE Ubuntu VI Editor
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
22
Received in last 30 days
0
Total given
12
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Riaan Nel

How do you stop the server? If it shuts down cleanly (via a shutdown command) I would expect it to work, but if you just kill the process your callback method probably won't get called.

Jaikiran Pai wrote:Riaan, good job, you seem to have done a good amount of investigation into this already and that now narrows the issue down to figuring out what the right behaviour is. I am not an expert on resource adapters, so I don't have an answer to this, but I suggest you download the JCA 1.6 spec from here http://download.oracle.com/otndocs/jcp/connector_architecture-1.6-fr-eval-oth-JSpec/ and read through some of the relevant chapters in it. I think you'll find the answer to your question in there. If you don't, then feel free to post back here.



Thanks Jaikiran, that spec was useful. I read chapter 5 (Lifecycle Management), and it largely confirmed what I expected. It makes reference to the start(BootstrapContext ctx) method, although I couldn't find anything that explicitly dictates the order in which events should happen prior to starting the resource adapter. I went back to Wildfly's AbstractResourceAdapterDeploymentService, and after a bit of deep diving into the code, I found that it will start the resource adapter only after creating the managed connection factory (which fails, because the implementation that we had depended on the resource adapter being started already). It is invoked reflectively, so it was a bit tricky to find it - which is probably why I missed it the first time round.

The sequence of events seems to differ from JBoss 4.2.3, but I wouldn't call it a bug - like I said, the spec doesn't seem to explicitly state what should happen prior to the resource adapter being started. Eventually, I ended up having to decompile the managed connection factory and resource adapter implementations in the RAR that I had, move some code around, recompile the classes and stick them back into the archive. That seems to have done the trick, although it is a bit of a hack.

Cheers,
Riaan
3 years ago
Good Day Folks

I'm busy migrating an application from JBoss 4.2.3 to Wildfly 8.1, and I'm stuck on a resource adapter issue. The system that I'm working on talks to another system, via a provided resource adapter. I've configured my resource-adapter in my standalone-full.xml file, and I've taken the provided .rar archive (the same one that we used for JBoss 4.2.3) and put it in my deployments directory.

When my server starts up, I can see that Wildfly is trying to deploy the resource adapter, but halfway through, it depends blows up in the ManagedConnectionFactory implementation that is packaged in my .rar. Since the .rar has been provided to us, I don't actually have the original source code for it - I only have a decompiled view in my IDE that I can use to debug. Based on what I can see, Wildfly uses a class called org.jboss.as.connector.services.resourceadapters.deployment.AbstractResourceAdapterDeploymentService to deploy the resource adapter. In doing so, it instantiates the javax.resource.spi.ResourceAdapter implementation in the .rar, and then ends up calling createConnectionFactory(ConnectionManager paramConnectionManager) on our ManagedConnectionFactory implementation, via createObjectsAndInjectValue(URL url, String deploymentName, File root, ClassLoader cl, Connector cmd, IronJacamar ijmd, org.jboss.jca.common.api.metadata.resourceadapter.ResourceAdapter raxml) on AbstractResourceAdapterDeploymentService (all of this is done by Wildfly while trying to deploy). However, the implementation assumes that a javax.resource.spi.BootstrapContext would already have been set on the resource adapter when this method is invoked. The code sets the bootstrap context from the start(BootstrapContext ctx) method on the resource adapter implementation class.

Based on logging output, JBoss 4.2.3 creates the ResourceAdapter implementation instance, and immediately thereafter calls its start(BootstrapContext ctx) method. Wildfly, on the other hand, instantiates the ResourceAdapter, but it doesn't call the start(...) method - which means that the bootstrap context isn't initialized by the time that the createConnectionFactory(...) method tries to use it - and ultimately, it results in a NullPointerException.

I realise that his is quite an involved problem, and it probably won't be easy to come up with an answer, but I've been struggling for a couple of days already, so I was hoping that someone might have an answer. How can I get Wildfly to start the resource adapter immediately after creating it?

Thanks,
Riaan

(Apologies if my formatting looks bad - I tried to highlight the classes that relate to my issue)
3 years ago
I should also point out the the application is deployed as an EAR file. The EAR contains, among other things, the JAR with the session bean in it and a WAR containing the servlet. If I copy and paste both of these methods into a servlet and execute them from there, it works perfectly - I can only see the issue happening in a session bean.
Hi Folks

I haven't posted on JavaRanch in quite a while, but I'm struggling with an issue that has me stumped.

My team is in the process of migrating an application from WebLogic to JBoss 6. The bulk of the work is done, but JMS is still giving us some pains. We have code that looks up a TIBCO EMS connection factory via JNDI. The factory is set up as per the specifications in section 1 of this page. In some places, we try to access queues and in other places we try to access topics. Unfortunately, I cannot post the actual code, since it is sitting on my machine at the office. Nonetheless, I figured that I'd try my luck posting here.

We look up the TIBCO connection factory via JNDI, and cast it to the appropriate type (QueueConnectionFactory or TopicConnectionFactory). This lookup always succeeds, regardless of what we cast the resulting object to (my understanding is that the factory should implement both the QueueConnectionFactory and TopicConnectionFactory interfaces). We then create a QueueConnection/TopicConnection and the relevant type of session using the factory. Then, we send/publish a message to the relevant queue or topic. The code is very similar to the below (my apologies, but like I said, I don't have the actual code available right now).



The (very odd) issue that the method that is called first always seems to work (regardless of whether it uses a queue or a topic), whereas the second method always fails. If the order of the method is switched around, whichever one is called first still works, while the second one then fails. The cause of this, based on the JBoss logs, seems to be that JBoss gives us a factory for the first lookup and then keeps the type of the factory when the second lookup is done. So, even though the factory that we look up should provide both a queue connection factory and a topic connection factory, the session that is returns is only valid for whichever is created first. It throws an exception (just like the code, I don't have the full stack trace handy right now, but I think it's an InvalidDestinationException or an IllegalArgumentException) with either "topic session" or "queue session" as the message. The method calls are made from a session bean that is invoked from a servlet. The issue occurs when the session beans calls both methodA() and methodB() from the method called by the servlet (i.e. in the same container transaction). Please correct me if anything I'm saying comes across as nonsense.

Any thoughts on why this would happen? My JNDI knowledge isn't perfect, so I'm not sure if it is JNDI related. Are objects cached when you look them up via JNDI? I want to try and see if I can use the TIBCO specific context to look up the individual queue and topic connection factories directly. In the meantime, I was hoping that someone will be able to shed some light on the issue.

Cheers,
Riaan

Ulf Dittmer wrote:While I like Project Euler, I wouldn't recommend it as a way to learn Java - it's geared towards implementing mathematical or logical algorithms, not so much towards learning programming.


Project Euler, to me, is not a way to learn a programming language (so I agree with what you've said), but it does give you an environment to practice writing small programs in.
5 years ago

Anthony Allen wrote:I'm trying to learn Java programming and I'm watching Lynda.com Java Essential Training and I find myself following along with my Eclipse program open and just copying and typing out syntax with the instructor but a lot of the concepts are just brushed over so quickly that there is very little room for why, how, or what even. It's just "copy this here...now copy that here..now you want to put that in front of this..and now go do this here."

And you're just following along typing out what you're told mindlessly and it truly feels like you aren't really learning anything. What should I be doing to truly learn it?

My strategy right now is just push along and maybe I'll see something later on that makes it all click more. Maybe move on to the advanced Lynda video. Then maybe come back and watch it again while looking stuff up online until my knowledge increases on it.

I just want to get the most out of it and actually learn it. Thoughts?


Welcome to JavaRanch Anthony!

The best way to learn, in my opinion, is by doing. Come up with ideas for simple programs, then implement those ideas - if you get stuck, you can always ask for help here. You could also find some programming exercises online to work through (google Project Euler).

Cheers,
Riaan
5 years ago
Hi Folks

I'm a couple of days away from my OCPJP 6 exam. I've used Devaka's ExamLab for most of my recent preparation, and I'm currently getting around 60% average on the practice exams. I'm a bit concerned about concurrency and generics, but overall, I'm confident that I'll do well.

Any tips that you'd like to share? What are the trickiest questions that I can expect around concurrency, generics (and garbage collection)?

Cheers,
Riaan
Hi Guys

I've always used NetBeans to compile my code, but I'm preparing for the OCPJP certification, so I'm now using the command line. I've encountered a very strange issue.

I have two classes in two separate files (both of them have been compiled succesfully). They look as follows:


My directory structure is as follows:


When I run the Java command from the test directory without specifying a classpath (i.e. java Main), I get a NoClassDefFoundError because the HelloPrinter class cannot be found. This is what I expected to happen. However, when try to add the HelloPrinter class to the classpath by running java -cp classes Main, I get a NoClassDefFoundError stating that the Main class cannot be found. Does anyone have an idea why this is happening? Am I missing something obvious?

Many thanks.

Cheers,
Riaan

Edit: Here's the error.


java -cp classes Main
Exception in thread "main" java.lang.NoClassDefFoundError: Main
Caused by: java.lang.ClassNotFoundException: Main
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: Main. Program will exit.



Another edit: I've just found the issue. I just needed to include the current directory in the classpath as well. When I tried it earlier I was using the Unix path separator ( instead of the Windows separator (;), and it didn't work.
6 years ago

Nistor Alexandru wrote:If you must know I am trying to learn to program on my own I am 22 and barely finished Head first Java I am still barely understanding programming concepts but if asking for help is such a problem then so be it


You're welcome to ask for help, but there's a difference between asking for help and asking for a complete program (as you did at the end of your first post).

Before you write any code, take a pen and a piece of paper and determine what the program should do and how it should do it. Once you've figured that out you can start working on a Java program. If you get stuck with the program, show us what you've tried and we'll be glad to help.
6 years ago
Hi Guys

I wanted to try and illustrate the difference between the two types of beans for myself, so I created a couple of classes and remote interfaces as follows:


I then exposed the call() methods through a web service and invoked each of them four times. My output (in the Glassfish log) was as follows:


INFO: Stateless bean: 1
INFO: Stateful bean: 1
INFO: Stateless bean: 2
INFO: Stateful bean: 2
INFO: Stateless bean: 3
INFO: Stateful bean: 3
INFO: Stateless bean: 4
INFO: Stateful bean: 4



I was expecting the stateful bean's counter to be incremented with each call, but I didn't expect the stateless bean to do the same - I thought that it would essentially lose track of whatever state it was in (i.e. that it would be lost after being invoked, and that the next call would get a new instance). What am I missing?

Cheers,
Riaan

Winston Gutkowski wrote:
And BTW, if S&B says that you need to sort a List in order to search it (and I suspect they didn't), they're wrong.


Page 577 of the SCJP 6 study guide - "The collection/array being searched must be sorted before you can search it." This applies to specifically to binary searching, not searching in general.

6 years ago