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>
Related
I'm trying to create new Struts 2 application (annotation based configuration) with common header, footer and body where body change on menu click.
So I referred to this link which says If you are using annotations alone and no struts.xml, then you have to create a minimal one for this because there's no annotation available to define a custom result type.
Do i still have to create struts.xml for result-type tag?
I am trying to use Tiles 3 and getting this error:
Jun 17, 2017 3:26:20 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter struts2
Unable to load configuration. - [unknown location]
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:499)
at org.apache.struts2.dispatcher.InitOperations.initDispatcher(InitOperations.java:75)
at org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:63)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4590)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5233)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
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 configuration. - [unknown location]
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:906)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:445)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:486)
... 14 more
Caused by: The Result type [tiles] which is defined in the Result annotation on the class [class org.iibf.crf.action.LoginAction] or determined by the file extension or is the default result type for the PackageConfig of the action, could not be found as a result-type defined for the Struts/XWork package [org.iibf.crf.action#convention-default#/] - [unknown location]
at org.apache.struts2.convention.DefaultResultMapBuilder.createResultConfig(DefaultResultMapBuilder.java:443)
at org.apache.struts2.convention.DefaultResultMapBuilder.createFromAnnotations(DefaultResultMapBuilder.java:414)
at org.apache.struts2.convention.DefaultResultMapBuilder.createResultsFromAnnotations(DefaultResultMapBuilder.java:222)
at org.apache.struts2.convention.DefaultResultMapBuilder.build(DefaultResultMapBuilder.java:192)
at org.apache.struts2.convention.PackageBasedActionConfigBuilder.createActionConfig(PackageBasedActionConfigBuilder.java:948)
at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildConfiguration(PackageBasedActionConfigBuilder.java:700)
at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:336)
at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:53)
at com.
The default parent package should be not convention-default but tiles-default. You can distinguish this if you add a tiles plugin to the classpath and set the #ParentPackage("tiles-default") annotation to the action class. You can put this annotation on the class or package where it's applied by the retention policy.
Also note, that you can define the parent package globally, not only the custom action class from the previous example. I.e., if you have a package default in your configuration that extends tiles-default and you want to configure it globally use
<constant name="struts.convention.default.parent.package" value="default"/>
I'm trying to obfuscate my JavaFX application but it fails. The generated result does not work and I do not understand why. The resulting jar just fails because the fxml file cannot load all imports anymore (ClassNotFoundException).
The Deployment workflow:
Build runnable jar (in IntelliJ knwon as an artifact)
Obfuscate that jar with ProGuard
Fix some issues in that jar that ProGuard fails to do
1) The minimal example application
The example application 'GuardTest' is a IntelliJ project that consists of 3 classes.
sample.Main: contains the application entry point and loads the GUI fxml file 'sample.fxml'
sample.Controller: the controller class for 'sample.fxml'
controls.CustomControl: A simple javafx control that inherits from HBox. This is used in 'sample.fxml'
The contents of 'sample.fxml':
<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.VBox?>
<?import controls.CustomControl?>
<VBox fx:controller="sample.Controller"
xmlns:fx="http://javafx.com/fxml">
<children>
<CustomControl>
<children>
<Button text="Test"></Button>
</children>
</CustomControl>
</children>
</VBox>
2) Obfuscation
Now I use ProGuard for the resulting jar file that is generated from the above project. I use the following settings:
-target 8
-injars ./out/artifacts/JavaFXApp/JavaFXApp.jar
-outjars ./out/obfuscated/Obfuscated.jar
-ignorewarnings
-printmapping ./out/obfuscated/proguard.map
-dontusemixedcaseclassnames
-dontshrink
-dontoptimize
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
#-flattenpackagehierarchy
-repackageclasses 'p'
-allowaccessmodification
-libraryjars "<java.home>/lib/rt.jar"
-libraryjars "<java.home>/lib/javaws.jar"
-libraryjars "<java.home>/lib/ext/jfxrt.jar"
-adaptresourcefilecontents **.fxml,**.properties,META-INF/MANIFEST.MF,images/*.jar,publicCerts.store,production.version
-keepattributes javafx.fxml.FXML,Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,LocalVariable*Table,*Annotation*,Synthetic,EnclosingMethod
-keepclassmembers class * {
#javafx.fxml.FXML *;
}
-keepclassmembernames public class com.javafx.main.Main, com.nywelt.sharkload.application.Main {
public static void main(java.lang.String[]);
}
-keepclasseswithmembers public class com.javafx.main.Main, com.product.main.EntryFX, net.license.LicenseEntryPoint {
public *; public static *;
}
3) Fixing some (obvious) ProGuard failures
The resulting jar file 'Obfuscated.jar' has the following structure:
**Obfuscated.jar**
- META-INF
--> MANIFEST.MF
- p
--> a.class
--> b.class
--> c.class
- sample
--> sample.fxml
The main class starts the GUI by loading the 'sample.fxml' file with the following line:
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
Because of that I have to move the 'sample.fxml' file to the folder p as well to make the above line work again. I also fix some issue in the fxml file where ProGuard forgets to change a (now obfuscated) class name.
Now the structure looks like this:
**Obfuscated_fixed.jar**
- META-INF
--> MANIFEST.MF
- p
--> a.class
--> b.class
--> c.class
--> sample.fxml
The sample.fxml file now looks like this:
<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.VBox?>
<?import p.a?>
<VBox fx:controller="p.b"
xmlns:fx="http://javafx.com/fxml">
<children>
<a>
<children>
<Button text="Test"></Button>
</children>
</a>
</children>
</VBox>
The Problem
Now this jar should really work again because everything is ok again. But it DOESN'T! The fxml loader fails to load the CustomControl (now named/obfuscated 'a.class'). Why is that?
I get the following error output when starting the jar file (I'm running java version 1.8.0_40):
E:\Eigene Programme\GuardTest\out\obfuscated>java -jar Obfuscated_fixed.jar
Exception in Application start method
Exception in thread "main" java.lang.reflect.InvocationTargetException
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 sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown So
urce)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$152(
Unknown Source)
at com.sun.javafx.application.LauncherImpl$$Lambda$49/849460928.run(Unkn
own Source)
at java.lang.Thread.run(Unknown Source)
Caused by: javafx.fxml.LoadException:
file:/E:/Eigene%20Programme/GuardTest/out/obfuscated/Obfuscated_fixed.jar!/p/sam
ple.fxml
at javafx.fxml.FXMLLoader.constructLoadException(Unknown Source)
at javafx.fxml.FXMLLoader.importClass(Unknown Source)
at javafx.fxml.FXMLLoader.processImport(Unknown Source)
at javafx.fxml.FXMLLoader.processProcessingInstruction(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at p.c.start(Main.java:13)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$159
(Unknown Source)
at com.sun.javafx.application.LauncherImpl$$Lambda$52/663980963.run(Unkn
own Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(Unknown
Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$46/410424423.run(Unkn
own Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$170(Unknown Sourc
e)
at com.sun.javafx.application.PlatformImpl$$Lambda$48/1149216748.run(Unk
nown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(Unknown S
ource)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/1963387170.run(Unk
nown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$145(Unknown Source)
at com.sun.glass.ui.win.WinApplication$$Lambda$36/237061348.run(Unknown
Source)
... 1 more
Caused by: java.lang.ClassNotFoundException
at javafx.fxml.FXMLLoader.loadType(Unknown Source)
... 26 more
E:\Eigene Programme\GuardTest\out\obfuscated>Pause
Drücken Sie eine beliebige Taste . . .
Setting the default class loader in the main class with
FXMLLoader.setDefaultClassLoader(this.getClass().getClassLoader());
does not help either.
Project Files
Here you can find the example project (IntelliJ):
https://www.dropbox.com/s/ot51spvwk6lzo4k/GuardTest.zip?dl=0
The generated jar artifact by IntelliJ is compiled to:
./out/artifacts/JavaFXApp/JavaFXApp.jar
The obfuscated Jar is found under:
./out/obfuscated/Obfuscated.jar
The obfuscated but fixed (at least it should be) jar as described above:
./out/obfuscated/Obfuscated_fixed.jar
And to show that the import statement in the 'sample.fxml' file causes the problem I removed my custom control from the fxml file and saved that to the (working) jar:
./out/obfuscated/Obfuscated_fixed_work.jar
I'm sorry for the long question. I hope you will help me anyway :)
I have found the solution! The problem is that FXML cannot import classes that do not start with an upper case letter. Therefore one has to provide an own list of available names that ProGuard uses for obfuscating. This is done by:
-classobfuscationdictionary obfuscationClassNames.txt
With obfuscationClassNames.txt containing the line seperated list of available class names:
A
B
C
D
...
I used the same steps. I can see imports are updated into fxml file but their use is not.
Getting the exception:
javafx.fxml.LoadException: MenuBarControl is not a valid type.
But If I see the fxml file imports are updated but not their use.
< ? import q.A ? >
< ? import r.A ? >
<VBox fx:id="top">
<MenuBarControl fx:id="menuBarControl"/>
</VBox>
While trying to run Jar application using JWS (JNLP) launch. It has been giving me this error. Can't even find where is the mistake. Any directions would help.
If someone could tell me where is the potential location of this error, I could find post that code here.
java.lang.NumberFormatException: For input string: "\Tools_Dev\TestApp\dist"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at com.sun.deploy.security.DeployManifestChecker.verifyCodebaseEx(Unknown Source)
at com.sun.deploy.security.DeployManifestChecker.verifyCodebase(Unknown Source)
at com.sun.deploy.security.DeployManifestChecker.verify(Unknown Source)
at com.sun.deploy.security.DeployManifestChecker.verify(Unknown Source)
at com.sun.javaws.security.AppPolicy.grantUnrestrictedAccess(Unknown Source)
at com.sun.javaws.security.JNLPSignedResourcesHelper.checkSignedResourcesHelper(Unknown Source)
at com.sun.javaws.security.JNLPSignedResourcesHelper.checkSignedResources(Unknown Source)
at com.sun.javaws.Launcher.prepareResources(Unknown Source)
at com.sun.javaws.Launcher.prepareAllResources(Unknown Source)
at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
at com.sun.javaws.Launcher.launch(Unknown Source)
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main.access$000(Unknown Source)
at com.sun.javaws.Main$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Note: I have the latest Java 8 installed and working on Netbeans.
The jar file works well if called manually, java -jar testTool.jar
Update:
JNLP File Content:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jnlp codebase="file:/C:/Tools_Dev/TestApp/dist/" href="launch.jnlp" spec="1.0+">
<information>
<title>Java Tool Update Test</title>
<vendor>Local</vendor>
<description>Test Tool</description>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<update check="background"/>
<resources>
<j2se version="1.7+"/>
<jar href="Java-Tool-Update-Test.jar" main="true"/>
<jar href="lib/sqlite-jdbc-3.7.15-M1.jar"/>
<jar href="lib/poi-3.10-FINAL-20140208.jar"/>
<jar href="lib/poi-ooxml-3.10-FINAL-20140208.jar"/>
<jar href="lib/poi-ooxml-schemas-3.10-FINAL-20140208.jar"/>
<jar href="lib/dom4j-1.6.1.jar"/>
<jar href="lib/xmlbeans-2.3.0.jar"/>
<jar href="lib/jaxen-1.1.6.jar"/>
</resources>
<application-desc main-class="Tool.Test.Main">
</application-desc>
</jnlp>
Errors prompted in JaNeLa tool excluding warnings and optimizations:
JaNeLA Report - version 11.05.17
cvc-complex-type.2.4.a: Invalid content was found starting with element 'security'. One of '{resources, application-desc, applet-desc, component-desc, installer-desc}' is expected.
cvc-complex-type.2.4.a: Invalid content was found starting with element 'security'. One of '{resources, application-desc, applet-desc, component-desc, installer-desc}' is expected.
Lazy downloads might not work as expected for lib/sqlite-jdbc-3.7.15-M1.jar unless the download 'part' is specified.
Lazy downloads might not work as expected for lib/poi-3.10-FINAL-20140208.jar unless the download 'part' is specified.
Lazy downloads might not work as expected for lib/poi-ooxml-3.10-FINAL-20140208.jar unless the download 'part' is specified.
Lazy downloads might not work as expected for lib/poi-ooxml-schemas-3.10-FINAL-20140208.jar unless the download 'part' is specified.
Lazy downloads might not work as expected for lib/dom4j-1.6.1.jar unless the download 'part' is specified.
Lazy downloads might not work as expected for lib/xmlbeans-2.3.0.jar unless the download 'part' is specified.
Lazy downloads might not work as expected for lib/jaxen-1.1.6.jar unless the download 'part' is specified.
Posting this here in case someone has that very same error, even with java 8 Update 101:
In our specific case, after a few hours of digging, the problem ended up being that NetBeans version 7.4 was putting some useless junk on the Codebase property of the jar's MANIFEST.MF; by going into the project properties, Application -> Web Start and then changing Codebase to User defined and Codebase Preview to *, the application started working correctly.
Please do keep in mind that we're using an applet instead of a JNLP application, so your mileage may vary.
Looks like a known issue... See Bug #236765
Upgrading your Java version as specified in the bug.
Not a NB issue, javaws problem. I've tested
https://netbeans.org/kb/73/java/javase-jws.html with JDK 1.7.0_45 and
works fine.Please update JDK JRE.
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);
}
}
I try to execute my first spring application but I'm getting error. I'm new to spring can you help me out here that would be appreciated. Here are the codes
package com.bam.springexample;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class MainApp {
/**
* #param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");
HelloSpring obj = (HelloSpring)context.getBean("msgid");
obj.getMessage();
}
}
here is the POJO class.....
package com.bam.springexample;
public class HelloSpring {
private String message;
public void getMessage() {
System.out.println("Your Message is "+ message);
}
public void setMessage(String message) {
this.message = message;
}
}
the beans.xml is
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="msgid" class="com.bam.springexmple.HelloSpring">
<property name="message" value="Hello Bamadeva Its your first Spring Program ."/>
</bean>
</beans>
error I'm getting is
Jun 16, 2013 10:12:22 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext#1608e05: display name [org.springframework.context.support.ClassPathXmlApplicationContext#1608e05]; startup date [Sun Jun 16 10:12:22 IST 2013]; root of context hierarchy
Jun 16, 2013 10:12:22 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [Beans.xml]
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [Beans.xml]; nested exception is java.io.FileNotFoundException: class path resource [Beans.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:320)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:290)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:142)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:158)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:184)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:112)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:79)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:97)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:411)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:338)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:122)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:66)
at com.bam.springexample.MainApp.main(MainApp.java:13)
Caused by: java.io.FileNotFoundException: class path resource [Beans.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:142)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:307)
... 12 more
Thanks In Advance...
Edited here after I placed the bean.sml into src folder
Caused by: org.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanPIData(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanPIData(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanPI(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:78)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:361)
... 13 more
The beans file Beans.xml is not being found. You should place Beans.xml in your classpath.
Just right click on src folder in eclipse and click new then other and create a new xml file. Put all your code of beans.xml in that file.
<bean id="helloWorld" class="com.practice.HelloWorld">
<property name="message" value="Hello World!"/>
</bean>
I declared the bean as above.
Call the bean as follows.
ApplicationContext context =
new ClassPathXmlApplicationContext("Beans.xml");
HelloWorld obj = (HelloWorld) context.getBean("helloWorld");
This works for me. I can get the value of message.
Spring is looking for Beans.xml and not finding it on the class path.
The file might well be in your current working directory or somewhere else obvious to humans, but it must be on the Java class path for a ClassPathXmlApplicationContext to find it properly.
Put Beans.xml inside project Build path. Following are the steps
Right click on the project => select Build path => select configure build path
Select Java Build Path => Source => Click on Included
Then click on Add and add your Beans.xml
Final configuration is like this:
Click on Finish and save all changes. Run the project with ctrl+F11.
Go to the physical location of the application and place the .xml file
Ex :C:\Workspace\application-name\target\classes