Tuesday, November 12, 2013

Eclipse Maven Issue : 'dependencies.dependency.version' for jar is missing

Having trouble building a new Maven Project in Eclipse. I get the following exception regarding missing dependencies, even though I have added the dependency for this jar in the parent pom with a version tag.

Child pom.xml:

  <dependencies>
            <dependency>
                <groupId>com.oracle.jars.common</groupId>
                <artifactId>javax.ejb_3.0.1</artifactId>
            </dependency>
                      ...
                      Other Dependencies
        </dependencies>

Parent pom.xml:

        <dependencies>
            <dependency>
                <groupId>com.oracle.jars.common</groupId>
                <artifactId>javax.ejb_3.0.1</artifactId>
                <version>11.1.1.4.0</version>
                <scope>compile</scope>
            </dependency>
           
            ...
            ...
            Other Dependencies
            ...
            ...
        </dependencies>


Error:

 The project testwebapp-parent:testapp:1.0-SNAPSHOT (C:\workspace\testwebapp-parent\testwebapp\pom.xml) has 2 errors
[ERROR]     'dependencies.dependency.version' for com.oracle.jars.common:javax.ejb_3.0.1:jar is missing. @ line 18, column 15
[ERROR]     'dependencies.dependency.version' for com.oracle.jars.common:javax.jms_1.1.1:jar is missing. @ line 22, column 15


If I run it with '-N'  option in Run Configurations as shown below it works fine, but it doesn't fix the problem when I run it on remote build environment like Hudson, or if I try to directly run it.



Solution :

The fix to the problem is having a <dependencyManagement> tag in your parent POM.
I just had <dependencies> tag in my parent pom. After adding this tag it works just fine.


Parent pom.xml:

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.oracle.jars.common</groupId>
                <artifactId>javax.ejb_3.0.1</artifactId>
                <version>11.1.1.4.0</version>
                <scope>compile</scope>
            </dependency>
           
            ...
            ...
            Other Dependencies
            ...
            ...
        </dependencies>
    </dependencyManagement>

Apache Maven - Non-resolvable parent POM

Facing following exception while creating a new Maven Project.

My Parent POM file had some invalid open tags which caused build failure, After I removed those tags, I receive following exception:

[ERROR]     Non-resolvable parent POM: Failure to find testapp-parent:pom:1.0-SNAPSHOT in http://mavenrepo.test.com/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of maven has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 3, column 10 -> [Help 2]
[ERROR]  


Looks like to me that its still picking up the previous POM which had errors, probably because that was pushed to the local repository. Doing a clean install did not help me.

I looked into mt local repository for the file with .lastUpdated suffix,
testapp-parent-1.0-SNAPSHOT.pom.lastUpdated

I tried adding an empty tag <relativePath/> but it did not resolve the issue.
Also I deleted the project folder itself from my local repository, still din't help.

Sunday, November 10, 2013

MongoDB Couldn't connect to [127.0.0.1] couldn't connect to server 127.0.0.1:27017

Getting following exception while trying to import the data into MongoDB from a CSV file on a remote linux box.

>mongoimport -d EmpDatabase -c EmployeeRecords --type csv --file /var/lib/testuser/root/data/emp-datasheet.csv --headerline

Couldn't connect to [127.0.0.1] couldn't connect to server 127.0.0.1:27017

Solution:

This requires the host and port to be specified with mongoimport command:

--host <hostname><:port>

Example:

>mongoimport --host <<HOST>>:<<PORT>> -d EmpDatabase -c EmployeeRecords --type csv --file /var/lib/testuser/root/data/emp-datasheet.csv --headerline

SFTP Command to transfer files remotely

I was looking for something similar to WinScp for MacBook Pro, but could not find it. There are similar tools available to do the same task but I did'nt want to install an unknown application.

Finally I had to resort to SFTP.

In the following example I am trying to connect to a remote Linux server from my local MacBook-Pro and upload some *.csv files from my local folder to a remote folder.

Steps:
  • Connect to remote server
> sftp remote.secure-wb1-hvbd.com

Connecting to remote.secure-wb1-hvbd.com...
remote.secure-wb1-hvbd.com FTP server ready.
Name: yourusername
Password: 

//// Provide user and password for authentication

  • Navigate to Remote Destination Directory
Connected to remote.secure-wb1-hvbd.com
sftp> cd /var/lib/users/test/destination-dir

  • Use the lcd command to specify the local source directory where file to be uploaded, exists.
sftp> lcd /Users/localuser/workspace/server-data

  • Use the put (single file), mput (multiple files) commands to upload the files to remote directory.
Example :
// Upload all *.csv files using mput command
sftp> mput *.csv

Or 
// Upload a specific file using put command
sftp> put testout.csv

  •  Similarly get and mget can be used to retrieve the files.
  • For larger files, we might encounter the following error [rite failed: Broken pipe]. Use the zip utility to  zip the file first and then do sftp. For Example:
//Zip the file on local server
>gzip testout.csv
 //It will create testout.csv.gz

// Upload on server using SFTP as mentioned above

//Unzip the file on remote server 
>gzip -d testout.csv.gz


Friday, November 8, 2013

weblogic.management.DeploymentException: Error encountered during prepare phase of deploying WebService module

Getting following exception when trying to deploy the webserive on Weblogic 11G Server. The class is part of the war file packaged but server is reporting the Class Not found exception :

<Nov 8, 2013 3:05:59 PM CST> <Error> <Console> <BEA-240003> <Console encountered the following error weblogic.management.DeploymentException: Error encountered during prepare phase of deploying WebService module 'test-webappweb-war.war'. Class not found for link: TestWebService:  avaialbe:{}
        at weblogic.wsee.deploy.WSEEModule.prepare(WSEEModule.java:153)
        at weblogic.wsee.deploy.AppDeploymentExtensionFactory.prepare(AppDeploymentExtensionFactory.java:79)
        at weblogic.wsee.deploy.AppDeploymentExtensionFactory.access$100(AppDeploymentExtensionFactory.java:15)
        at weblogic.wsee.deploy.AppDeploymentExtensionFactory$1.prepare(AppDeploymentExtensionFactory.java:219)
        at weblogic.application.internal.flow.AppDeploymentExtensionFlow.prepare(AppDeploymentExtensionFlow.java:23)
        at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:648)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
        at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:191)
        at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:59)
        at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:154)
        at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
        at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:208)
        at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:98)
        at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217)
        at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747)
        at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216)
        at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250)
        at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
        at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
        at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
        at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
        at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Caused by: java.lang.IllegalArgumentException: Class not found for link: TestWebService:   avaialbe:{}
        at weblogic.wsee.deploy.WSEEAnnotationProcessor.loadPorts(WSEEAnnotationProcessor.java:311)
        at weblogic.wsee.deploy.WSEEAnnotationProcessor.load(WSEEAnnotationProcessor.java:292)
        at weblogic.wsee.deploy.WSEEAnnotationProcessor.process(WSEEAnnotationProcessor.java:63)
        at weblogic.wsee.deploy.WSEEAnnotationProcessor.process(WSEEAnnotationProcessor.java:52)
        at weblogic.wsee.deploy.WSEEModule.prepare(WSEEModule.java:111)

[ERROR] The prefix "soap" for element "soap:binding" is not bound.

I encountered the following Exception while making WSDL changes for JAX RPC to JAXWS:
 
INFO] jaxws:wsimport args: [-s, C:\workspace2013\test-search-parent\test-search\target\jaxws\wsimport\java, -d, C:\workspace2013\test-search-parent\test-search\target\classes, -extension, -Xnocompile, -b, C:\workspace2013\test-search-parent\test-search\src\main\wsdl\wsdl-customize.xml, C:\workspace2013\test-search-parent\test-search/src/main/wsdl/TesWebWSDL.wsdl]
parsing WSDL...


[ERROR] The prefix "soap" for element "soap:binding" is not bound.
  line 368 of file:/C:/workspace2013/test-search-parent/test-search/src/main/wsdl/TesWebWSDL.wsdl

[ERROR] The prefix "soap" for element "soap:binding" is not bound.

Its a small fix. I forgot to add the required prefix in wsdl definitions. We need to add the "soap" prefix in WSDL definition tag as shown below:

&lt;wsdl:definitions name="TesWebWSDL" targetNamespace="http://www.testweburl.com/wsdl/TesWebServ" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:srch="http://www.testweburl.com/wsdl/TesWebServ" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:params="http://www.testweburl.com/TesWebServ/dataobj"&gt;

Monday, November 4, 2013

Apache Wicket - The object type is not Serializable

One of the common exceptions in Wicket is the Serialization exception as Wicket maintains the page maps and serializes and deserialize the page components along with components :

One of the solutions to the problem would be to either make the object in question "transient"
or make its class implement "Serializable" interace.

In this case the object of "TestDataServiceImpl" class needs to be declared with transient modifier
or its class should implement the Serializable interface.

Stacktrace :

22:53:33,267 WARN  [org.apache.wicket.pageStore.DefaultPageStore] (http-localhost-127.0.0.1-8080-1) Page [Page class = com.testwebapp.web.TestPage, id = 1, render count = 1] cannot be serialized. See previous logs for possible reasons.
22:53:33,791 ERROR [org.apache.wicket.serialize.java.JavaSerializer] (http-localhost-127.0.0.1-8080-1) Error serializing object class com.testwebapp.web.TestPage [object=[Page class = com.testwebapp.web.TestPage, id = 1, render count = 1]]: org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream$ObjectCheckException: The object type is not Serializable!
A problem occurred while checking object with type: com.testwebapp.service.impl.TestDataServiceImpl
Field hierarchy is:
  1 [class=com.testwebapp.web.TestPage, path=1]
    private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;]
      private final org.apache.wicket.datetime.DateConverter org.apache.wicket.datetime.markup.html.form.DateTextField.converter[2] [class=com.testwebapp.web.panel.OpportunityDetailsPanel, path=1:opportunityDetailContainer]
        private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;]
          private java.lang.Object org.apache.wicket.MarkupContainer.children[0] [class=com.testwebapp.web.panel.TestDetailsPanel, path=1:opportunityDetailContainer:eventDetailPanel]
            private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;]
              java.lang.Object org.apache.wicket.Component.data[1] [class=com.testwebapp.web.panel.TestExportRawDataPanel, path=1:opportunityDetailContainer:eventDetailPanel:supRawDataContainer]
                com.testwebapp.service.impl.TestDataServiceImpl com.testwebapp.web.panel.TestExportRawDataPanel.TestDataService [class=com.testwebapp.service.impl.TestDataServiceImpl] <----- field that is causing the problem
    at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.internalCheck(CheckingObjectOutputStream.java:387) [wicket-core-6.10.0.jar:6.10.0]
        at org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream.writeObjectOverride(CheckingObjectOutputStream.java:713) [wicket-core-6.10.0.jar:6.10.0]
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:325) [classes.jar:1.6.0_65]
    at org.apache.wicket.serialize.java.JavaSerializer$SerializationCheckerObjectOutputStream.writeObjectOverride(JavaSerializer.java:268) [wicket-core-6.10.0.jar:6.10.0]
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:325) [classes.jar:1.6.0_65]
    at org.apache.wicket.serialize.java.JavaSerializer.serialize(JavaSerializer.java:78) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.pageStore.DefaultPageStore.serializePage(DefaultPageStore.java:376) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.pageStore.DefaultPageStore.storePage(DefaultPageStore.java:150) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.page.PageStoreManager$PersistentRequestAdapter.storeTouchedPages(PageStoreManager.java:410) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.page.RequestAdapter.commitRequest(RequestAdapter.java:181) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.page.AbstractPageManager.commitRequest(AbstractPageManager.java:98) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.page.PageManagerDecorator.commitRequest(PageManagerDecorator.java:73) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.page.PageAccessSynchronizer$2.commitRequest(PageAccessSynchronizer.java:281) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.Application$2.onDetach(Application.java:1628) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.request.cycle.RequestCycleListenerCollection$3.notify(RequestCycleListenerCollection.java:105) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.request.cycle.RequestCycleListenerCollection$3.notify(RequestCycleListenerCollection.java:101) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.util.listener.ListenerCollection$1.notify(ListenerCollection.java:120) [wicket-util-6.10.0.jar:6.10.0]
    at org.apache.wicket.util.listener.ListenerCollection.reversedNotify(ListenerCollection.java:144) [wicket-util-6.10.0.jar:6.10.0]
    at org.apache.wicket.util.listener.ListenerCollection.reversedNotifyIgnoringExceptions(ListenerCollection.java:113) [wicket-util-6.10.0.jar:6.10.0]
    at org.apache.wicket.request.cycle.RequestCycleListenerCollection.onDetach(RequestCycleListenerCollection.java:100) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.request.cycle.RequestCycle.onDetach(RequestCycle.java:640) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.request.cycle.RequestCycle.detach(RequestCycle.java:589) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:293) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:201) [wicket-core-6.10.0.jar:6.10.0]
    at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:282) [wicket-core-6.10.0.jar:6.10.0]
        at java.lang.Thread.run(Thread.java:695) [classes.jar:1.6.0_65]
Caused by: java.io.NotSerializableException: com.testwebapp.service.impl.TestDataServiceImpl
     at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:329) [classes.jar:1.6.0_65]
    at org.apache.wicket.serialize.java.JavaSerializer$SerializationCheckerObjectOutputStream.writeObjectOverride(JavaSerializer.java:260) [wicket-core-6.10.0.jar:6.10.0]
    ... 35 more

22:53:33,832 WARN  [org.apache.wicket.pageStore.DefaultPageStore] (http-localhost-127.0.0.1-8080-1) Page [Page class = com.testwebapp.web.TestPage, id = 1, render count = 1] cannot be serialized. See previous logs for possible reasons.


Saturday, November 2, 2013

java.lang.ClassNotFoundException: com.apple.laf.AquaLookAndFeel

 Following exception occurred on Jboss while using JFreeChart on mac, The code works fine on Linux and windows.

Stacktrace:

14:22:57,220 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/testweb].[default]] (http-localhost-127.0.0.1-8080-1) Servlet.service() for servlet default threw exception: java.lang.ClassNotFoundException: com.apple.laf.AquaLookAndFeel from [Module "deployment.testweb.war:main" from Service Module Loader]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
    at java.lang.Class.forName0(Native Method) [classes.jar:1.6.0_65]
    at java.lang.Class.forName(Class.java:249) [classes.jar:1.6.0_65]

Solution :
We need to add com.apple.laf dependencies to Jboss to add the required jars in classpath.Add the following -D option in Jboss Startup variables and restart.

-Dswing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeel