1
votes

I need to overwrite /util-java/src/com/liferay/util/Normalizer.java

I found code on git.

I followed this instructions and able to do ant clean

I read this

Putted my .java file in my-ext-plugin/docroot/WEB-INF/ext-util-java/com/liferay/util/Normalizer.java

ant build

  BUILD FAILED
`/liferay/plugins/liferay-plugins-sdk-6.1.0-ce-ga1/ext/build-common-ext.xml:122: The` following error occurred while executing this line:
/liferay/plugins/liferay-plugins-sdk-6.1.0-ce-ga1/ext/build-common-ext.xml:173: The following error occurred while executing this line:
/liferay/plugins/liferay-plugins-sdk-6.1.0-ce-ga1/build-common.xml:80: /liferay/plugins/liferay-plugins-sdk-6.1.0-ce-ga1/ext/normalizer-ext/docroot/WEB-INF/ext-service/src does not exist.

I know that the right way is to create an child of Normalizer.java and overwrite those private methods but I'm wondering where to put those files.

I surprised how little information you can find about this. And all Liferay gurus acting like it's very simple. But it's not.

UPDATE

buld.username.properties

    app.server.dir = /liferay/bundles/liferay-portal-6.1.0-ce-ga1-new/tomcat-7.0.23
    ext.work.dir = /liferay/bundles
    app.server.zip = /liferay/portal/liferay-portal-tomcat-6.1.0-ce-ga1.zip

UPDATE 2

I created ext-service/src folder and was rewarded by BUILD SUCCESSFUL.

ant compile and ant deploy is working

url-redirect-fix-ext is the name of my ext plugin.

[root@localhost url-redirect-fix-ext]# ant deploy
Buildfile: /liferay/plugins/liferay-plugins-sdk-6.1.0-ce-ga1/ext/url-redirect-fix-ext/build.xml

compile:

compile-with-global-class-loader:

compile-java:

compile-with-portal-class-loader:

compile-java:

compile-with-portal-class-loader:

compile-java:

compile-with-portal-class-loader:

compile-java:

compile-with-portal-class-loader:

compile-java:

war:

war-util:

war-util:

war-util:
   [delete] Deleting: /liferay/plugins/liferay-plugins-sdk-6.1.0-ce-ga1/dist/url-redirect-fix-ext-6.1.0.1.war
      [zip] Building zip: /liferay/plugins/liferay-plugins-sdk-6.1.0-ce-ga1/dist/url-redirect-fix-ext-6.1.0.1.war
   [delete] Deleting: /liferay/plugins/liferay-plugins-sdk-6.1.0-ce-ga1/ext/url-redirect-fix-ext/docroot/WEB-INF/ext-url-redirect-fix-ext.xml

deploy:
     [copy] Copying 1 file to /liferay/bundles/liferay-portal-6.1.0-ce-ga1-new/deploy

BUILD SUCCESSFUL

But ant deploy not working

[root@localhost url-redirect-fix-ext]# ant build
Buildfile: /liferay/plugins/liferay-plugins-sdk-6.1.0-ce-ga1/ext/url-redirect-fix-ext
/build.xml

BUILD FAILED
Target "build" does not exist in the project "url-redirect-fix-ext". 

I followed instructions and deployed my plug-in, then rebooted server.

Here is my Tomcat log. I guess plug-in was deployed successfully.

15:36:18,815 INFO  [AutoDeployDir:167] Processing url-redirect-fix-ext-6.1.0.1.war
15:36:18,818 INFO  [ExtAutoDeployListener:43] Copying extension environment plugin for /liferay/bundles/liferay-portal-6.1.0-ce-ga1-new/deploy/url-redirect-fix-ext-6.1.0.1.war
  Expanding: /liferay/bundles/liferay-portal-6.1.0-ce-ga1-new/deploy/url-redirect-fix-ext-6.1.0.1.war into /liferay/bundles/liferay-portal-6.1.0-ce-ga1-new/tomcat-7.0.23/temp/20120605153618829
  Copying 1 file to /liferay/bundles/liferay-portal-6.1.0-ce-ga1-new/tomcat-7.0.23/temp/20120605153618829/WEB-INF
  Copying 1 file to /liferay/bundles/liferay-portal-6.1.0-ce-ga1-new/tomcat-7.0.23/temp/20120605153618829/WEB-INF/classes
  Copying 1 file to /liferay/bundles/liferay-portal-6.1.0-ce-ga1-new/tomcat-7.0.23/temp/20120605153618829/WEB-INF/classes
  Copying 1 file to /liferay/bundles/liferay-portal-6.1.0-ce-ga1-new/tomcat-7.0.23/temp/20120605153618829/WEB-INF
  Warning: WEB-INF/ext-impl/classes/com/liferay/portal/deploy/dependencies/ext-url-redirect-fix-ext-util-bridges.jar modified in the future.
  Warning: WEB-INF/ext-impl/classes/com/liferay/portal/deploy/dependencies/ext-url-redirect-fix-ext-util-java.jar modified in the future.
  Warning: WEB-INF/ext-impl/classes/com/liferay/portal/deploy/dependencies/ext-url-redirect-fix-ext-util-taglib.jar modified in the future.
  Warning: WEB-INF/ext-impl/ext-impl.jar modified in the future.
  Warning: WEB-INF/ext-service/ext-service.jar modified in the future.
  Warning: WEB-INF/ext-util-bridges/ext-util-bridges.jar modified in the future.
  Warning: WEB-INF/ext-util-java/ext-util-java.jar modified in the future.
  Warning: WEB-INF/ext-util-taglib/ext-util-taglib.jar modified in the future.
  Warning: WEB-INF/ext-web/docroot/WEB-INF/liferay-portlet-ext.xml modified in the future.
  Warning: WEB-INF/ext-web/docroot/WEB-INF/portlet-ext.xml modified in the future.
  Warning: WEB-INF/ext-web/docroot/WEB-INF/struts-config-ext.xml modified in the future.
  Warning: WEB-INF/ext-web/docroot/WEB-INF/tiles-defs-ext.xml modified in the future.
  Warning: WEB-INF/liferay-plugin-package.properties modified in the future.
  Warning: WEB-INF/ext-impl/classes modified in the future.
  Warning: WEB-INF/ext-impl/classes/com/liferay modified in the future.
  Warning: WEB-INF/ext-impl/classes/com/liferay/portal modified in the future.
  Warning: WEB-INF/ext-impl/classes/com/liferay/portal/deploy modified in the future.
  Warning: WEB-INF/ext-impl/src modified in the future.
  Warning: WEB-INF/ext-lib modified in the future.
  Warning: WEB-INF/ext-lib/global modified in the future.
  Warning: WEB-INF/ext-lib/portal modified in the future.
  Warning: WEB-INF/ext-service/classes modified in the future.
  Warning: WEB-INF/ext-service/src modified in the future.
  Warning: WEB-INF/ext-util-bridges modified in the future.
  Warning: WEB-INF/ext-util-bridges/classes modified in the future.
  Warning: WEB-INF/ext-util-bridges/src modified in the future.
  Warning: WEB-INF/ext-util-java modified in the future.
  Warning: WEB-INF/ext-util-java/classes modified in the future.
  Warning: WEB-INF/ext-util-java/com modified in the future.
  Warning: WEB-INF/ext-util-java/com/liferay modified in the future.
  Warning: WEB-INF/ext-util-java/com/liferay/util modified in the future.
  Warning: WEB-INF/ext-util-java/src modified in the future.
  Warning: WEB-INF/ext-util-taglib modified in the future.
  Warning: WEB-INF/ext-util-taglib/classes modified in the future.
  Warning: WEB-INF/ext-util-taglib/src modified in the future.
  Warning: WEB-INF/ext-web modified in the future.
  Warning: WEB-INF/ext-web/docroot modified in the future.
  Copying 8 files to /liferay/bundles/liferay-portal-6.1.0-ce-ga1-new/tomcat-7.0.23/webapps/url-redirect-fix-ext
  Copying 2 files to /liferay/bundles/liferay-portal-6.1.0-ce-ga1-new/tomcat-7.0.23/webapps/url-redirect-fix-ext
  Deleting directory /liferay/bundles/liferay-portal-6.1.0-ce-ga1-new/tomcat-7.0.23/temp/20120605153618829
15:36:19,062 INFO  [ExtAutoDeployListener:50] Extension environment for /liferay/bundles/liferay-portal-6.1.0-ce-ga1-new/deploy/url-redirect-fix-ext-6.1.0.1.war copied successfully. Deployment will start in a few seconds.
Jun 5, 2012 3:36:25 PM org.apache.catalina.startup.HostConfig checkResources
INFO: Reloading context [/url-redirect-fix-ext]
15:36:25,612 INFO  [PluginPackageUtil:1099] Reading plugin package for url-redirect-fix-ext
15:36:25,618 INFO  [ExtHotDeployListener:226] Extension environment for url-redirect-fix-ext will not be undeployed
15:36:26,090 INFO  [PluginPackageUtil:1099] Reading plugin package for url-redirect-fix-ext
15:36:26,133 INFO  [ExtHotDeployListener:234] Registering extension environment for url-redirect-fix-ext
15:36:26,133 INFO  [ExtHotDeployListener:152] Extension environment for url-redirect-fix-ext has been applied.

Not working. There is still bug in my portal.

So ether the solution I found on Git not handled my bug Or the new Normalizer.java not overrided old Normalizer.class

How can I be sure?

UPDATE 3

ant deploy

ERROR [ExtHotDeployListener:189] Extension environment for normalizer-ext cannot be applied because of detected conflicts:
url-redirect-fix-ext:
    ext-util-java/com/liferay/util/Normalizer.java
    ext-web/docroot/WEB-INF/liferay-portlet-ext.xml
    ext-web/docroot/WEB-INF/portlet-ext.xml
    ext-web/docroot/WEB-INF/struts-config-ext.xml
    ext-web/docroot/WEB-INF/tiles-defs-ext.xml
    ext-web/docroot/WEB-INF/web.xml
1
Hi, did you try "ant compile" on your /my-ext-plugin/>?Felix Christy
@FelixChristy thanks for reply. I did. Got the same output as from ant buid. I think I should put Normalizer.java to a propper location and add some properties.Boris Y.
I tried ant clean-app-server direct-deploy. Looks like Liferay can't find my zip file.Boris Y.
I double checked my properties. Can't find a problem. Please check properties in the question.Boris Y.
I've edited the question in reply to your comment on my answer. Please make sure that this is accurate with regards to your actual setup. (and take a look at my edit to my answer as well)Olaf Kock

1 Answers

1
votes

You change code from util-java, but put it into util-bridges? Try putting it in ext-util-java. It seems that there's no spring autowiring involved calling this, and there are only static methods in that class, so you probably just need to copy the existing code and patch it as you like, then compile.

Edit/Added:

From the error message it looks like you followed this paragraph from http://www.liferay.com/documentation/liferay-portal/6.0/development/-/ai/creating-an-ext-plugin too hard:

Tip: after creating an Ext plugin, remove all of the files added by default that are not necessary for the extension. This is important because Liferay keeps track of the files deployed by each Ext plugin and it won't allow deploying two Ext plugins if they override the same file to avoid collisions. By removing any files not really necessary from an ext plugin it will be easier to use along with other Ext plugins.

You should only remove the unrequired files in the plugin - not the directories. The errormessage you state says that

normalizer-ext/docroot/WEB-INF/ext-service/src does not exist

Edit 2:

In your latest edit you say that "ant deploy" is not working but the command that you actually execute is "ant build" - with ant complaining that the "build" target is not found. Try again with "ant deploy"

Edit 3:

This is more an interactive debugging session than a Q&A :-)

You can have as many ext plugins as you like, but every file can only be overridden (contained) in one ext plugin. The error message tells you what's wrong: The files that the build process complains about are modified from different ext-plugins. That's why the quote (see above in my answer, the "Tip" section) says to remove the files from your plugin unless you really need&override them. The files that the build process is complaining about are exactly the files that the create-script automatically starts an ext plugin with.