on 06-19-2008 12:59 PM
Hi,
I have a problem with the connection to my database MaxDB.
I created a JDBC Connector in the Visual Administrator.
Now I try to connect to the database from my ejb project.
I try it with the following statement
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("jdbc/CCPM");
Here I got the error message:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at myspv.com.connectors.SAPDBConnector.getManagedOracleDBConnection(SAPDBConnector.java:46)
at myspv.com.connectors.SAPDBConnector.main(SAPDBConnector.java:54)
Now, after reading some sdn entries, I try it with the following statement:
Properties p = new Properties();
p.put(InitialContext.INITIAL_CONTEXT_FACTORY,"com.sap.engine.services.jndi.InitialContextFactoryImpl");
p.put(InitialContext.PROVIDER_URL, "localhost:50004");
InitialContext ctx = new InitialContext(p);
DataSource ds = (DataSource) ctx.lookup("jdbc/CCPM");
But I got again an error:
java.lang.NoClassDefFoundError: javax/resource/ResourceException
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
Could anyone explain me what the error are and what is the solution for each error?
Thanks a lot.
Nils
.Jar file is missing which contains the package javax/resource/ResourceException.
Check it in www.docjar.com for the jar file which contains this package and download the correct jar file and place it in lib folder of your project.
Reward points if useful
Regards,
Siva.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>
> .Jar file is missing which contains the package javax/resource/ResourceException.
> Check it in www.docjar.com for the jar file which contains this package and download the correct jar file and place it in lib folder of your project.
>
> Reward points if useful
> Regards,
> Siva.
Well Siva,
this is really... far away from anything like a solution.
For this you only can get negative points.
Regards,
Benny
Hi Benny,
thanks for your answer.
I regarded and also reconstructed the assistance but I get yet the first error message
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at myspv.com.connectors.SAPDBConnector.getManagedOracleDBConnection(SAPDBConnector.java:46)
at myspv.com.connectors.SAPDBConnector.main(SAPDBConnector.java:54)
I created a JDBC Connector and JMS Connector.
Thanks
Nils
How about some reading in the docs?
[Getting a Connection to the Database|http://help.sap.com/saphelp_nw70/helpdata/en/82/fdbf2085f65f43a71e755fc904478d/frameset.htm] or
[Relational Persistence|http://help.sap.com/saphelp_nw70/helpdata/en/b8/092492099b7c44b266c3128624076e/frameset.htm]
That should help....
BTW: Your second try is completely off the records.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.