Henrik Axelsson

Greenhorn
+ Follow
since Sep 15, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Henrik Axelsson

Hi Jose,

I'm pretty sure that you can only use DI if the apps are running in the same server. If you need to access the beans externally you will have to use other means.

Not sure what app server you are using but here is an FAQ on how to do it with glassfish https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#nonJavaEEwebcontainerRemoteEJB

I don't have much EJB experience but I am trying to achieve a similar thing and have encountered problems...

Good luck with it.

Henrik
Hi all,

I've been trying to access a simple bean that I set up in glassfish using an external client. I followed the instructions here: https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#StandaloneRemoteEJB

However when the client tries to connect I get the following error:




When I use TCP view, and look at all the open ports on my machine, 3700 doesn't seem to be there. But going by the article I linked this is supposed to be the default port used. I had a look through my glassfish directories and found domain.xml that contains the line:



so it appears that it should be opening the correct port.

I created an 'Enterprise Application Client' in Netbeans, and if I try to access the bean through that it works fine. I just can't get it to work from a stand alone client which is what I really need to do. I am running glassfish 2u2 and controlling it through Netbeans 6.5.

I am a pretty much a beginner when it comes to glassfish and EJB so I may be missing something simple.

Thanks
Ok solved the problem!

It ended up being this:
c3p0 was trying to find the configuration file using the system class loader, which doesn't have access to the /lib dir of the web app.

Because it wasn't reading the config file, when I was trying to get connections, there were no pool configurations set up. The reason I got confused it that I also parse the config file to get the pool names and actually create the pools. (c3p0 just creates the pool configs, not the actual pools).

So, if I added /project_dir/config to the class path of tomcat in the catalina.bat file it all works fine.

I'll have to check to make 100% sure but, to me this seems like an error in c3p0, it really should be using Class.class.getClassLoader().getResource(); instead of ClassLoader.getSystemResource(); I've seen that other people have had this problem with different libraries when trying to run them in web containers.

Hopefully this will save someone else wasting 2 days of their time hunting this down!
16 years ago
The value of the jdbcUrl comes from the c3p0-config.xml file. As this is the same file that we are using under windows (where it works fine) I don't think that this would be the issue. Just to make sure, I copy/pasted the connection strings from the config file into SquirrelSQL and it didn't have a problem with them.
16 years ago
thanks for the reply, yes it is open source, the source tree is bit of a mess though! I tried loading into netbeans but it wasn't too happy with it. I'll have to spend a bit more time on it.

Considering the same file is working fine under windows, I'm fairly certain that it is being caused by classpath/classloader issues.

I was having another problem loading the c3p0 configuration files, it was located in: project_dir/config and I was accessing it using .

This worked fine on windows, and after adding the directory to the tomcat classpath I could access it from the main servlet class using

but if i tried accessing it from another class, using

it wouldn't find the file.

In the end I move the config files into project_dir/deployment/WEB-INF/classes/config where it was found by both classes.

Now I'm not tomcat expert, but it seems to me like there are some security or classpath settings that I could be missing that is likely causing both issues. Who knows though, it could be the urls getting messed up. Argh so frustrating!
16 years ago
Hi all,

I am trying to solve a frustrating problem with a servlet running under tomcat 6. Running under Windows there was no problems, but now after trying to move it over to OS X there are odd problems occurring.

We are using c3p0 to do connection pooling, however c3p0 is having trouble creating the database connections, it gives the following error:

java.sql.SQLException: No suitable driver

After looking at the c3p0 code, it attempts to get a reference to the driver by calling:

But this is throwing the exception.

If I place the following code into my webapp (which is copied from the c3p0 xml file im using):

It works without a problem.

Does this mean that is is not finding the com.mysql.jdbc.Driver class or is it caused by something else? I have tried copying the mysql connector jar file into tomcat_home/lib but that didn't help either.

The only other thing I can think of is the jdbcUrl being used by c3p0 is getting mangled some how, but checking that is going to be bit of a pain.
16 years ago