tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpmad4it <jpill...@fortvale.com>
Subject Re: Tomcat and openEJB - how to do this simple config?
Date Thu, 05 Feb 2009 16:38:02 GMT

Can anyone help, I'm still struggling with this??



EDIT: I think I managed to call the Calculator web service through PHP. I
used the script soap.php:

<?php
$client = new SoapClient("http://ww3.mysite.com/Calculator?wsdl");
var_dump($client->__getTypes());
?>

When I access soap.php in the browser I get:

array(4) { [0]=> string(41) "struct multiply { int arg0; int arg1; }" [1]=>
string(40) "struct multiplyResponse { int return; }" [2]=> string(36)
"struct sum { int arg0; int arg1; }" [3]=> string(35) "struct sumResponse {
int return; }" } 

So I think that it has successfully called the service and grabbed the types
from it? I don't know how to code the PHP to actually do a simple addition
though.

Maybe I should start to think about getting a service setup for the MySQL
database?

EDIT2: I am now trying to setup the injection-of-datasource example, I've
changed the test java file so that its correct for my mysql database, but
during "mvn clean install" the process fails, saying it cannot find the jdbc
driver com.mysql.jdbc.Driver. The mysql-connector/J.jar is in my tomcat/lib
folder: 

lin003:/home/tomcat/webapps/injection-of-datasource # mvn clean install
[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
[INFO] Building OpenEJB :: Examples :: @Resource DataSource Injection
[INFO]    task-segment: [clean, install]
[INFO]
------------------------------------------------------------------------
[INFO] [clean:clean]
[INFO] Deleting directory
/home/tomcat/webapps/injection-of-datasource/target
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
Downloading:
http://people.apache.org/repo/m2-snapshot-repository//org/apache/activemq/activeio-core/3.0.0-incubator/activeio-core-3.0.0-incubator.pom
Downloading:
http://repo1.maven.org/maven2/org/apache/activemq/activeio-core/3.0.0-incubator/activeio-core-3.0.0-incubator.pom
[INFO] [compiler:compile]
[INFO] Compiling 3 source files to
/home/tomcat/webapps/injection-of-datasource/target/classes
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] Compiling 1 source file to
/home/tomcat/webapps/injection-of-datasource/target/test-classes
[INFO] [surefire:test]
[INFO] Surefire report directory:
/home/tomcat/webapps/injection-of-datasource/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.superbiz.injection.MoviesTest
Apache OpenEJB 3.1    build: 20081009-03:31
http://openejb.apache.org/
INFO - openejb.home = /home/tomcat/webapps/injection-of-datasource
INFO - openejb.base = /home/tomcat/webapps/injection-of-datasource
INFO - Configuring Service(id=Default Security Service,
type=SecurityService, provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager,
type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Configuring Service(id=movieDatabase, type=Resource,
provider-id=Default JDBC Database)
INFO - Found EjbModule in classpath:
/home/tomcat/webapps/injection-of-datasource/target/classes
INFO - Beginning load:
/home/tomcat/webapps/injection-of-datasource/target/classes
INFO - Configuring enterprise application: classpath.ear
INFO - Configuring Service(id=Default Stateful Container, type=Container,
provider-id=Default Stateful Container)
INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL,
id=Default Stateful Container)
INFO - Auto-linking resource-ref
'org.superbiz.injection.MoviesImpl/movieDatabase' in bean Movies to
Resource(id=movieDatabase)
INFO - Enterprise application "classpath.ear" loaded.
INFO - Assembling app: classpath.ear
INFO - Jndi(name=MoviesLocal) --> Ejb(deployment-id=Movies)
INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default
Stateful Container)
INFO - Deployed Application(path=classpath.ear)
ERROR - The bean instance business method encountered a system exception:
Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class
'com.mysql.jdbc.Driver'
        at
org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1259)
        at
org.apache.commons.dbcp.managed.BasicManagedDataSource.createConnectionFactory(BasicManagedDataSource.java:99)
        at
org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1192)
        at
org.apache.openejb.resource.jdbc.BasicManagedDataSource.createDataSource(BasicManagedDataSource.java:75)
        at
org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:884)
        at org.superbiz.injection.MoviesImpl.construct(MoviesImpl.java:50)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
        at java.lang.reflect.Method.invoke(Method.java:599)
        at
org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:158)
        at
org.apache.openejb.core.interceptor.ReflectionInvocationContext$LifecycleInvocation.invoke(ReflectionInvocationContext.java:189)
        at
org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:141)
        at
org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:67)
        at
org.apache.openejb.core.stateful.StatefulContainer.newInstance(StatefulContainer.java:559)
        at
org.apache.openejb.core.stateful.StatefulContainer.createEJBObject(StatefulContainer.java:300)
        at
org.apache.openejb.core.stateful.StatefulContainer.invoke(StatefulContainer.java:263)
        at
org.apache.openejb.core.ivm.EjbHomeProxyHandler.create(EjbHomeProxyHandler.java:270)
        at
org.apache.openejb.core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:161)
        at
org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:286)
        at $Proxy3.create(Unknown Source)
        at
org.apache.openejb.core.ivm.naming.BusinessLocalReference.getObject(BusinessLocalReference.java:33)
        at
org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:150)
        at
org.apache.openejb.core.ivm.naming.ContextWrapper.lookup(ContextWrapper.java:115)
        at javax.naming.InitialContext.lookup(InitialContext.java:455)
        at org.superbiz.injection.MoviesTest.test(MoviesTest.java:40)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
        at java.lang.reflect.Method.invoke(Method.java:599)
        at junit.framework.TestCase.runTest(TestCase.java:164)
        at junit.framework.TestCase.runBare(TestCase.java:130)
        at junit.framework.TestResult$1.protect(TestResult.java:110)
        at junit.framework.TestResult.runProtected(TestResult.java:128)
        at junit.framework.TestResult.run(TestResult.java:113)
        at junit.framework.TestCase.run(TestCase.java:120)
        at junit.framework.TestSuite.runTest(TestSuite.java:228)
        at junit.framework.TestSuite.run(TestSuite.java:223)
        at
org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
        at
org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
        at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
        at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
        at java.lang.reflect.Method.invoke(Method.java:599)
        at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
        at
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)
Caused by:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
        at java.lang.Class.forName(Class.java:136)
        at
org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1253)
        ... 48 more
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 20.332 sec
<<< FAILURE!

Results :

Tests in error:
  test(org.superbiz.injection.MoviesTest)

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

[INFO]
------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO]
------------------------------------------------------------------------
[INFO] There are test failures.

Please refer to
/home/tomcat/webapps/injection-of-datasource/target/surefire-reports for the
individual test results.
[INFO]
------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 8 minutes 7 seconds
[INFO] Finished at: Thu Jan 29 15:17:25 GMT 2009
[INFO] Final Memory: 32M/58M
[INFO]
------------------------------------------------------------------------



I do have another concern......from studying the injection example, all the
SQL is wrote in Java. This is something that we don't really want to do. We
want to call the connection written in Java from PHP, and then use that
connection to carry out mysql queries within PHP - is this going to be
possible? Or does all the SQL have to be writtin in the Java?












David Blevins wrote:
> 
> 
>> Sorry for the delay -- we're a bit backed up at the moment :)
> 
> No problem!
> 
>> I see. This is a very different approach to accessing the bean than  
>> via SOAP as shown in the other article.  With SOAP you have 100%  
>> native client.  This technique uses java on the client which as a  
>> result is going to use our binary protocol to do the remote  
>> invocations.  This is fine.  If you go this route you'll need to  
>> follow a different example, the one I created for you won't work.  The  
>> main difference is that you'd remove the @WebService and then you'd  
>> need to add an @Remote interface.  The "component-interfaces" example  
>> matches that article the best as it uses the old style home/remote  
>> interfaces.  A newer approach would be to follow the "telephone- 
>> stateful" example.
> 
> Lets take the SOAP route for now, and access the Calculator service from
> PHP. Once this is done I can think about getting a web service set up for
> MySQL database access via JDBC type 4 or JNDI (required for the IDMS
> database JDBC driver), and then calling this from PHP. If it all works
> well I can implement this into the IDMS config - just change the JNDI /
> JDBC configs hopefully?
> 
>> I suspect though that there's going to be a slight learning curve on  
>> either one, though.
> 
> I'm ready for it!
> 
>> Which startup script are you referring to?  If you mean the tomcat/bin/ 
>> startup.sh than, no, you don't need to modify that.  We'll find our  
>> libraries and load them automatically.
> 
> My .bashrc file for Linux startup. I dont think this applies.
> 
>> One idea for you as I know getting started in a new technology is  
>> extremely difficult due to all the very large pieces that have to be  
>> learned before much of anything can be done.  Rather than buying bunch  
> of books, you might try finding the mailing list for the local java  
>> user group and offering a 100 bucks and a few beers (or coffees and  
>> snacks) for an afternoon side by side hacking.  Just let them know  
>> what your trying to do and what technologies you're using (PHP, EJB,  
>> JDBC, Servlets).  In this economy there's guaranteed to be a few  
>> people who'd take you up on that offer.  Will be the best 100 you ever  
>> spent.
> 
> Agreed, is this forum US based? I am in the UK, I wonder if there is
> anyone here willing to do that??
> 
> As for SOAP and PHP, I now have the SOAP extension installed - I
> recompiled PHP with --enable-soap and its now available in PHP as an
> extension.
> 
> Can I access the Calculator web service using the PHP SOAP extension
> without adding axis2 or any other SOAP service for Apache2 and Tomcat? ( I
> read above that you use Apache CXF?)
> 
> I've got to a point now where I'm stuck again - I saw that you gave me the
> following:
> 
>> As an FYI, the client-side SOAP message associated with that call   
>> looks like this: 
> 
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
>    <soap:Body> 
>      <ns1:multiply xmlns:ns1="http://superbiz.org/wsdl"> 
>        <arg0>3</arg0> 
>        <arg1>4</arg1> 
>      </ns1:multiply> 
>    </soap:Body> 
> </soap:Envelope>
> 
> Where do I insert this config? 
> 
> Also, how do I actually get the Calculator web service to do some
> calculations? Can I add variables to the URL to get some output e.g.
> www.localhost:8080/Calculator?some_variable_add etc
> 
> PHP can call a WSDL file using the following code (this requires NuSOAP):
> 
> < ?php
> 
> // include the SOAP classes
> require_once(’nusoap.php’);
> 
> $client = new soapclient(’http://example.com/url/to/some/valid.wsdl’,
> True);
> 
> $err = $client->getError();
> if ($err) {
> // Display the error
> echo ‘client construction error: ‘ . $err ;
> } else {
> $answer = $client->call(’someSOAPMethod’,
> array(
> ‘param1′=>’foo’
> ,’param2′=>’bar’));
> 
> $err = $client->getError();
> if ($err) {
> // Display the error
> echo ‘Call error: ‘ . $err;
> print_r($client->response);
> print_r($client->getDebug());
> } else {
> print_r($answer);
> }
> }
> ?>
> 
> Is it possible to create a WSDL file for the Calculator service? How is
> this done? If I can do this I can call it from PHP.
> 
> Sorry that my questions are really poor quality, but I've got really
> confused and prety stuck. 
> 
> Any help will be fantastic again.
> king regards
> Jp
> 

-- 
View this message in context: http://www.nabble.com/Tomcat-and-openEJB---how-to-do-this-simple-config--tp21582249p21855662.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Mime
View raw message