Can't generate code with JOOQ and MySQL Database over SSL connection - java

i'm trying to generate code from a MySQL database, which I connect to over SSL. I got 3 files from the guy who set up the database (client-cert.pem, client-key.pem, ca-cert.pem)
To connect to the database in Java I first had to solve another problem with the certificates. With the help of http://bugs.mysql.com/bug.php?id=68957 and the answer from "[17 Apr 2013 9:04] Alexander Soklakov", I mananged to get the JDBC connection to work as expected in my Java code.
But now I don't know where to configure SSL in JOOQs library.xml. Where do I provide the *.pem files? Or my created trust- & keystore? Without configuration of SSL I get
Jun 11, 2014 1:53:40 PM org.jooq.tools.JooqLogger info
Information: Initialising properties : ./library.xml
com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
javax.net.ssl.SSLException
MESSAGE: Unsupported record version Unknown-0.0
STACKTRACE:
javax.net.ssl.SSLException: Unsupported record version Unknown-0.0
at sun.security.ssl.InputRecord.readV3Record(Unknown Source)
at sun.security.ssl.InputRecord.read(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at com.mysql.jdbc.ExportControlled.transformSocketToSSLSocket(ExportControlled.java:72)
at com.mysql.jdbc.MysqlIO.negotiateSSLConnection(MysqlIO.java:4237)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1222)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2558)
at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.jooq.util.GenerationTool.run(GenerationTool.java:206)
at org.jooq.util.GenerationTool.main(GenerationTool.java:173)
at org.jooq.util.GenerationTool.main(GenerationTool.java:160)
** END NESTED EXCEPTION **
Last packet sent to the server was 396 ms ago.
at com.mysql.jdbc.ExportControlled.transformSocketToSSLSocket(ExportControlled.java:87)
at com.mysql.jdbc.MysqlIO.negotiateSSLConnection(MysqlIO.java:4237)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1222)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2558)
at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.jooq.util.GenerationTool.run(GenerationTool.java:206)
at org.jooq.util.GenerationTool.main(GenerationTool.java:173)
at org.jooq.util.GenerationTool.main(GenerationTool.java:160)
Jun 11, 2014 1:53:41 PM org.jooq.tools.JooqLogger error
Schwerwiegend: Cannot read ./library.xml. Error : Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
javax.net.ssl.SSLException
MESSAGE: Unsupported record version Unknown-0.0
STACKTRACE:
javax.net.ssl.SSLException: Unsupported record version Unknown-0.0
at sun.security.ssl.InputRecord.readV3Record(Unknown Source)
at sun.security.ssl.InputRecord.read(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at com.mysql.jdbc.ExportControlled.transformSocketToSSLSocket(ExportControlled.java:72)
at com.mysql.jdbc.MysqlIO.negotiateSSLConnection(MysqlIO.java:4237)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1222)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2558)
at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.jooq.util.GenerationTool.run(GenerationTool.java:206)
at org.jooq.util.GenerationTool.main(GenerationTool.java:173)
at org.jooq.util.GenerationTool.main(GenerationTool.java:160)
** END NESTED EXCEPTION **
Last packet sent to the server was 396 ms ago.
com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
javax.net.ssl.SSLException
MESSAGE: Unsupported record version Unknown-0.0
STACKTRACE:
javax.net.ssl.SSLException: Unsupported record version Unknown-0.0
at sun.security.ssl.InputRecord.readV3Record(Unknown Source)
at sun.security.ssl.InputRecord.read(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at com.mysql.jdbc.ExportControlled.transformSocketToSSLSocket(ExportControlled.java:72)
at com.mysql.jdbc.MysqlIO.negotiateSSLConnection(MysqlIO.java:4237)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1222)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2558)
at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.jooq.util.GenerationTool.run(GenerationTool.java:206)
at org.jooq.util.GenerationTool.main(GenerationTool.java:173)
at org.jooq.util.GenerationTool.main(GenerationTool.java:160)
** END NESTED EXCEPTION **
Last packet sent to the server was 396 ms ago.
at com.mysql.jdbc.ExportControlled.transformSocketToSSLSocket(ExportControlled.java:87)
at com.mysql.jdbc.MysqlIO.negotiateSSLConnection(MysqlIO.java:4237)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1222)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2558)
at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.jooq.util.GenerationTool.run(GenerationTool.java:206)
at org.jooq.util.GenerationTool.main(GenerationTool.java:173)
at org.jooq.util.GenerationTool.main(GenerationTool.java:160)
Jun 11, 2014 1:53:41 PM org.jooq.tools.JooqLogger error
Schwerwiegend: Usage : GenerationTool <configuration-file>
My library.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-2.5.0.xsd">
<!-- Configure the database connection here -->
<jdbc>
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://server:3306/dbname?useSSL=true&requireSSL=true&verifyServerCertificate=false;</url>
<user>user</user>
<password>pass</password>
</jdbc>
<generator>
<!-- The default code generator. You can override this one, to generate your own code style
Defaults to org.jooq.util.DefaultGenerator -->
<name>org.jooq.util.DefaultGenerator</name>
<database>
<!-- The database type. The format here is:
org.util.[database].[database]Database -->
<name>org.jooq.util.mysql.MySQLDatabase</name>
<!-- The database schema (or in the absence of schema support, in your RDBMS this
can be the owner, user, database name) to be generated -->
<inputSchema>dbname</inputSchema>
<!-- All elements that are generated from your schema (several Java regular expressions, separated by comma)
Watch out for case-sensitivity. Depending on your database, this might be important! -->
<includes>smv_.*</includes>
<!-- All elements that are excluded from your schema (several Java regular expressions, separated by comma).
Excludes match before includes -->
<excludes></excludes>
</database>
<target>
<!-- The destination package of your generated classes (within the destination directory) -->
<packageName>my.package</packageName>
<!-- The destination directory of your generated classes -->
<directory>./src</directory>
</target>
</generator>
</configuration>
I also could not find any hints, when I took a look at the schema under http://www.jooq.org/xsd/jooq-codegen-2.5.0.xsd
Right now it looks like I have to give up on using JOOQ :(
Edit: I use Eclipse to generate the JOOQ code, like explained in: http://www.jooq.org/doc/3.0/manual/code-generation/codegen-configuration/ under "Run code generation from Eclipse".

If you need a more special way to set up your database connection, the right way to go forward is probably by using programmatic code generation configuration. This is documented here:
http://www.jooq.org/doc/latest/manual/code-generation/codegen-programmatic/
We (unfortunately) hadn't explicitly documented this yet, but you can pass a JDBC connection explicitly to the GenerationTool by calling setConnection()

Solution, based on the accepted answer of Lukas Eder
After creating the truststore and keystore (scroll down to [17 Apr 2013 9:04] Alexander Soklakov), I could generate the code with the following class, where I get an SSL database connection and use it for the JOOQ Generator:
import java.sql.Connection;
import org.jooq.util.GenerationTool;
import org.jooq.util.jaxb.Configuration;
import org.jooq.util.jaxb.Database;
import org.jooq.util.jaxb.Generator;
import org.jooq.util.jaxb.Target;
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
public class JooqGenerator {
public static void main(String[] args) throws Exception {
MysqlDataSource mysqlDS = new MysqlDataSource();
mysqlDS.setUseSSL(true);
mysqlDS.setRequireSSL(true);
mysqlDS.setClientCertificateKeyStoreUrl(".../keystore");
mysqlDS.setClientCertificateKeyStorePassword("keystore-pw");
mysqlDS.setTrustCertificateKeyStoreUrl(".../truststore");
mysqlDS.setTrustCertificateKeyStorePassword("truststore-pw");
mysqlDS.setServerName("server");
mysqlDS.setPort(3306);
mysqlDS.setDatabaseName("databasename");
Connection connection = mysqlDS.getConnection("user", "password");
Configuration configuration = new Configuration()
.withGenerator(new Generator()
.withName("org.jooq.util.DefaultGenerator")
.withDatabase(new Database()
.withName("org.jooq.util.mysql.MySQLDatabase")
.withIncludes(".*")
.withExcludes("")
.withInputSchema("databasename"))
.withTarget(new Target()
.withPackageName("my.package.name")
.withDirectory("./src")));
GenerationTool tool = new GenerationTool();
tool.setConnection(connection);
tool.run(configuration);
}
}

Related

Error when configuring Datasource Oracle 11g into Apache Tomcat 7 (7.0.82)

I am trying to change the configuration in my application to use the datasource into the Apache Tomcat server with Oracle DB 11g, but it is throwing an error about SYS.AUD$ tablespace. Follow my configuration:
$TOMCAT_HOME/conf/context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource auth="Container"
name="jdbc/oracleds"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:#HOSTNAME:PORT/SERVICENAME"
username="${db.user}"
password="${db.password}"
maxActive="20"
maxIdle="10"
maxWait="10000"
validationQuery="SELECT SYSDATE FROM DUAL"
/>
</Context>
While the server is loading the following exception is displayed into the console:
Jul 24, 2018 11:17:37 AM org.apache.tomcat.jdbc.pool.ConnectionPool init
SEVERE: Unable to create initial connections of the pool.
java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-01653: unable to extend table SYS.AUD$ by 1024 in tablespace SYSTEM
ORA-02002: error while writing to audit trail
ORA-00604: error occurred at recursive SQL level 1
ORA-01653: unable to extend table SYS.AUD$ by 1024 in tablespace SYSTEM
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:445)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:389)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:382)
at oracle.jdbc.driver.T4CTTIfun.processError(T4CTTIfun.java:600)
at oracle.jdbc.driver.T4CTTIoauthenticate.processError(T4CTTIoauthenticate.java:445)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:450)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192)
at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:380)
at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:760)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:401)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:546)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:236)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:278)
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:182)
at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:730)
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:664)
at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:482)
at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:156)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:116)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:103)
at org.apache.tomcat.jdbc.pool.DataSourceFactory.createDataSource(DataSourceFactory.java:560)
at org.apache.tomcat.jdbc.pool.DataSourceFactory.getObjectInstance(DataSourceFactory.java:245)
at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:141)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at org.apache.naming.NamingContext.lookup(NamingContext.java:848)
at org.apache.naming.NamingContext.lookup(NamingContext.java:159)
at org.apache.naming.NamingContextBindingsEnumeration.nextElementInternal(NamingContextBindingsEnumeration.java:117)
at org.apache.naming.NamingContextBindingsEnumeration.next(NamingContextBindingsEnumeration.java:71)
at org.apache.naming.NamingContextBindingsEnumeration.next(NamingContextBindingsEnumeration.java:34)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:138)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:145)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:110)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.lifecycleEvent(GlobalResourcesLifecycleListener.java:82)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:388)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:333)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:751)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.startup.Catalina.start(Catalina.java:694)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:428)
Try replacing the oracle.jdbc.OracleDriver with oracle.jdbc.driver.OracleDriver
RESOLVED I've discovered that my database FREE SPACE was very low (less than 100 MB) so I've asked the support team to fix it (increasing the memory available) and now the initial configuration has worked as expected.
Giving a look at another resolved question here I've found some interesting information about how to configure the Connection Pool in Tomcat server:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory ( 'v$session.osuser' , value is 'x')

Running application with Java 9, module java.base does not "opens java.io"

I tried to run my application (front-end developed in Java Swing, server developed with EJB deployed on Wildfly 8) with Java 9.
When the client tries to establish an EJB connection got the following exception:
09:53:42,358 INFO [xnio] XNIO version 3.2.0.Final
09:53:42,465 INFO [nio] XNIO NIO Implementation Version 3.2.0.Final
09:53:42,507 DEBUG [nio] Started channel thread 'Remoting "config-based-naming-client-endpoint" I/O-1', selector sun.nio.ch.WindowsSelectorImpl#4b4a5caf
RmiServiceFactpry ExceptionInInitializerError
java.lang.ExceptionInInitializerError
at org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver.<init>(RemotingConnectionEJBReceiver.java:148)
at org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver.<init>(RemotingConnectionEJBReceiver.java:106)
at org.jboss.ejb.client.EJBClientContext.registerConnection(EJBClientContext.java:465)
at org.jboss.naming.remote.client.ejb.RemoteNamingStoreEJBClientHandler.associate(RemoteNamingStoreEJBClientHandler.java:78)
at org.jboss.naming.remote.protocol.v1.RemoteNamingStoreV1.<init>(RemoteNamingStoreV1.java:71)
at org.jboss.naming.remote.protocol.v1.VersionOne.getRemoteNamingStore(VersionOne.java:50)
at org.jboss.naming.remote.protocol.Versions.getRemoteNamingStore(Versions.java:55)
at org.jboss.naming.remote.client.RemoteContextFactory.createVersionedStore(RemoteContextFactory.java:73)
at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:202)
at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:149)
at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:130)
at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:272)
at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:79)
at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:83)
at java.naming/javax.naming.InitialContext.lookup(Unknown Source)
at com.dataloy.client.core.RmiServiceFactory.createRemote(RmiServiceFactory.java:105)
at com.dataloy.client.core.RmiServiceFactory.getServiceImpl(RmiServiceFactory.java:96)
at com.dataloy.core.AbstractServiceFactory.getService(AbstractServiceFactory.java:58)
at com.dataloy.DataloyEngine.getService(DataloyEngine.java:198)
at com.dataloy.DataloyEngine.login(DataloyEngine.java:548)
at com.dataloy.client.login.LoginPanel.doLogin(LoginPanel.java:511)
at com.dataloy.client.login.LoginPanel.access$500(LoginPanel.java:56)
at com.dataloy.client.login.LoginPanel$5.run(LoginPanel.java:452)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make java.io.OptionalDataException(boolean) accessible: module java.base does not "opens java.io" to unnamed module #312002a1
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(Unknown Source)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(Unknown Source)
at java.base/java.lang.reflect.Constructor.checkCanSetAccessible(Unknown Source)
at java.base/java.lang.reflect.Constructor.setAccessible(Unknown Source)
at org.jboss.marshalling.Marshalling$OptionalDataExceptionCreateAction$1.run(Marshalling.java:385)
at org.jboss.marshalling.Marshalling$OptionalDataExceptionCreateAction$1.run(Marshalling.java:381)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at org.jboss.marshalling.Marshalling$OptionalDataExceptionCreateAction.<init>(Marshalling.java:381)
at org.jboss.marshalling.Marshalling$OptionalDataExceptionCreateAction.<init>(Marshalling.java:376)
at org.jboss.marshalling.Marshalling.<clinit>(Marshalling.java:374)
... 23 more
I see there is some problem with the new module management introduced in Java 9, but I cannot understand what should do.
Regards,
Andrea
As per this answer you need to add --add-opens java.base/java.io=ALL-UNNAMED to the java command that launches the application.
Adding the following JVM parameters:
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
--add-opens=java.base/java.io=ALL-UNNAMED
--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED
the above exception it is not reached anymore, it fails before with this exception:
java.lang.ClassNotFoundException: com.dataloy.client.Main
at jdk.deploy#9-ea/com.sun.deploy.security.DeployURLClassLoader.findClass(Unknown Source)
at jdk.javaws#9-ea/com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
at jdk.javaws#9-ea/com.sun.jnlp.JNLPClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
at jdk.javaws#9-ea/com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at jdk.javaws#9-ea/com.sun.javaws.Launcher.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
I need to make visible more modules but I struggling to understand which one.
Andrea

Error while reading image data:SqlException: [jcc][10120][11936][4.11.77] Invalid operation: Lob is closed. ERRORCODE=-4470, SQLSTATE=null

I am working on application and in one page i have been fetching images from DB and i am not able to get the images in the front end but the page is loading and showing other details.
I am using was liberty profile server for this application.
Could you please suggest me regarding this problem.
please find the error below.
ERROR CustomRequestCycle - Unexpected exception
org.apache.wicket.WicketRuntimeException: Error while reading image data
at org.apache.wicket.markup.html.image.resource.BlobImageResource.getImageData (BlobImageResource.java:102)
at org.apache.wicket.markup.html.image.resource.DynamicImageResource$1.getData(DynamicImageResource.java:194)
Caused by: com.ibm.db2.jcc.am.SqlException: [jcc][10120][11936][4.11.77] Invalid operation:
Lob is closed. ERRORCODE=-4470, SQLSTATE=null
at com.ibm.db2.jcc.am.gd.a(gd.java:660)
at com.ibm.db2.jcc.am.gd.a(gd.java:60)
at com.ibm.db2.jcc.am.gd.a(gd.java:94)
at com.ibm.db2.jcc.am.ie.c(ie.java:67)
at com.ibm.db2.jcc.am.je.v(je.java:203)
at com.ibm.db2.jcc.am.je.getBinaryStream(je.java:107)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.hibernate.engine.jdbc.SerializableBlobProxy.invoke(SerializableBlobProxy.java:74)
at $Proxy68.getBinaryStream(Unknown Source)
at org.apache.wicket.markup.html.image.resource.BlobImageResource.getImageData(BlobImageResource.java:93)
... 55 more
According to Liberty profile Configuration elements, this property can be added like this:
<library id="DB2JCC4Lib">
<fileset dir="${wlp.install.dir}/lib"
includes="db2jcc.jar db2jcc_license_cisuz.jar db2jcc_license_cu.jar"/>
</library>
<dataSource id="db2_SUD" jndiName="jdbc/U_SUD">
<jdbcDriver libraryRef="DB2JCC4Lib"/>
<properties.db2.jcc databaseName="DB2TEST" password="YYYYY" portNumber="20025"
serverName="xyxyxyxxyx" user="XXXXX" progressiveStreaming="2"/>
</dataSource>

Tomcat errors when executing tutorial

I was executing the code from the tuorial from http://viralpatel.net/blogs/tutorial-create-struts-2-application-eclipse-example/ and I am getting the following errors
janv. 09, 2014 11:20:02 AM org.apache.struts2.dispatcher.Dispatcher error
Grave: Dispatcher initialization failed
Unable to load configuration. - bean - jar:file:/K:/sop/java/code/.
metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/StrutsHelloWorld/W
EB-INF/lib/struts2-core-2.3.16.jar!/struts-default.xml:64:179
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(Configu
rationManager.java:70)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatche
r.java:445)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:489)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperation
s.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(S
trutsPrepareAndExecuteFilter.java:57)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilte
rConfig.java:281)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilter
Config.java:262)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterCon
fig.java:107)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:47
75)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:
5452)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:15
59)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:15
49)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: Unable to load bean: type:org.apache.struts2.dispatcher.multipart.Mul
tiPartRequest class:org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequ
est - bean - jar:file:/K:/sop/java/code/.metadata/.plugins/org.ecli
pse.wst.server.core/tmp0/wtpwebapps/StrutsHelloWorld/WEB-INF/lib/struts2-core-2.
3.16.jar!/struts-default.xml:64:179
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(X
mlConfigurationProvider.java:245)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlC
onfigurationProvider.java:102)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(Def
aultConfiguration.java:234)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(Configu
rationManager.java:67)
... 16 more
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileUpl
oadBase$SizeLimitExceededException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getDeclaredConstructors(Unknown Source)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(X
mlConfigurationProvider.java:235)
... 19 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileU
ploadBase$SizeLimitExceededException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
a:1702)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
a:1547)
... 23 more
The jars that I use are:
commons-logging-1.1.3.jar
commons-lang3-3.1.jar
commons-logging-1.1.3.jar
freemaker-2.3.19.jar
javassist-3.11.0.GA.jar
ongl-3.0.6.jar
struts2-core-2.3.16.jar
xwork-core-2.3.16.jar
Can someone tell me what am I wrong? Is the Tomcat server? Is the code?
Another problem is that I was trying more tutorials on the internet and every time I get errors when applying struts2 to the web page. Can someone tell me What am I missing with Tomcat?
P.S. I am using Eclipse kepler, Could it be it th problem?
Javassist library is missing. You can download it from maven below is the link. This is mentioned in the exception itself :)
http://mvnrepository.com/artifact/javassist/javassist

SAXParseException in JAXB during CXF WebService test

I am new to JAXB. I was provided a wsdl file, I used apache-cxf utility wsdl2java to gain a number of java classes, from which I implemented my webservice. But when I start client server test on my service, I get the following exception:
мар 25, 2013 12:19:36 PM org.apache.cxf.wsdl.EndpointReferenceUtils createSchema
WARNING: SAXException for newSchema()
org.xml.sax.SAXParseException; src-import.1.1: The namespace attribute 'http://www.aaa.com/bbb/ccc/ddd' of an <import> element information item must not be the same as the targetNamespace of the schema it exists in.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.reportSchemaError(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.constructTrees(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)
at org.apache.xerces.jaxp.validation.XMLSchemaFactory.newSchema(Unknown Source)
at org.apache.cxf.wsdl.EndpointReferenceUtils.createSchema(EndpointReferenceUtils.java:698)
at org.apache.cxf.wsdl.EndpointReferenceUtils.getSchema(EndpointReferenceUtils.java:743)
at org.apache.cxf.binding.soap.interceptor.SoapHeaderInterceptor.handleMessage(SoapHeaderInterceptor.java:107)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:800)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1590)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1488)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1307)
at org.apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutputStream.java:50)
at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:229)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:622)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:530)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:133)
.............
INFO: Schema for: http://www.globe.com/warcraft/wsdl/amax
<?xml version="1.0" encoding="utf-8"?><xs:schema xmlns:tns="http://www.aaa.com/bbb/ccc/ddd" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.aaa.com/bbb/ccc/ddd" version="1.0">
<xs:import namespace="http://www.aaa.com/bbb/ccc/ddd"/>
...........
Why this intermediate XML is generated so, that it is importing itself? Can appearance of this import tag be cancelled somehow? I suppose, that the reason may be in the initial wsdl, or maybe it is some bug.
Thanks in advance
The problem was because in my generated ProxyServiceImpl class, I was missing a wsdlLocation in #WebService annotation:
#javax.jws.WebService(
serviceName = "ServiceName",
portName = "ServicePort",
targetNamespace = "http://www.aaa.com/bbb/ccc/ddd",
wsdlLocation = "path_to_wsdl",
endpointInterface = "ProxyService_class")
When I added it, everything worked.
as the exception suggest
org.xml.sax.SAXParseException; src-import.1.1: The namespace attribute 'http://www.aaa.com/bbb/ccc/ddd' of an element information item must not be the same as the targetNamespace of the schema it exists in.
Change the target name space and try refer this
Your answer about wsdlLocation helped me, but since I can't comment yet, I will just add more info.
As an option it is also possible to modify pom.xml and add wsdlLocation there
<wsdlOption>
<wsdl>${basedir}/src/main/resources/cxf/webservice.wsdl</wsdl>
<wsdlLocation>classpath:cxf/webservice.wsdl</wsdlLocation>
<wsdlOption>

Categories

Resources