Can't use other bundle [message #737803] |
Sat, 15 October 2011 09:21  |
Eclipse User |
|
|
|
Hi,
I created a bundle that contains the jdbc driver. Because I could not get it up and running I created a RCP Client application that uses this bundle and it works well. See the example below.
public class DBConnection {
public static Connection getConnection() {
Connection connection = null;
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
}
catch (java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
catch (InstantiationException e) {
System.err.print("InstantiationException: ");
e.printStackTrace();
}
catch (IllegalAccessException e) {
e.printStackTrace();
}
try {
String connectionUrl = "jdbc:sqlserver://localhost:1433;database=MY_DB;";
connection = DriverManager.getConnection(connectionUrl, "user", "password");
}
catch (SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
return connection;
}
}
When I add the same bundle to a Scout Server and configure the SQL Service (see below) it cannot find the class.
(First it could not able to find the bundle but solved that with the help of ivan.motsch)
public class MsSqlService extends AbstractSqlService implements IService {
@Override
protected String getConfiguredJdbcDriverName() {
return "com.microsoft.sqlserver.jdbc.SQLServerDriver";
}
@Override
protected String getConfiguredJdbcMappingName() {
return "jdbc:sqlserver://localhost:1433";
}
@Override
protected String getConfiguredJdbcProperties() {
return "database=MY_DB";
}
@Override
protected String getConfiguredPassword() {
return "password";
}
@Override
protected String getConfiguredUsername() {
return "user";
}
So the question is, what is different in Scout that this does not work. Is it something with different class loaders ? or do I have to make some more configurations to make it work?
Regards Bertin
|
|
|
|
Re: Can't use other bundle [message #738653 is a reply to message #738103] |
Sun, 16 October 2011 10:58   |
Eclipse User |
|
|
|
Hi,
what do you mean by this "You should do it in the Runtimetime Tab of the Plugin.xml/Manifest editor of your Bundle."
I can not find a location on the runtime tab where I can add a bundle. I added the bundle to the plug-in (see manifest) and on the product (see .MyServer-server-dev.product contents below) other wise it could not find the bundle.
But whatever I do and change in the plug-in or product configuration, it is never able to find the SQLServerDriver. It works perfect in a 'normal' RCP project. So what is different in the Scout server class loading?
Manifest
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: MPXRid.server
Bundle-SymbolicName: MPXRid.server;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: MPXRid.server.Activator
Bundle-ActivationPolicy: lazy
Require-Bundle: org.eclipse.core.runtime,
MPXRid.shared,
org.eclipse.scout.rt.server,
com.microsoft.jdbc;bundle-version="1.0.0"
Export-Package: MPXRid.server,
MPXRid.server.services.custom.security,
MPXRid.server.services.common.sql,
MPXRid.server.services.outline
Bundle-ClassPath: .
Import-Package: javax.servlet;version="2.4.0",
javax.servlet.http;version="2.4.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
MPXRid-server-dev.product :
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>
<product name="MPXRid Server" id="MPXRid.server.product" application="MPXRid.server.app" useFeatures="false" includeLaunchers="true">
<configIni use="default">
<linux>/MPXRid.server/products/development/config.ini</linux>
<macosx>/MPXRid.server/products/development/config.ini</macosx>
<win32>/MPXRid.server/products/development/config.ini</win32>
</configIni>
<launcherArgs>
<vmArgs>-Xms64m
-Xmx512m
-XX:MaxPermSize=256m</vmArgs>
</launcherArgs>
<windowImages/>
<launcher>
<solaris/>
<win useIco="false">
<bmp/>
</win>
</launcher>
<vm>
</vm>
<plugins>
<plugin id="MPXRid.server"/>
<plugin id="MPXRid.shared"/>
<plugin id="com.microsoft.jdbc"/>
<plugin id="javax.servlet"/>
<plugin id="org.apache.commons.codec"/>
<plugin id="org.eclipse.core.contenttype"/>
<plugin id="org.eclipse.core.jobs"/>
<plugin id="org.eclipse.core.runtime"/>
<plugin id="org.eclipse.core.runtime.compatibility.registry" fragment="true"/>
<plugin id="org.eclipse.equinox.app"/>
<plugin id="org.eclipse.equinox.common"/>
<plugin id="org.eclipse.equinox.http.jetty"/>
<plugin id="org.eclipse.equinox.http.registry"/>
<plugin id="org.eclipse.equinox.http.servlet"/>
<plugin id="org.eclipse.equinox.launcher"/>
<plugin id="org.eclipse.equinox.launcher.win32.win32.x86" fragment="true"/>
<plugin id="org.eclipse.equinox.preferences"/>
<plugin id="org.eclipse.equinox.registry"/>
<plugin id="org.eclipse.equinox.security"/>
<plugin id="org.eclipse.equinox.security.win32.x86" fragment="true"/>
<plugin id="org.eclipse.osgi"/>
<plugin id="org.eclipse.osgi.services"/>
<plugin id="org.eclipse.scout.commons"/>
<plugin id="org.eclipse.scout.http.servletfilter"/>
<plugin id="org.eclipse.scout.rt.jdbc.derby"/>
<plugin id="org.eclipse.scout.rt.server"/>
<plugin id="org.eclipse.scout.rt.shared"/>
<plugin id="org.eclipse.scout.service"/>
<plugin id="org.eclipse.update.configurator"/>
<plugin id="org.mortbay.jetty.server"/>
<plugin id="org.mortbay.jetty.util"/>
</plugins>
</product>
console log
Caused by: java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.eclipse.scout.rt.server.services.common.jdbc.internal.pool.SqlConnectionBuilder.createJdbcConnection(SqlConnectionBuilder.java:35)
at org.eclipse.scout.rt.server.services.common.jdbc.internal.pool.SqlConnectionPool.leaseConnection(SqlConnectionPool.java:102)
at org.eclipse.scout.rt.server.services.common.jdbc.AbstractSqlService.leaseConnectionInternal(AbstractSqlService.java:609)
... 61 more
|
|
|
Re: Can't use other bundle [message #738773 is a reply to message #738653] |
Sun, 16 October 2011 14:36   |
Eclipse User |
|
|
|
Simply add the following line the the MANIFEST.MF of 'com.microsoft.jdbc':
Eclipse-RegisterBuddy: org.eclipse.scout.rt.server
For more details see:
http://www.eclipse.org/forums/index.php/mv/msg/246503/738769/#msg_738769
-andreas
On 16.10.2011 16:58, bertin wrote:
> Hi,
>
> what do you mean by this "You should do it in the Runtimetime Tab of the
> Plugin.xml/Manifest editor of your Bundle."
> I can not find a location on the runtime tab where I can add a bundle. I
> added the bundle to the plug-in (see manifest) and on the product (see
> .MyServer-server-dev.product contents below) other wise it could not
> find the bundle.
>
> But whatever I do and change in the plug-in or product configuration, it
> is never able to find the SQLServerDriver. It works perfect in a
> 'normal' RCP project. So what is different in the Scout server class
> loading?
>
> Manifest
>
> Manifest-Version: 1.0
> Bundle-ManifestVersion: 2
> Bundle-Name: MPXRid.server
> Bundle-SymbolicName: MPXRid.server;singleton:=true
> Bundle-Version: 1.0.0.qualifier
> Bundle-Activator: MPXRid.server.Activator
> Bundle-ActivationPolicy: lazy
> Require-Bundle: org.eclipse.core.runtime,
> MPXRid.shared,
> org.eclipse.scout.rt.server,
> com.microsoft.jdbc;bundle-version="1.0.0"
> Export-Package: MPXRid.server,
> MPXRid.server.services.custom.security,
> MPXRid.server.services.common.sql,
> MPXRid.server.services.outline
> Bundle-ClassPath: .
> Import-Package: javax.servlet;version="2.4.0",
> javax.servlet.http;version="2.4.0"
> Bundle-RequiredExecutionEnvironment: JavaSE-1.6
>
>
>
> MPXRid-server-dev.product :
>
> <?xml version="1.0" encoding="UTF-8"?>
> <?pde version="3.5"?>
>
> <product name="MPXRid Server" id="MPXRid.server.product"
> application="MPXRid.server.app" useFeatures="false"
> includeLaunchers="true">
>
> <configIni use="default">
> <linux>/MPXRid.server/products/development/config.ini</linux>
> <macosx>/MPXRid.server/products/development/config.ini</macosx>
> <win32>/MPXRid.server/products/development/config.ini</win32>
> </configIni>
>
> <launcherArgs>
> <vmArgs>-Xms64m
> -Xmx512m
> -XX:MaxPermSize=256m</vmArgs>
> </launcherArgs>
>
> <windowImages/>
>
> <launcher>
> <solaris/>
> <win useIco="false">
> <bmp/>
> </win>
> </launcher>
>
> <vm>
> </vm>
>
> <plugins>
> <plugin id="MPXRid.server"/>
> <plugin id="MPXRid.shared"/>
> <plugin id="com.microsoft.jdbc"/>
> <plugin id="javax.servlet"/>
> <plugin id="org.apache.commons.codec"/>
> <plugin id="org.eclipse.core.contenttype"/>
> <plugin id="org.eclipse.core.jobs"/>
> <plugin id="org.eclipse.core.runtime"/>
> <plugin id="org.eclipse.core.runtime.compatibility.registry"
> fragment="true"/>
> <plugin id="org.eclipse.equinox.app"/>
> <plugin id="org.eclipse.equinox.common"/>
> <plugin id="org.eclipse.equinox.http.jetty"/>
> <plugin id="org.eclipse.equinox.http.registry"/>
> <plugin id="org.eclipse.equinox.http.servlet"/>
> <plugin id="org.eclipse.equinox.launcher"/>
> <plugin id="org.eclipse.equinox.launcher.win32.win32.x86" fragment="true"/>
> <plugin id="org.eclipse.equinox.preferences"/>
> <plugin id="org.eclipse.equinox.registry"/>
> <plugin id="org.eclipse.equinox.security"/>
> <plugin id="org.eclipse.equinox.security.win32.x86" fragment="true"/>
> <plugin id="org.eclipse.osgi"/>
> <plugin id="org.eclipse.osgi.services"/>
> <plugin id="org.eclipse.scout.commons"/>
> <plugin id="org.eclipse.scout.http.servletfilter"/>
> <plugin id="org.eclipse.scout.rt.jdbc.derby"/>
> <plugin id="org.eclipse.scout.rt.server"/>
> <plugin id="org.eclipse.scout.rt.shared"/>
> <plugin id="org.eclipse.scout.service"/>
> <plugin id="org.eclipse.update.configurator"/>
> <plugin id="org.mortbay.jetty.server"/>
> <plugin id="org.mortbay.jetty.util"/>
> </plugins>
>
>
> </product>
>
>
>
> console log
>
> Caused by: java.lang.ClassNotFoundException:
> com.microsoft.sqlserver.jdbc.SQLServerDriver
> at
> org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
>
> at
> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
>
> at
> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
>
> at
> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
>
> at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:169)
> at
> org.eclipse.scout.rt.server.services.common.jdbc.internal.pool.SqlConnectionBuilder.createJdbcConnection(SqlConnectionBuilder.java:35)
>
> at
> org.eclipse.scout.rt.server.services.common.jdbc.internal.pool.SqlConnectionPool.leaseConnection(SqlConnectionPool.java:102)
>
> at
> org.eclipse.scout.rt.server.services.common.jdbc.AbstractSqlService.leaseConnectionInternal(AbstractSqlService.java:609)
>
> ... 61 more
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.06499 seconds